Java Code Examples for java.awt.Font#equals()
The following examples show how to use
java.awt.Font#equals() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openjdk-jdk8u-backup File: XComponentPeer.java License: GNU General Public License v2.0 | 6 votes |
@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(); }
Example 2
Source Project: hottub File: XComponentPeer.java License: GNU General Public License v2.0 | 6 votes |
@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(); }
Example 3
Source Project: nextreports-designer File: PropertyPanel.java License: Apache License 2.0 | 6 votes |
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; }
Example 4
Source Project: TencentKona-8 File: XComponentPeer.java License: GNU General Public License v2.0 | 6 votes |
@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(); }
Example 5
Source Project: jdk8u60 File: XComponentPeer.java License: GNU General Public License v2.0 | 6 votes |
@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(); }
Example 6
Source Project: openjdk-jdk8u File: XComponentPeer.java License: GNU General Public License v2.0 | 6 votes |
@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(); }
Example 7
Source Project: openjdk-jdk9 File: bug6421058.java License: GNU General Public License v2.0 | 6 votes |
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"); } }
Example 8
Source Project: jdk8u-jdk File: XComponentPeer.java License: GNU General Public License v2.0 | 6 votes |
@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(); }
Example 9
Source Project: gumtree-spoon-ast-diff File: right_QuickNotepad_1.14.java License: Apache License 2.0 | 5 votes |
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); } }
Example 10
Source Project: rapidminer-studio File: SyntaxUtilities.java License: GNU Affero General Public License v3.0 | 5 votes |
/** * 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; }
Example 11
Source Project: gumtree-spoon-ast-diff File: right_QuickNotepad_1.14.java License: Apache License 2.0 | 5 votes |
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); } }
Example 12
Source Project: coming File: left_QuickNotepad_1.13.java License: MIT License | 5 votes |
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); } }
Example 13
Source Project: gumtree-spoon-ast-diff File: left_QuickNotepad_1.13.java License: Apache License 2.0 | 5 votes |
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); } }
Example 14
Source Project: netbeans File: Coloring.java License: Apache License 2.0 | 5 votes |
/** 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); }
Example 15
Source Project: openjdk-8 File: Test7022041.java License: GNU General Public License v2.0 | 5 votes |
/** * 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()); } }
Example 16
Source Project: openjdk-jdk9 File: WrongEditorTextFieldFont.java License: GNU General Public License v2.0 | 4 votes |
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)); } }
Example 17
Source Project: jdk8u60 File: PSPathGraphics.java License: GNU General Public License v2.0 | 4 votes |
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); } }
Example 18
Source Project: jdk8u-jdk File: PSPathGraphics.java License: GNU General Public License v2.0 | 4 votes |
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); } }
Example 19
Source Project: netbeans File: DrawGraphics.java License: Apache License 2.0 | 4 votes |
public @Override void setFont(Font font) { if (!font.equals(this.font)) { flush(); this.font = font; } }
Example 20
Source Project: openjdk-8-source File: PSPathGraphics.java License: GNU General Public License v2.0 | 4 votes |
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); } }