RenderingHints.VALUE_TEXT_ANTIALIAS_ON); int y = fm.getLeading() + fm.getMaxAscent(); for( String s : lines ) { g2.drawString(s, 0, y);
void drawMessage(Graphics2D g2d) { if (promptMsg == null) { return; } g2d.setFont(fontMsg); g2d.setColor(new Color(1f, 1f, 1f, 1)); int sw = g2d.getFontMetrics().stringWidth(promptMsg); int sh = g2d.getFontMetrics().getMaxAscent(); Rectangle ubound = scrOCP.getRectangle(); int cx = ubound.x + (ubound.width - sw) / 2; int cy = ubound.y + (ubound.height - sh) / 2; g2d.drawString(promptMsg, cx, cy); //TODO multi monitor message // for (int i = 0; i < Screen.getNumberScreens(); i++) { // if (!Screen.getScreen(i).hasPrompt()) { // continue; // } // Rectangle bound = Screen.getBounds(i); // int cx = bound.x + (bound.width - sw) / 2 - ubound.x; // int cy = bound.y + (bound.height - sh) / 2 - ubound.y; // g2d.drawString(promptMsg, cx, cy); // } }
lineHeight = height; int ascent = fm.getMaxAscent(); if (ascent>maxAscent) { maxAscent = ascent; lineHeight = height; int ascent = fm.getMaxAscent(); if (ascent>maxAscent) { maxAscent = ascent;
g.setColor(getDisabledTextColor()); g.drawString(placeholder, getInsets().left, pG.getFontMetrics() .getMaxAscent() + getInsets().top);
prefSize.height += (fm.getMaxAscent() + fm.getMaxDescent());
txtY += fm.getMaxAscent();
int txtH = fm.getMaxAscent() + fm.getMaxDescent(); Insets ins = r.getInsets(); } else { txtY = fm.getMaxAscent();
private void calcStringSizes(Font f, Graphics g) { FontMetrics fm = g.getFontMetrics(f); stringWidth = fm.stringWidth(emptyString); stringHeight = fm.getHeight(); ascent = fm.getMaxAscent(); }
private void calcStringSizes (Font f, Graphics g) { FontMetrics fm = g.getFontMetrics (f); stringWidth = fm.stringWidth(emptyString); stringHeight = fm.getHeight(); ascent = fm.getMaxAscent(); }
private void calcStringSizes (Font f, Graphics g) { FontMetrics fm = g.getFontMetrics (f); stringWidth = fm.stringWidth(emptyString); stringHeight = fm.getHeight(); ascent = fm.getMaxAscent(); }
private int centralizeTextY(String text, int y, int h) { FontMetrics fm = screen.getFontMetrics(); int ascent = fm.getMaxAscent(); int descent= fm.getMaxDescent(); int dy = y+h/2 - descent/2 + ascent/2; return dy; }
private int centralizeTextY(String text, int y, int h) { FontMetrics fm = screen.getFontMetrics(); int ascent = fm.getMaxAscent(); int descent = fm.getMaxDescent(); int dy = y + h / 2 - descent / 2 + ascent / 2; return dy; }
public void paintValue (Graphics gfx, Rectangle box) { String s = getPaintableString(); FontMetrics fm = gfx.getFontMetrics (); gfx.drawString (s, 4, (box.height - fm.getHeight ()) / 2 + 1 + fm.getMaxAscent ()); }
private void drawHeaderText(Graphics2D g2d) { if (hasHeaderText()) { final FontMetrics fontMetrics = g2d.getFontMetrics(); g2d.setPaint(foregroundColor); int x0 = GAP; int y0 = GAP + fontMetrics.getMaxAscent(); g2d.drawString(headerText, x0, y0); } }
/** * En fonction de <code>_g</code>, renvoie la hauteur de la Font <code>FONTBASE</code>. */ private static int getHauteurFONTBASE(final Graphics _g){ _g.setFont(FONTBASE); final FontMetrics metric = _g.getFontMetrics(); return metric.getMaxAscent() + metric.getMaxDescent() + metric.getLeading(); }
@Override protected void paintComponent(final Graphics pG) { super.paintComponent(pG); if (placeholder == null || placeholder.length() == 0 || getText().length() > 0) { return; } final Graphics2D g = (Graphics2D) pG; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g.drawString(placeholder, getInsets().left, pG.getFontMetrics().getMaxAscent() + getInsets().top); }
@Override protected void paintComponent(final Graphics pG) { super.paintComponent(pG); if (placeholder == null || placeholder.length() == 0 || getText().length() > 0 || !isEnabled()) { return; } final Graphics2D g = (Graphics2D) pG; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g.drawString(placeholder, getInsets().left, pG.getFontMetrics().getMaxAscent() + getInsets().top); }
/** * Calculates the size of the component based on its name. */ public Dimension getPreferredSize() { FontMetrics fm = getFontMetrics(DisplayNodeUtils.getFont()); int width = fm.stringWidth(getName()) + 11; int height = fm.getMaxAscent() + 6; return new Dimension(width, height); }
@Override public Dimension getPreferredSize() { FontMetrics fm = getFontMetrics(getFont()); Rectangle2D renderingBounds = fm.getStringBounds(rendering, getGraphics()); int prefWidth = 2 + (int) renderingBounds.getWidth(); if(parentArrowVisible) { prefWidth += PARENT_ARROW_BOX_WIDTH; } int prefTextHeight = fm.getMaxAscent() + fm.getMaxDescent() + fm.getLeading(); return new Dimension(prefWidth, prefTextHeight); }
private void setupFontMetrics() { _fm_small = _owner.getFontMetrics( _small_font ); _fm_large = _owner.getFontMetrics( _large_font ); _small_max_descent = _fm_small.getMaxDescent(); _small_max_ascent = _fm_small.getMaxAscent() + 1; }