java.awt.Font#equals ( )源码实例Demo

下面列出了java.awt.Font#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk8u-backup   文件: XComponentPeer.java
@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 项目: hottub   文件: XComponentPeer.java
@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();
}
 
源代码3 项目: nextreports-designer   文件: PropertyPanel.java
private Font getUniqueFont() {
    Font font = null;
    int n = reportGridCells.size();
    for (int i = 0; i < n; i++) {
        BandElement element = reportGridCells.get(i).getValue();
        if (i == 0) {
            font = element.getFont();
            continue;
        }
        if (!font.equals(element.getFont())) {
            return null;
        }
    }
    
    return font;
}
 
源代码4 项目: TencentKona-8   文件: XComponentPeer.java
@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();
}
 
源代码5 项目: jdk8u60   文件: XComponentPeer.java
@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();
}
 
源代码6 项目: openjdk-jdk8u   文件: XComponentPeer.java
@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();
}
 
源代码7 项目: openjdk-jdk9   文件: bug6421058.java
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");
    }
}
 
源代码8 项目: jdk8u-jdk   文件: XComponentPeer.java
@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();
}
 
private void propertiesChanged() {
	String propertyFilename = jEdit
			.getProperty(QuickNotepadPlugin.OPTION_PREFIX + "filepath");
	if (!MiscUtilities.objectsEqual(defaultFilename, propertyFilename)) {
		saveFile();
		toolPanel.propertiesChanged();
		defaultFilename = propertyFilename;
		filename = defaultFilename;
		readFile();
	}
	Font newFont = QuickNotepadOptionPane.makeFont();
	if (!newFont.equals(textArea.getFont())) {
		textArea.setFont(newFont);
	}
}
 
源代码10 项目: rapidminer-studio   文件: SyntaxUtilities.java
/**
 * 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();

	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;

		tokens = tokens.next;
	}

	return x;
}
 
private void propertiesChanged() {
	String propertyFilename = jEdit
			.getProperty(QuickNotepadPlugin.OPTION_PREFIX + "filepath");
	if (!MiscUtilities.objectsEqual(defaultFilename, propertyFilename)) {
		saveFile();
		toolPanel.propertiesChanged();
		defaultFilename = propertyFilename;
		filename = defaultFilename;
		readFile();
	}
	Font newFont = QuickNotepadOptionPane.makeFont();
	if (!newFont.equals(textArea.getFont())) {
		textArea.setFont(newFont);
	}
}
 
源代码12 项目: coming   文件: left_QuickNotepad_1.13.java
private void propertiesChanged() {
	String propertyFilename = jEdit
			.getProperty(QuickNotepadPlugin.OPTION_PREFIX + "filepath");
	if (!MiscUtilities.objectsEqual(defaultFilename, propertyFilename)) {
		saveFile();
		toolPanel.propertiesChanged();
		defaultFilename = propertyFilename;
		filename = defaultFilename;
		readFile();
	}
	Font newFont = QuickNotepadOptionPane.makeFont();
	if (!newFont.equals(textArea.getFont())) {
		textArea.setFont(newFont);
	}
}
 
private void propertiesChanged() {
	String propertyFilename = jEdit
			.getProperty(QuickNotepadPlugin.OPTION_PREFIX + "filepath");
	if (!MiscUtilities.objectsEqual(defaultFilename, propertyFilename)) {
		saveFile();
		toolPanel.propertiesChanged();
		defaultFilename = propertyFilename;
		filename = defaultFilename;
		readFile();
	}
	Font newFont = QuickNotepadOptionPane.makeFont();
	if (!newFont.equals(textArea.getFont())) {
		textArea.setFont(newFont);
	}
}
 
源代码14 项目: netbeans   文件: Coloring.java
/** 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);
}
 
源代码15 项目: openjdk-8   文件: Test7022041.java
/**
  * 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());
    }
}
 
源代码16 项目: openjdk-jdk9   文件: WrongEditorTextFieldFont.java
private static void testDefaultFont(final JFrame frame) {
    final JSpinner spinner = new JSpinner();
    final JSpinner spinner_u = new JSpinner();
    frame.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 50));
    frame.getContentPane().add(spinner);
    frame.getContentPane().add(spinner_u);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    final DefaultEditor ed = (DefaultEditor) spinner.getEditor();
    final DefaultEditor ed_u = (DefaultEditor) spinner_u.getEditor();
    ed_u.getTextField().setFont(USERS_FONT);

    for (int i = 5; i < 40; i += 5) {
        /*
         * 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.
         */
        final Font tff = ed.getTextField().getFont();
        if (!(tff instanceof UIResource)) {
            throw new RuntimeException("Font must be UIResource");
        }
        if (spinner.getFont().getSize() != tff.getSize()) {
            throw new RuntimeException("Rrong size");
        }
        spinner.setFont(new Font("dialog", Font.BOLD, i));
        /*
         * Validate that the font of the text field is NOT changed to the
         * font of JSpinner if the font of text field was set by the user.
         */
        final Font tff_u = ed_u.getTextField().getFont();
        if (tff_u instanceof UIResource || !tff_u.equals(USERS_FONT)) {
            throw new RuntimeException("Font must NOT be UIResource");
        }
        if (spinner_u.getFont().getSize() == tff_u.getSize()) {
            throw new RuntimeException("Wrong size");
        }
        spinner_u.setFont(new Font("dialog", Font.BOLD, i));
    }
}
 
