本文整理汇总了Java中java.awt.Font.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Font.equals方法的具体用法?Java Font.equals怎么用?Java Font.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Font
的用法示例。
在下文中一共展示了Font.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFont
import java.awt.Font; //导入方法依赖的package包/类
@Override
public void setFont(Font f) {
if (f == null) {
f = XWindow.getDefaultFont();
}
synchronized (getStateLock()) {
if (f.equals(font)) {
return;
}
font = f;
}
// as it stands currently we don't need to do layout since
// layout is done in the Component upon setFont.
//layout();
repaint();
}
示例2: testDefaultFont
import java.awt.Font; //导入方法依赖的package包/类
private static void testDefaultFont(final JFrame frame) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JSpinner spinner = new JSpinner();
frame.add(spinner);
frame.setSize(300, 100);
frame.setVisible(true);
final DefaultEditor editor = (DefaultEditor) spinner.getEditor();
final Font editorFont = editor.getTextField().getFont();
/*
* Validate that the font of the text field is changed to the
* font of JSpinner if the font of text field was not set by the
* user.
*/
if (!(editorFont instanceof UIResource)) {
throw new RuntimeException("Font must be UIResource");
}
if (!editorFont.equals(spinner.getFont())) {
throw new RuntimeException("Wrong FONT");
}
}
示例3: changeFont
import java.awt.Font; //导入方法依赖的package包/类
/** Derive a new coloring by changing the font and font-mode and leaving
* the rest of the coloring unchanged.
*/
public static Coloring changeFont(Coloring c, Font newFont, int newFontMode) {
if ((newFont == null && c.font == null)
|| (newFont != null && newFont.equals(c.font)
&& c.fontMode == newFontMode)
) {
return c;
}
return new Coloring(newFont, c.foreColor, c.backColor);
}
示例4: setFont
import java.awt.Font; //导入方法依赖的package包/类
/**
* Set font for standard mode.
*/
public void setFont(Font font) {
Font fontToSet = checkFontToSet(font);
if (!fontToSet.equals(this.font)) {
Font oldFont = this.font;
this.font = fontToSet;
defaultFontType = checkDefaultFontType();
pcs.firePropertyChange(PROP_FONT, oldFont, fontToSet);
}
}
示例5: setFontForWrappedMode
import java.awt.Font; //导入方法依赖的package包/类
private void setFontForWrappedMode(Font font) {
Font fontToSet = checkFontToSet(font);
if (!fontToSet.equals(this.fontWrapped)) {
int oldFontSize = this.fontWrapped != null
? this.fontWrapped.getSize() : 0;
this.fontWrapped = fontToSet;
pcs.firePropertyChange(PROP_FONT_SIZE_WRAP, oldFontSize,
fontToSet.getSize());
}
}
示例6: coloringEquals
import java.awt.Font; //导入方法依赖的package包/类
private boolean coloringEquals(Coloring coloring, Font f, Color fc, Color bc){
if (coloring == null) return false;
Font coloringFont = coloring.getFont();
if (coloringFont == null) coloringFont = getDefaultFont();
Color coloringForeColor = coloring.getForeColor();
if (coloringForeColor == null) coloringForeColor = getDefaultColor();
Color coloringBackColor = coloring.getBackColor();
if (coloringBackColor == null) coloringBackColor = getDefaultBackgroundColor();
return f.equals(coloringFont) && fc.equals(coloringForeColor) && bc.equals(coloringBackColor);
}
示例7: getStyleId
import java.awt.Font; //导入方法依赖的package包/类
public final String getStyleId (Font f, Color fc, Color bc) {
if (!fc.equals(getDefaultColor()) || !bc.equals(getDefaultBackgroundColor()) || !f.equals(getDefaultFont())) {
StyleDescriptor sd = new StyleDescriptor (f, fc, bc);
String id = this.descs.get(sd);
if (id == null) {
java.util.Set keySet = syntaxColoring.keySet();
Iterator iter = keySet.iterator();
while(iter.hasNext()){
Object key = iter.next();
if (coloringEquals((Coloring)syntaxColoring.get(key), f, fc, bc)){
id = (String) key;
break;
}
}
if (id == null){
id = STYLE_PREFIX + this.sequence++;
}
sd.name = id;
this.descs.put (sd, id);
}
return id;
}
else {
return null; //No style needed
}
}
示例8: isFontChanged
import java.awt.Font; //导入方法依赖的package包/类
private boolean isFontChanged(String language, AttributeSet currentAS, AttributeSet savedAS) {
String name = (String) getValue(language, currentAS, StyleConstants.FontFamily);
assert (name != null);
Integer size = (Integer) getValue(language, currentAS, StyleConstants.FontSize);
assert (size != null);
Boolean bold = (Boolean) getValue(language, currentAS, StyleConstants.Bold);
if (bold == null) {
bold = Boolean.FALSE;
}
Boolean italic = (Boolean) getValue(language, currentAS, StyleConstants.Italic);
if (italic == null) {
italic = Boolean.FALSE;
}
int style = bold.booleanValue() ? Font.BOLD : Font.PLAIN;
if (italic.booleanValue()) {
style += Font.ITALIC;
}
Font currentFont = new Font(name, style, size.intValue());
name = (String) getValue(language, savedAS, StyleConstants.FontFamily);
assert (name != null);
size = (Integer) getValue(language, savedAS, StyleConstants.FontSize);
assert (size != null);
bold = (Boolean) getValue(language, savedAS, StyleConstants.Bold);
if (bold == null) {
bold = Boolean.FALSE;
}
italic = (Boolean) getValue(language, savedAS, StyleConstants.Italic);
if (italic == null) {
italic = Boolean.FALSE;
}
style = bold.booleanValue() ? Font.BOLD : Font.PLAIN;
if (italic.booleanValue()) {
style += Font.ITALIC;
}
Font savedFont = new Font(name, style, size.intValue());
return !currentFont.equals(savedFont);
}
示例9: setTitleFont
import java.awt.Font; //导入方法依赖的package包/类
/**
* @param titleFont
* the titleFont to set
*/
public void setTitleFont(Font titleFont) {
if (!titleFont.equals(this.titleFont)) {
this.titleFont = titleFont;
fireTitleChanged();
}
}
示例10: paintSyntaxLine
import java.awt.Font; //导入方法依赖的package包/类
/**
* Paints the specified line onto the graphics context. Note that this method munges the offset
* and count values of the segment.
*
* @param line
* The line segment
* @param tokens
* The token list for the line
* @param styles
* The syntax style list
* @param expander
* The tab expander used to determine tab stops. May be null
* @param gfx
* The graphics context
* @param x
* The x co-ordinate
* @param y
* The y co-ordinate
* @return The x co-ordinate, plus the width of the painted string
*/
public static int paintSyntaxLine(Segment line, Token tokens, SyntaxStyle[] styles, TabExpander expander, Graphics gfx,
int x, int y) {
Font defaultFont = gfx.getFont();
Color defaultColor = gfx.getColor();
int offset = 0;
for (;;) {
byte id = tokens.id;
if (id == Token.END) {
break;
}
int length = tokens.length;
if (id == Token.NULL) {
if (!defaultColor.equals(gfx.getColor())) {
gfx.setColor(defaultColor);
}
if (!defaultFont.equals(gfx.getFont())) {
gfx.setFont(defaultFont);
}
} else {
styles[id].setGraphicsFlags(gfx, defaultFont);
}
line.count = length;
x = Utilities.drawTabbedText(line, x, y, gfx, expander, 0);
line.offset += length;
offset += length;
tokens = tokens.next;
}
return x;
}
示例11: getFontMetrics
import java.awt.Font; //导入方法依赖的package包/类
/**
* Returns the font metrics for the styled font.
*/
@SuppressWarnings("deprecation")
public FontMetrics getFontMetrics(Font font) {
if (font == null) {
throw new NullPointerException("font param must not" + " be null");
}
if (font.equals(lastFont) && fontMetrics != null) {
return fontMetrics;
}
lastFont = font;
lastStyledFont = new Font(font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize());
fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(lastStyledFont);
return fontMetrics;
}
示例12: getFontA
import java.awt.Font; //导入方法依赖的package包/类
@Override
public Font getFontA() {
Font font = functions.get(0).getFont();
for (int i = 1; i < functions.size(); i++) {
if (!font.equals(functions.get(i).getFont()))
return null;
}
return font;
}
示例13: setLineNumberFont
import java.awt.Font; //导入方法依赖的package包/类
/**
* Sets the font used for line numbers.
*
* @param font The font to use. This cannot be <code>null</code>.
* @see #getLineNumberFont()
*/
public void setLineNumberFont(Font font) {
if (font==null) {
throw new IllegalArgumentException("font cannot be null");
}
if (!font.equals(lineNumberFont)) {
lineNumberFont = font;
if (lineNumberList!=null) {
lineNumberList.setFont(font);
}
}
}
示例14: checkTitleFont
import java.awt.Font; //导入方法依赖的package包/类
/**
* Check behaviour of method TitledBorder.getTitleFont()
*/
private static void checkTitleFont() {
TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1));
Font defaultFont = UIManager.getLookAndFeelDefaults().getFont("TitledBorder.font");
Font titledBorderFont = titledBorder.getTitleFont();
// check default configuration
if (defaultFont == null) {
if (titledBorderFont == null) {
return;
}
else {
throw new RuntimeException("TitledBorder default font should be null");
}
}
if (!defaultFont.equals(titledBorderFont)) {
throw new RuntimeException("L&F default font " + defaultFont.toString()
+ " differs from TitledBorder font " + titledBorderFont.toString());
}
// title font is explicitly specified
Font font = new Font("Dialog", Font.PLAIN, 10);
titledBorder.setTitleFont(font);
if (!font.equals(titledBorder.getTitleFont())) {
throw new RuntimeException("TitledBorder font should be " + font.toString());
}
// title Font is unspecified
titledBorder.setTitleFont(null);
if (!defaultFont.equals(titledBorder.getTitleFont())) {
throw new RuntimeException("L&F default font " + defaultFont.toString()
+ " differs from TitledBorder font " + titledBorderFont.toString());
}
}
示例15: setFont
import java.awt.Font; //导入方法依赖的package包/类
public @Override void setFont(Font font) {
if (!font.equals(this.font)) {
flush();
this.font = font;
}
}