Java Code Examples for java.awt.Font#toString()
The following examples show how to use
java.awt.Font#toString() .
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: dragonwell8_jdk 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 2
Source Project: TencentKona-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 3
Source Project: jdk8u60 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 4
Source Project: openjdk-jdk8u 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 5
Source Project: openjdk-jdk8u-backup 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 6
Source Project: openjdk-jdk9 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 7
Source Project: jdk8u-jdk 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 8
Source Project: hottub 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 9
Source Project: openjdk-8-source 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 10
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 11
Source Project: jdk8u_jdk 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 12
Source Project: mars-sim File: LabelMapLayer.java License: GNU General Public License v3.0 | 5 votes |
/** * Gets an image of the label from cache or creates one if it doesn't exist. * @param label the label string. * @param font the font to use. * @param fontRenderContext the font render context to use. * @param labelColor the color of the label. * @param labelOutlineColor the color of the outline of the label. * @return buffered image of label. */ private BufferedImage getLabelImage( String label, Font font, FontRenderContext fontRenderContext, Color labelColor, Color labelOutlineColor ) { BufferedImage labelImage = null; String labelId = label + font.toString() + labelColor.toString() + labelOutlineColor.toString(); if (labelImageCache.containsKey(labelId)) { labelImage = labelImageCache.get(labelId); } else { labelImage = createLabelImage(label, font, fontRenderContext, labelColor, labelOutlineColor); labelImageCache.put(labelId, labelImage); } return labelImage; }
Example 13
Source Project: jdk8u-jdk 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 14
Source Project: jdk8u-dev-jdk 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 15
Source Project: dragonwell8_jdk File: MaxAdvanceIsMax.java License: GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); BufferedImage bi = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB); for (AntialiasHint antialiasHint : antialiasHints) { for (Font f : fonts) { for (StyleAndSize styleAndSize : stylesAndSizes) { f = f.deriveFont(styleAndSize.style, styleAndSize.size); Graphics2D g2d = bi.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antialiasHint.getHint()); FontMetrics fm = g2d.getFontMetrics(f); int[] width; int maxWidth = -1; int maxAdvance = fm.getMaxAdvance(); if (debug) { System.out.println("Testing " + f + " in " + antialiasHint); System.out.println("getMaxAdvance: " + maxAdvance); } if (maxAdvance != -1) { String failureMessage = null; width = fm.getWidths(); for (int j = 0; j < width.length; j++) { if (width[j] > maxWidth) { maxWidth = width[j]; } if (width[j] > maxAdvance) { failureMessage = "FAILED: getMaxAdvance is " + "not max for font: " + f.toString() + " getMaxAdvance(): " + maxAdvance + " getWidths()[" + j + "]: " + width[j]; throw new Exception(failureMessage); } } } if (debug) { System.out.println("Max char width: " + maxWidth); System.out.println("PASSED"); System.out.println("........................."); } } } } System.out.println("TEST PASS - OK"); }
Example 16
Source Project: openjdk-jdk8u File: MaxAdvanceIsMax.java License: GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); BufferedImage bi = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB); for (AntialiasHint antialiasHint : antialiasHints) { for (Font f : fonts) { for (StyleAndSize styleAndSize : stylesAndSizes) { f = f.deriveFont(styleAndSize.style, styleAndSize.size); Graphics2D g2d = bi.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antialiasHint.getHint()); FontMetrics fm = g2d.getFontMetrics(f); int[] width; int maxWidth = -1; int maxAdvance = fm.getMaxAdvance(); if (debug) { System.out.println("Testing " + f + " in " + antialiasHint); System.out.println("getMaxAdvance: " + maxAdvance); } if (maxAdvance != -1) { String failureMessage = null; width = fm.getWidths(); for (int j = 0; j < width.length; j++) { if (width[j] > maxWidth) { maxWidth = width[j]; } if (width[j] > maxAdvance) { failureMessage = "FAILED: getMaxAdvance is " + "not max for font: " + f.toString() + " getMaxAdvance(): " + maxAdvance + " getWidths()[" + j + "]: " + width[j]; throw new Exception(failureMessage); } } } if (debug) { System.out.println("Max char width: " + maxWidth); System.out.println("PASSED"); System.out.println("........................."); } } } } System.out.println("TEST PASS - OK"); }
Example 17
Source Project: jdk8u_jdk File: MaxAdvanceIsMax.java License: GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); BufferedImage bi = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB); for (AntialiasHint antialiasHint : antialiasHints) { for (Font f : fonts) { for (StyleAndSize styleAndSize : stylesAndSizes) { f = f.deriveFont(styleAndSize.style, styleAndSize.size); Graphics2D g2d = bi.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antialiasHint.getHint()); FontMetrics fm = g2d.getFontMetrics(f); int[] width; int maxWidth = -1; int maxAdvance = fm.getMaxAdvance(); if (debug) { System.out.println("Testing " + f + " in " + antialiasHint); System.out.println("getMaxAdvance: " + maxAdvance); } if (maxAdvance != -1) { String failureMessage = null; width = fm.getWidths(); for (int j = 0; j < width.length; j++) { if (width[j] > maxWidth) { maxWidth = width[j]; } if (width[j] > maxAdvance) { failureMessage = "FAILED: getMaxAdvance is " + "not max for font: " + f.toString() + " getMaxAdvance(): " + maxAdvance + " getWidths()[" + j + "]: " + width[j]; throw new Exception(failureMessage); } } } if (debug) { System.out.println("Max char width: " + maxWidth); System.out.println("PASSED"); System.out.println("........................."); } } } } System.out.println("TEST PASS - OK"); }