源代码17 项目: jdk8u60   文件: PSPathGraphics.java
protected void drawString(String str, float x, float y,
                          Font font, FontRenderContext frc, float w) {
    if (str.length() == 0) {
        return;
    }

    /* If the Font has layout attributes we need to delegate to TextLayout.
     * TextLayout renders text as GlyphVectors. We try to print those
     * using printer fonts - ie using Postscript text operators so
     * we may be reinvoked. In that case the "!printingGlyphVector" test
     * prevents us recursing and instead sends us into the body of the
     * method where we can safely ignore layout attributes as those
     * are already handled by TextLayout.
     */
    if (font.hasLayoutAttributes() && !printingGlyphVector) {
        TextLayout layout = new TextLayout(str, font, frc);
        layout.draw(this, x, y);
        return;
    }

    Font oldFont = getFont();
    if (!oldFont.equals(font)) {
        setFont(font);
    } else {
        oldFont = null;
    }

    boolean drawnWithPS = false;

    float translateX = 0f, translateY = 0f;
    boolean fontisTransformed = getFont().isTransformed();

    if (fontisTransformed) {
        AffineTransform fontTx = getFont().getTransform();
        int transformType = fontTx.getType();
        /* TYPE_TRANSLATION is a flag bit but we can do "==" here
         * because we want to detect when its just that bit set and
         *
         */
        if (transformType == AffineTransform.TYPE_TRANSLATION) {
            translateX = (float)(fontTx.getTranslateX());
            translateY = (float)(fontTx.getTranslateY());
            if (Math.abs(translateX) < 0.00001) translateX = 0f;
            if (Math.abs(translateY) < 0.00001) translateY = 0f;
            fontisTransformed = false;
        }
    }

    boolean directToPS = !fontisTransformed;

    if (!PSPrinterJob.shapeTextProp && directToPS) {

        PSPrinterJob psPrinterJob = (PSPrinterJob) getPrinterJob();
        if (psPrinterJob.setFont(getFont())) {

            /* Set the text color.
             * We should not be in this shape printing path
             * if the application is drawing with non-solid
             * colors. We should be in the raster path. Because
             * we are here in the shape path, the cast of the
             * paint to a Color should be fine.
             */
            try {
                psPrinterJob.setColor((Color)getPaint());
            } catch (ClassCastException e) {
                if (oldFont != null) {
                    setFont(oldFont);
                }
                throw new IllegalArgumentException(
                                            "Expected a Color instance");
            }

            psPrinterJob.setTransform(getTransform());
            psPrinterJob.setClip(getClip());

            drawnWithPS = psPrinterJob.textOut(this, str,
                                               x+translateX, y+translateY,
                                               font, frc, w);
        }
    }

    /* The text could not be converted directly to PS text
     * calls so decompose the text into a shape.
     */
    if (drawnWithPS == false) {
        if (oldFont != null) {
            setFont(oldFont);
            oldFont = null;
        }
        super.drawString(str, x, y, font, frc, w);
    }

    if (oldFont != null) {
        setFont(oldFont);
    }
}
 
