下面列出了java.awt.Font#getAttributes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Constructs a <code>TextLayout</code> from a <code>String</code>
* and a {@link Font}. All the text is styled using the specified
* <code>Font</code>.
* <p>
* The <code>String</code> must specify a single paragraph of text,
* because an entire paragraph is required for the bidirectional
* algorithm.
* @param string the text to display
* @param font a <code>Font</code> used to style the text
* @param frc contains information about a graphics device which is needed
* to measure the text correctly.
* Text measurements can vary slightly depending on the
* device resolution, and attributes such as antialiasing. This
* parameter does not specify a translation between the
* <code>TextLayout</code> and user space.
*/
public TextLayout(String string, Font font, FontRenderContext frc) {
if (font == null) {
throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
}
if (string == null) {
throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
}
if (string.length() == 0) {
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
Map<? extends Attribute, ?> attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
char[] text = string.toCharArray();
if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
fastInit(text, font, attributes, frc);
} else {
AttributedString as = attributes == null
? new AttributedString(string)
: new AttributedString(string, attributes);
as.addAttribute(TextAttribute.FONT, font);
standardInit(as.getIterator(), text, frc);
}
}
/**
* Constructs a <code>TextLayout</code> from a <code>String</code>
* and a {@link Font}. All the text is styled using the specified
* <code>Font</code>.
* <p>
* The <code>String</code> must specify a single paragraph of text,
* because an entire paragraph is required for the bidirectional
* algorithm.
* @param string the text to display
* @param font a <code>Font</code> used to style the text
* @param frc contains information about a graphics device which is needed
* to measure the text correctly.
* Text measurements can vary slightly depending on the
* device resolution, and attributes such as antialiasing. This
* parameter does not specify a translation between the
* <code>TextLayout</code> and user space.
*/
public TextLayout(String string, Font font, FontRenderContext frc) {
if (font == null) {
throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
}
if (string == null) {
throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
}
if (string.length() == 0) {
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
Map<? extends Attribute, ?> attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
char[] text = string.toCharArray();
if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
fastInit(text, font, attributes, frc);
} else {
AttributedString as = attributes == null
? new AttributedString(string)
: new AttributedString(string, attributes);
as.addAttribute(TextAttribute.FONT, font);
standardInit(as.getIterator(), text, frc);
}
}
/**
* Constructs a <code>TextLayout</code> from a <code>String</code>
* and a {@link Font}. All the text is styled using the specified
* <code>Font</code>.
* <p>
* The <code>String</code> must specify a single paragraph of text,
* because an entire paragraph is required for the bidirectional
* algorithm.
* @param string the text to display
* @param font a <code>Font</code> used to style the text
* @param frc contains information about a graphics device which is needed
* to measure the text correctly.
* Text measurements can vary slightly depending on the
* device resolution, and attributes such as antialiasing. This
* parameter does not specify a translation between the
* <code>TextLayout</code> and user space.
*/
public TextLayout(String string, Font font, FontRenderContext frc) {
if (font == null) {
throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
}
if (string == null) {
throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
}
if (string.length() == 0) {
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
Map<? extends Attribute, ?> attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
char[] text = string.toCharArray();
if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
fastInit(text, font, attributes, frc);
} else {
AttributedString as = attributes == null
? new AttributedString(string)
: new AttributedString(string, attributes);
as.addAttribute(TextAttribute.FONT, font);
standardInit(as.getIterator(), text, frc);
}
}
/**
* Constructs a <code>TextLayout</code> from a <code>String</code>
* and a {@link Font}. All the text is styled using the specified
* <code>Font</code>.
* <p>
* The <code>String</code> must specify a single paragraph of text,
* because an entire paragraph is required for the bidirectional
* algorithm.
* @param string the text to display
* @param font a <code>Font</code> used to style the text
* @param frc contains information about a graphics device which is needed
* to measure the text correctly.
* Text measurements can vary slightly depending on the
* device resolution, and attributes such as antialiasing. This
* parameter does not specify a translation between the
* <code>TextLayout</code> and user space.
*/
public TextLayout(String string, Font font, FontRenderContext frc) {
if (font == null) {
throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
}
if (string == null) {
throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
}
if (string.length() == 0) {
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
Map<? extends Attribute, ?> attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
char[] text = string.toCharArray();
if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
fastInit(text, font, attributes, frc);
} else {
AttributedString as = attributes == null
? new AttributedString(string)
: new AttributedString(string, attributes);
as.addAttribute(TextAttribute.FONT, font);
standardInit(as.getIterator(), text, frc);
}
}
@Override
public void render(Graphics g, Font defaultFont, Color defaultColor, Color backgroundColor, int width, int height, boolean selected) {
Map<TextAttribute, Object> attributes = new HashMap<>(defaultFont.getAttributes());
if (!flag.isSupported()) {
attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
}
Font font = new Font(attributes);
CompletionUtilities.renderHtml(null, getValue(), null, g, font, defaultColor, width, height, selected);
}
/**
* Constructs a <code>TextLayout</code> from a <code>String</code>
* and a {@link Font}. All the text is styled using the specified
* <code>Font</code>.
* <p>
* The <code>String</code> must specify a single paragraph of text,
* because an entire paragraph is required for the bidirectional
* algorithm.
* @param string the text to display
* @param font a <code>Font</code> used to style the text
* @param frc contains information about a graphics device which is needed
* to measure the text correctly.
* Text measurements can vary slightly depending on the
* device resolution, and attributes such as antialiasing. This
* parameter does not specify a translation between the
* <code>TextLayout</code> and user space.
*/
public TextLayout(String string, Font font, FontRenderContext frc) {
if (font == null) {
throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
}
if (string == null) {
throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
}
if (string.length() == 0) {
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
Map<? extends Attribute, ?> attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
char[] text = string.toCharArray();
if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
fastInit(text, font, attributes, frc);
} else {
AttributedString as = attributes == null
? new AttributedString(string)
: new AttributedString(string, attributes);
as.addAttribute(TextAttribute.FONT, font);
standardInit(as.getIterator(), text, frc);
}
}
/**
* Constructs a <code>TextLayout</code> from a <code>String</code>
* and a {@link Font}. All the text is styled using the specified
* <code>Font</code>.
* <p>
* The <code>String</code> must specify a single paragraph of text,
* because an entire paragraph is required for the bidirectional
* algorithm.
* @param string the text to display
* @param font a <code>Font</code> used to style the text
* @param frc contains information about a graphics device which is needed
* to measure the text correctly.
* Text measurements can vary slightly depending on the
* device resolution, and attributes such as antialiasing. This
* parameter does not specify a translation between the
* <code>TextLayout</code> and user space.
*/
public TextLayout(String string, Font font, FontRenderContext frc) {
if (font == null) {
throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
}
if (string == null) {
throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
}
if (string.length() == 0) {
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
Map attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
char[] text = string.toCharArray();
if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
fastInit(text, font, attributes, frc);
} else {
AttributedString as = attributes == null
? new AttributedString(string)
: new AttributedString(string, attributes);
as.addAttribute(TextAttribute.FONT, font);
standardInit(as.getIterator(), text, frc);
}
}
/**
* Constructs a {@code TextLayout} from a {@code String}
* and a {@link Font}. All the text is styled using the specified
* {@code Font}.
* <p>
* The {@code String} must specify a single paragraph of text,
* because an entire paragraph is required for the bidirectional
* algorithm.
* @param string the text to display
* @param font a {@code Font} used to style the text
* @param frc contains information about a graphics device which is needed
* to measure the text correctly.
* Text measurements can vary slightly depending on the
* device resolution, and attributes such as antialiasing. This
* parameter does not specify a translation between the
* {@code TextLayout} and user space.
*/
public TextLayout(String string, Font font, FontRenderContext frc) {
if (font == null) {
throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
}
if (string == null) {
throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
}
if (string.length() == 0) {
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
Map<? extends Attribute, ?> attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
char[] text = string.toCharArray();
if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
fastInit(text, font, attributes, frc);
} else {
AttributedString as = attributes == null
? new AttributedString(string)
: new AttributedString(string, attributes);
as.addAttribute(TextAttribute.FONT, font);
standardInit(as.getIterator(), text, frc);
}
}
protected Expression instantiate(Object oldInstance, Encoder out) {
Font font = (Font) oldInstance;
int count = 0;
String family = null;
int style = Font.PLAIN;
int size = 12;
Map<TextAttribute, ?> basic = font.getAttributes();
Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
for (TextAttribute key : basic.keySet()) {
Object value = basic.get(key);
if (value != null) {
clone.put(key, value);
}
if (key == TextAttribute.FAMILY) {
if (value instanceof String) {
count++;
family = (String) value;
}
}
else if (key == TextAttribute.WEIGHT) {
if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
count++;
style |= Font.BOLD;
}
}
else if (key == TextAttribute.POSTURE) {
if (TextAttribute.POSTURE_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
count++;
style |= Font.ITALIC;
}
} else if (key == TextAttribute.SIZE) {
if (value instanceof Number) {
Number number = (Number) value;
size = number.intValue();
if (size == number.floatValue()) {
count++;
}
}
}
}
Class<?> type = font.getClass();
if (count == clone.size()) {
return new Expression(font, type, "new", new Object[]{family, style, size});
}
if (type == Font.class) {
return new Expression(font, type, "getFont", new Object[]{clone});
}
return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
protected Expression instantiate(Object oldInstance, Encoder out) {
Font font = (Font) oldInstance;
int count = 0;
String family = null;
int style = Font.PLAIN;
int size = 12;
Map<TextAttribute, ?> basic = font.getAttributes();
Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
for (TextAttribute key : basic.keySet()) {
Object value = basic.get(key);
if (value != null) {
clone.put(key, value);
}
if (key == TextAttribute.FAMILY) {
if (value instanceof String) {
count++;
family = (String) value;
}
}
else if (key == TextAttribute.WEIGHT) {
if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
count++;
style |= Font.BOLD;
}
}
else if (key == TextAttribute.POSTURE) {
if (TextAttribute.POSTURE_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
count++;
style |= Font.ITALIC;
}
} else if (key == TextAttribute.SIZE) {
if (value instanceof Number) {
Number number = (Number) value;
size = number.intValue();
if (size == number.floatValue()) {
count++;
}
}
}
}
Class<?> type = font.getClass();
if (count == clone.size()) {
return new Expression(font, type, "new", new Object[]{family, style, size});
}
if (type == Font.class) {
return new Expression(font, type, "getFont", new Object[]{clone});
}
return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
/**
* Updates the charts.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
for (int i = 0; i < listOfChartPanels.size(); i++) {
JPanel panel = listOfChartPanels.get(i);
panel.removeAll();
JFreeChart chartOrNull = getModel().getChartOrNull(i);
if (chartOrNull != null) {
final ChartPanel chartPanel = new ChartPanel(chartOrNull) {
private static final long serialVersionUID = -6953213567063104487L;
@Override
public Dimension getPreferredSize() {
return DIMENSION_CHART_PANEL_ENLARGED;
}
};
chartPanel.setPopupMenu(null);
chartPanel.setBackground(COLOR_TRANSPARENT);
chartPanel.setOpaque(false);
chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
panel.add(chartPanel, BorderLayout.CENTER);
JPanel openChartPanel = new JPanel(new GridBagLayout());
openChartPanel.setOpaque(false);
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.CENTER;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
JButton openChartButton = new JButton(OPEN_CHART_ACTION);
openChartButton.setOpaque(false);
openChartButton.setContentAreaFilled(false);
openChartButton.setBorderPainted(false);
openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
openChartButton.setIcon(null);
Font font = openChartButton.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));
openChartPanel.add(openChartButton, gbc);
panel.add(openChartPanel, BorderLayout.SOUTH);
}
panel.revalidate();
panel.repaint();
}
}
protected Expression instantiate(Object oldInstance, Encoder out) {
Font font = (Font) oldInstance;
int count = 0;
String family = null;
int style = Font.PLAIN;
int size = 12;
Map<TextAttribute, ?> basic = font.getAttributes();
Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
for (TextAttribute key : basic.keySet()) {
Object value = basic.get(key);
if (value != null) {
clone.put(key, value);
}
if (key == TextAttribute.FAMILY) {
if (value instanceof String) {
count++;
family = (String) value;
}
}
else if (key == TextAttribute.WEIGHT) {
if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
count++;
style |= Font.BOLD;
}
}
else if (key == TextAttribute.POSTURE) {
if (TextAttribute.POSTURE_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
count++;
style |= Font.ITALIC;
}
} else if (key == TextAttribute.SIZE) {
if (value instanceof Number) {
Number number = (Number) value;
size = number.intValue();
if (size == number.floatValue()) {
count++;
}
}
}
}
Class<?> type = font.getClass();
if (count == clone.size()) {
return new Expression(font, type, "new", new Object[]{family, style, size});
}
if (type == Font.class) {
return new Expression(font, type, "getFont", new Object[]{clone});
}
return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
/**
* Allows reuse of the multi-line text element for computing bounds of
* changed font/text content
*
* @param fd
*/
public final void reuse( Label la, double forceWrappingSize )
{
final Font f = (Font) xs.createFont( la.getCaption( ).getFont( ) );
fm = g2d.getFontMetrics( f );
final FontRenderContext frc = g2d.getFontRenderContext( );
cachedwidth = Double.NaN;
String s = la.getCaption( ).getValue( );
if ( s == null )
{
s = IConstants.NULL_STRING;
}
else
{
// trim leading and trailing spaces.
s = s.trim( );
}
if ( s.length( ) == 0 ) // TextLayout DOESN'T LIKE EMPTY STRINGS
{
s = IConstants.ONE_SPACE;
}
String[] sa = splitOnBreaks( s, forceWrappingSize, f );
if ( sa == null )
{
iLineCount = 1;
oText = s;
tla = new TextLayout[1];
fsa = new String[1];
tla[0] = new TextLayout( s, f.getAttributes( ), frc );
fsa[0] = s;
}
else
{
iLineCount = sa.length;
oText = sa;
tla = new TextLayout[iLineCount];
fsa = new String[iLineCount];
for ( int i = 0; i < iLineCount; i++ )
{
tla[i] = new TextLayout( sa[i], f.getAttributes( ), frc );
fsa[i] = sa[i];
}
}
ins = la.getInsets( ).scaledInstance( pointsToPixels( ) );
if ( forceWrappingSize > 0 )
{
// update label with new broken content.
StringBuffer sb = new StringBuffer( );
for ( int i = 0; i < fsa.length; i++ )
{
sb.append( fsa[i] ).append( "\n" ); //$NON-NLS-1$
}
if ( sb.length( ) > 0 )
{
sb.deleteCharAt( sb.length( ) - 1 );
}
la.getCaption( ).setValue( sb.toString( ) );
}
}
protected Expression instantiate(Object oldInstance, Encoder out) {
Font font = (Font) oldInstance;
int count = 0;
String family = null;
int style = Font.PLAIN;
int size = 12;
Map<TextAttribute, ?> basic = font.getAttributes();
Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
for (TextAttribute key : basic.keySet()) {
Object value = basic.get(key);
if (value != null) {
clone.put(key, value);
}
if (key == TextAttribute.FAMILY) {
if (value instanceof String) {
count++;
family = (String) value;
}
}
else if (key == TextAttribute.WEIGHT) {
if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
count++;
style |= Font.BOLD;
}
}
else if (key == TextAttribute.POSTURE) {
if (TextAttribute.POSTURE_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
count++;
style |= Font.ITALIC;
}
} else if (key == TextAttribute.SIZE) {
if (value instanceof Number) {
Number number = (Number) value;
size = number.intValue();
if (size == number.floatValue()) {
count++;
}
}
}
}
Class<?> type = font.getClass();
if (count == clone.size()) {
return new Expression(font, type, "new", new Object[]{family, style, size});
}
if (type == Font.class) {
return new Expression(font, type, "getFont", new Object[]{clone});
}
return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
protected Expression instantiate(Object oldInstance, Encoder out) {
Font font = (Font) oldInstance;
int count = 0;
String family = null;
int style = Font.PLAIN;
int size = 12;
Map<TextAttribute, ?> basic = font.getAttributes();
Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
for (TextAttribute key : basic.keySet()) {
Object value = basic.get(key);
if (value != null) {
clone.put(key, value);
}
if (key == TextAttribute.FAMILY) {
if (value instanceof String) {
count++;
family = (String) value;
}
}
else if (key == TextAttribute.WEIGHT) {
if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
count++;
style |= Font.BOLD;
}
}
else if (key == TextAttribute.POSTURE) {
if (TextAttribute.POSTURE_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
count++;
style |= Font.ITALIC;
}
} else if (key == TextAttribute.SIZE) {
if (value instanceof Number) {
Number number = (Number) value;
size = number.intValue();
if (size == number.floatValue()) {
count++;
}
}
}
}
Class<?> type = font.getClass();
if (count == clone.size()) {
return new Expression(font, type, "new", new Object[]{family, style, size});
}
if (type == Font.class) {
return new Expression(font, type, "getFont", new Object[]{clone});
}
return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
protected Expression instantiate(Object oldInstance, Encoder out) {
Font font = (Font) oldInstance;
int count = 0;
String family = null;
int style = Font.PLAIN;
int size = 12;
Map<TextAttribute, ?> basic = font.getAttributes();
Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
for (TextAttribute key : basic.keySet()) {
Object value = basic.get(key);
if (value != null) {
clone.put(key, value);
}
if (key == TextAttribute.FAMILY) {
if (value instanceof String) {
count++;
family = (String) value;
}
}
else if (key == TextAttribute.WEIGHT) {
if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
count++;
style |= Font.BOLD;
}
}
else if (key == TextAttribute.POSTURE) {
if (TextAttribute.POSTURE_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
count++;
style |= Font.ITALIC;
}
} else if (key == TextAttribute.SIZE) {
if (value instanceof Number) {
Number number = (Number) value;
size = number.intValue();
if (size == number.floatValue()) {
count++;
}
}
}
}
Class<?> type = font.getClass();
if (count == clone.size()) {
return new Expression(font, type, "new", new Object[]{family, style, size});
}
if (type == Font.class) {
return new Expression(font, type, "getFont", new Object[]{clone});
}
return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
@SuppressWarnings("unchecked")
private void setAttributeMapFromFontSettings(Font font) {
if (font.hasLayoutAttributes()) {
map = (Map<TextAttribute, Object>) font.getAttributes();
}
}
protected Expression instantiate(Object oldInstance, Encoder out) {
Font font = (Font) oldInstance;
int count = 0;
String family = null;
int style = Font.PLAIN;
int size = 12;
Map basic = font.getAttributes();
Map clone = new HashMap(basic.size());
for (Object key : basic.keySet()) {
Object value = basic.get(key);
if (value != null) {
clone.put(key, value);
}
if (key == TextAttribute.FAMILY) {
if (value instanceof String) {
count++;
family = (String) value;
}
}
else if (key == TextAttribute.WEIGHT) {
if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
count++;
style |= Font.BOLD;
}
}
else if (key == TextAttribute.POSTURE) {
if (TextAttribute.POSTURE_REGULAR.equals(value)) {
count++;
} else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
count++;
style |= Font.ITALIC;
}
} else if (key == TextAttribute.SIZE) {
if (value instanceof Number) {
Number number = (Number) value;
size = number.intValue();
if (size == number.floatValue()) {
count++;
}
}
}
}
Class type = font.getClass();
if (count == clone.size()) {
return new Expression(font, type, "new", new Object[]{family, style, size});
}
if (type == Font.class) {
return new Expression(font, type, "getFont", new Object[]{clone});
}
return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
public void LikeLink() {
Font font = getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
setFont(font.deriveFont(attributes));
}
/**
* Adds attributes to fontmapping
*
* @param key Key value
* @param value value-value
* @param font font to add value to
* @return newly derived font
*/
@SuppressWarnings("unchecked") // No good way to do this in a type safe manner.
public static Font addFontAttribute(Object key, Object value, Font font) {
Map attributes = font.getAttributes();
attributes.put(key, value);
return font.deriveFont(attributes);
}