Package java.awt.font

Examples of java.awt.font.LineMetrics


        } else {
            String text = meter.getText();

            if (text != null
                && text.length() > 0) {
                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
                preferredHeight = (int)Math.ceil(lm.getHeight()) + 2;
            } else {
                preferredHeight = 0;
            }

            // If the meter has no content, its preferred height is hard-coded by the
View Full Code Here


        if (text != null
            && text.length() > 0) {
            Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
            preferredWidth = (int)Math.ceil(stringBounds.getWidth()) + 2;

            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
            preferredHeight = (int)Math.ceil(lm.getHeight()) + 2;
        }

        // If meter has no content, its preferred size is hard coded by the class
        preferredWidth = Math.max(preferredWidth, DEFAULT_WIDTH);
        preferredHeight = Math.max(preferredHeight, DEFAULT_HEIGHT);
View Full Code Here

        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            String text = meter.getText();

            if (text != null
                && text.length() > 0) {
                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
                float ascent = lm.getAscent();
                float textHeight = lm.getHeight();

                baseline = Math.round((height - textHeight) / 2 + ascent);
            }
        }
View Full Code Here

        }

        String text = meter.getText();
        if (text != null
            && text.length() > 0) {
            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
            float ascent = lm.getAscent();

            Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
            float textWidth = (float)stringBounds.getWidth();
            float textHeight = (float)stringBounds.getHeight();
View Full Code Here

     */
    public double getHeight(Graphics2D g2) {

        double result = 0.0;
        if (this.markers.size() > 0) {
            LineMetrics metrics = this.font.getLineMetrics(
                "123g", g2.getFontRenderContext()
            );
            result = this.topOuterGap + this.topInnerGap + metrics.getHeight()
                     + this.bottomInnerGap + this.bottomOuterGap;
        }
        return result;

    }
View Full Code Here

        Rectangle2D r = TextUtilities.getTextBounds(text, g2, fm);
        double x = bounds.getX();
        if (r.getWidth() < bounds.getWidth()) {
            x = x + (bounds.getWidth() - r.getWidth()) / 2;
        }
        LineMetrics metrics = font.getLineMetrics(
            text, g2.getFontRenderContext()
        );
        g2.drawString(
            text, (float) x, (float) (bounds.getMaxY()
                - this.bottomInnerGap - metrics.getDescent())
        );
    }
View Full Code Here

        if (isVerticalTickLabels()) {
            // all tick labels have the same width (equal to the height of the
            // font)...
            FontRenderContext frc = g2.getFontRenderContext();
            LineMetrics lm = getTickLabelFont().getLineMetrics("0", frc);
            result += lm.getHeight();
        }
        else {
            // look at lower and upper bounds...
            FontMetrics fm = g2.getFontMetrics(getTickLabelFont());
            Range range = getRange();
View Full Code Here

    gd.setPaint(paint);
    gd.drawString(text, x, y);
  }

  double getFontAscent(Font font) {
    LineMetrics lm = font.getLineMetrics(DUMMY_TEXT, gd.getFontRenderContext());
    return lm.getAscent();
  }
View Full Code Here

    LineMetrics lm = font.getLineMetrics(DUMMY_TEXT, gd.getFontRenderContext());
    return lm.getAscent();
  }

  double getFontHeight(Font font) {
    LineMetrics lm = font.getLineMetrics(DUMMY_TEXT, gd.getFontRenderContext());
    return lm.getAscent() + lm.getDescent();
  }
View Full Code Here

        if ((transform.getType() & TRANSFORM_MASK) == 0) {
            int width = 0;
            for (int i = start; i < end; i++) {
                width += peer.charWidth(chars[i]);
            }
            LineMetrics nlm = peer.getLineMetrics();
            bounds = transform.createTransformedShape(
                    new Rectangle2D.Float(0, -nlm.getAscent(), width, nlm
                            .getHeight())).getBounds2D();
        } else {
            int len = end - start;
            char[] subChars = new char[len];
            System.arraycopy(chars, start, subChars, 0, len);
View Full Code Here

TOP

Related Classes of java.awt.font.LineMetrics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.