源代码18 项目: jdk8u-jdk   文件: PSPathGraphics.java
protected void drawString(String str, float x, float y,
                          Font font, FontRenderContext frc, float w) {
    if (str.length() == 0) {
        return;
    }

    /* If the Font has layout attributes we need to delegate to TextLayout.
     * TextLayout renders text as GlyphVectors. We try to print those
     * using printer fonts - ie using Postscript text operators so
     * we may be reinvoked. In that case the "!printingGlyphVector" test
     * prevents us recursing and instead sends us into the body of the
     * method where we can safely ignore layout attributes as those
     * are already handled by TextLayout.
     */
    if (font.hasLayoutAttributes() && !printingGlyphVector) {
        TextLayout layout = new TextLayout(str, font, frc);
        layout.draw(this, x, y);
        return;
    }

    Font oldFont = getFont();
    if (!oldFont.equals(font)) {
        setFont(font);
    } else {
        oldFont = null;
    }

    boolean drawnWithPS = false;

    float translateX = 0f, translateY = 0f;
    boolean fontisTransformed = getFont().isTransformed();

    if (fontisTransformed) {
        AffineTransform fontTx = getFont().getTransform();
        int transformType = fontTx.getType();
        /* TYPE_TRANSLATION is a flag bit but we can do "==" here
         * because we want to detect when its just that bit set and
         *
         */
        if (transformType == AffineTransform.TYPE_TRANSLATION) {
            translateX = (float)(fontTx.getTranslateX());
            translateY = (float)(fontTx.getTranslateY());
            if (Math.abs(translateX) < 0.00001) translateX = 0f;
            if (Math.abs(translateY) < 0.00001) translateY = 0f;
            fontisTransformed = false;
        }
    }

    boolean directToPS = !fontisTransformed;

    if (!PSPrinterJob.shapeTextProp && directToPS) {

        PSPrinterJob psPrinterJob = (PSPrinterJob) getPrinterJob();
        if (psPrinterJob.setFont(getFont())) {

            /* Set the text color.
             * We should not be in this shape printing path
             * if the application is drawing with non-solid
             * colors. We should be in the raster path. Because
             * we are here in the shape path, the cast of the
             * paint to a Color should be fine.
             */
            try {
                psPrinterJob.setColor((Color)getPaint());
            } catch (ClassCastException e) {
                if (oldFont != null) {
                    setFont(oldFont);
                }
                throw new IllegalArgumentException(
                                            "Expected a Color instance");
            }

            psPrinterJob.setTransform(getTransform());
            psPrinterJob.setClip(getClip());

            drawnWithPS = psPrinterJob.textOut(this, str,
                                               x+translateX, y+translateY,
                                               font, frc, w);
        }
    }

    /* The text could not be converted directly to PS text
     * calls so decompose the text into a shape.
     */
    if (drawnWithPS == false) {
        if (oldFont != null) {
            setFont(oldFont);
            oldFont = null;
        }
        super.drawString(str, x, y, font, frc, w);
    }

    if (oldFont != null) {
        setFont(oldFont);
    }
}
 
源代码19 项目: netbeans   文件: DrawGraphics.java
public @Override void setFont(Font font) {
    if (!font.equals(this.font)) {
        flush();
        this.font = font;
    }
}
 
源代码20 项目: openjdk-8-source   文件: PSPathGraphics.java
protected void drawString(String str, float x, float y,
                          Font font, FontRenderContext frc, float w) {
    if (str.length() == 0) {
        return;
    }

    /* If the Font has layout attributes we need to delegate to TextLayout.
     * TextLayout renders text as GlyphVectors. We try to print those
     * using printer fonts - ie using Postscript text operators so
     * we may be reinvoked. In that case the "!printingGlyphVector" test
     * prevents us recursing and instead sends us into the body of the
     * method where we can safely ignore layout attributes as those
     * are already handled by TextLayout.
     */
    if (font.hasLayoutAttributes() && !printingGlyphVector) {
        TextLayout layout = new TextLayout(str, font, frc);
        layout.draw(this, x, y);
        return;
    }

    Font oldFont = getFont();
    if (!oldFont.equals(font)) {
        setFont(font);
    } else {
        oldFont = null;
    }

    boolean drawnWithPS = false;

    float translateX = 0f, translateY = 0f;
    boolean fontisTransformed = getFont().isTransformed();

    if (fontisTransformed) {
        AffineTransform fontTx = getFont().getTransform();
        int transformType = fontTx.getType();
        /* TYPE_TRANSLATION is a flag bit but we can do "==" here
         * because we want to detect when its just that bit set and
         *
         */
        if (transformType == AffineTransform.TYPE_TRANSLATION) {
            translateX = (float)(fontTx.getTranslateX());
            translateY = (float)(fontTx.getTranslateY());
            if (Math.abs(translateX) < 0.00001) translateX = 0f;
            if (Math.abs(translateY) < 0.00001) translateY = 0f;
            fontisTransformed = false;
        }
    }

    boolean directToPS = !fontisTransformed;

    if (!PSPrinterJob.shapeTextProp && directToPS) {

        PSPrinterJob psPrinterJob = (PSPrinterJob) getPrinterJob();
        if (psPrinterJob.setFont(getFont())) {

            /* Set the text color.
             * We should not be in this shape printing path
             * if the application is drawing with non-solid
             * colors. We should be in the raster path. Because
             * we are here in the shape path, the cast of the
             * paint to a Color should be fine.
             */
            try {
                psPrinterJob.setColor((Color)getPaint());
            } catch (ClassCastException e) {
                if (oldFont != null) {
                    setFont(oldFont);
                }
                throw new IllegalArgumentException(
                                            "Expected a Color instance");
            }

            psPrinterJob.setTransform(getTransform());
            psPrinterJob.setClip(getClip());

            drawnWithPS = psPrinterJob.textOut(this, str,
                                               x+translateX, y+translateY,
                                               font, frc, w);
        }
    }

    /* The text could not be converted directly to PS text
     * calls so decompose the text into a shape.
     */
    if (drawnWithPS == false) {
        if (oldFont != null) {
            setFont(oldFont);
            oldFont = null;
        }
        super.drawString(str, x, y, font, frc, w);
    }

    if (oldFont != null) {
        setFont(oldFont);
    }
}