/** * Creates a new style. * * @param fg The foreground color to use. * @param bg The background color to use. * @param font The font for this syntax scheme. * @param underline Whether or not to underline tokens with this style. */ public Style(Color fg, Color bg, Font font, boolean underline) { foreground = fg; background = bg; this.font = font; this.underline = underline; this.fontMetrics = font==null ? null : new JPanel().getFontMetrics(font); // Default, no rendering hints! }
/** * Returns the font metrics. * * @param font the font. * * @return The font metrics. */ @Override public FontMetrics getFontMetrics(Font font) { return SWTUtils.DUMMY_PANEL.getFontMetrics(font); }
public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { return panel.getFontMetrics(f); }
/** * Creates a new syntax scheme. * * @param fg The foreground color to use. * @param bg The background color to use. * @param font The font for this syntax scheme. * @param underline Whether or not to underline tokens with this style. */ public Style(Color fg, Color bg, Font font, boolean underline) { foreground = fg; background = bg; this.font = font; this.underline = underline; this.fontMetrics = font==null ? null : new JPanel().getFontMetrics(font); // Default, no rendering hints! }
/** * Creates a new style. * * @param fg The foreground color to use. * @param bg The background color to use. * @param font The font for this syntax scheme. * @param underline Whether or not to underline tokens with this style. */ public Style(Color fg, Color bg, Font font, boolean underline) { foreground = fg; background = bg; this.font = font; this.underline = underline; this.fontMetrics = font==null ? null : new JPanel().getFontMetrics(font); // Default, no rendering hints! }
/** * Creates a new syntax scheme. * * @param fg The foreground color to use. * @param bg The background color to use. * @param font The font for this syntax scheme. * @param underline Whether or not to underline tokens with this style. */ public Style(Color fg, Color bg, Font font, boolean underline) { foreground = fg; background = bg; this.font = font; this.underline = underline; this.fontMetrics = font==null ? null : new JPanel().getFontMetrics(font); // Default, no rendering hints! }
public OWLClsNodeRenderer(Controller controller, VisualisedObjectManager manager, NodeLabelRenderer labelRenderer, OWLModelManager owlModelManager) { this.owlModelManager = owlModelManager; if (manager == null) { throw new NullPointerException("VisualisedObjectManager must not be null"); } if (labelRenderer == null) { throw new NullPointerException("NodeLabelRenderer must not be null"); } this.controller = controller; visualisedObjectManager = manager; JPanel pan = new JPanel(); Font font = pan.getFont(); labelFont = font.deriveFont(10.0f); if (labelFont == null) { logger.warn("Font is NULL!"); } fontMetrics = pan.getFontMetrics(labelFont); if (fontMetrics == null) { logger.warn("Font metrics is NULL!"); } setupArrows(); }
private void setPreviewLabelFont(JPanel panel) { String fontName = (String) getFontNameComboBox().getSelectedItem(); int fontStyleFlags = FontStyle.fromName((String) getFontStyleComboBox().getSelectedItem()).getFontStyleFlags(); int fontSize = Integer.parseInt((String) getFontSizeComboBox().getSelectedItem()); Font font = new Font(fontName, fontStyleFlags, fontSize); getPreviewLabel().setFont(font); FontMetrics fontMetrics = panel.getFontMetrics(font); int width = fontMetrics.stringWidth(getPreviewLabel().getText()); int height = fontMetrics.getHeight(); getPreviewLabel().setPreferredSize(new Dimension(width, height)); }
int last_level_indent = MIDDLE_LEVEL_INDENT + IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND).getIconWidth() + rowContainer.getFontMetrics(rowContainer.getFont()).charWidth(' '); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
fontMetrics = pan.getFontMetrics(labelFont);
protected void enableIdOnTitleBar() { TableLayout layout = (TableLayout) titleBar.getLayout(); layout.setColumn(0, titleBar .getFontMetrics(titleBar.getFont()) .stringWidth( resourceManager.getUserString(toolWindow.getId()) ) + 12); SwingUtil.repaint(titleBar); }
borderInsets = EMPTY_INSETS; FontMetrics fm = panel.getFontMetrics(font); int fontHeight = fm.getHeight(); int descent = fm.getDescent();
borderInsets = EMPTY_INSETS; FontMetrics fm = panel.getFontMetrics(font); int fontHeight = fm.getHeight(); int descent = fm.getDescent();
java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { height--; else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { height++;
tmpGC.setFont(tmpFont); if (tmpGC.textExtent(Az).x > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { while (tmpGC.textExtent(Az).x > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { tmpFont.dispose(); height--; < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { while (tmpGC.textExtent(Az).x < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { tmpFont.dispose(); height++;
titleBarLayout.setColumn(0, titleBar.getFontMetrics( titleBar.getFont() ).stringWidth(resourceManager.getUserString(id)) + 12);