Examples of LineMetrics


Examples of java.awt.font.LineMetrics

            } else {
                graphics.setPaint(disabledColor);
            }

            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
            float ascent = lm.getAscent();
            float lineHeight = lm.getHeight();

            float y = 0;
            switch (verticalAlignment) {
                case TOP: {
                    y = padding.top;
View Full Code Here

Examples of java.awt.font.LineMetrics

        System.out.println(font.getFontName() + "  " + size + ": " + fm.getHeight() + " = " + fm.getLeading() + " + " + fm.getAscent() + " + "
                + fm.getDescent());
        System.out.println("    " + fm.getMaxAscent() + " + " + fm.getMaxDescent());

        LineMetrics lm = fm.getLineMetrics("test", g);
       
        System.out.println("    " + lm.getLeading() + "    " + lm.getAscent() + " + " + lm.getDescent());

        return fm.getHeight() + 14;
    }
View Full Code Here

Examples of java.awt.font.LineMetrics

        return info;
      }
    }

    cpBuffer[0] = (char) (c & 0xFFFF);
    final LineMetrics lm = font.getLineMetrics(cpBuffer, 0, 1, frc);
    final float[] bls = lm.getBaselineOffsets();
    final int idx = lm.getBaselineIndex();

    if (info == null)
    {
      info = new BaselineInfo();
    }

    // The ascent is local - but we need the global baseline, relative to the
    // MaxAscent.
    final long maxAscent = getMaxAscent();
    final long ascent = FontStrictGeomUtility.toInternalValue(lm.getAscent());
    final long delta = maxAscent - ascent;
    info.setBaseline(BaselineInfo.MATHEMATICAL, delta + maxAscent - getXHeight());
    info.setBaseline(BaselineInfo.IDEOGRAPHIC, getMaxHeight());
    info.setBaseline(BaselineInfo.MIDDLE, maxAscent / 2);
View Full Code Here

Examples of java.awt.font.LineMetrics

        Separator separator = (Separator)getComponent();
        String heading = separator.getHeading();

        if (heading != null
            && heading.length() > 0) {
            LineMetrics lm = font.getLineMetrics(heading, fontRenderContext);
            preferredHeight = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
                + lm.getLeading()), preferredHeight);
        }

        preferredHeight += (padding.top + padding.bottom);

        return preferredHeight;
View Full Code Here

Examples of java.awt.font.LineMetrics

        String heading = separator.getHeading();

        if (heading != null
            && heading.length() > 0) {
            LineMetrics lm = font.getLineMetrics(heading, fontRenderContext);

            if (fontRenderContext.isAntiAliased()) {
                graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                    Platform.getTextAntialiasingHint());
            }

            if (fontRenderContext.usesFractionalMetrics()) {
                graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                    RenderingHints.VALUE_FRACTIONALMETRICS_ON);
            }

            graphics.setFont(font);
            graphics.setPaint(headingColor);
            graphics.drawString(heading, padding.left, lm.getAscent() + padding.top);

            Rectangle2D headingBounds = font.getStringBounds(heading, fontRenderContext);

            Area titleClip = new Area(graphics.getClip());
            titleClip.subtract(new Area(new Rectangle2D.Double(padding.left, padding.top,
                headingBounds.getWidth() + padding.right, headingBounds.getHeight())));
            graphics.clip(titleClip);

            separatorY += (lm.getAscent() + lm.getDescent()) / 2 + 1;
        }

        graphics.setStroke(new BasicStroke(thickness));
        graphics.setColor(color);
        graphics.drawLine(0, separatorY, width, separatorY);
View Full Code Here

Examples of java.awt.font.LineMetrics

                    height += row.height;
                }

                // Recalculate terminator bounds
                LineMetrics lm = font.getLineMetrics("", 0, 0, FONT_RENDER_CONTEXT);
                int terminatorHeight = (int)Math.ceil(lm.getHeight());

                int terminatorY;
                if (getCharacterCount() == 1) {
                    // The terminator is the only character in this paragraph
                    terminatorY = 0;
View Full Code Here

Examples of java.awt.font.LineMetrics

                if (FONT_RENDER_CONTEXT.usesFractionalMetrics()) {
                    graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                        RenderingHints.VALUE_FRACTIONALMETRICS_ON);
                }

                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
                float ascent = lm.getAscent();

                graphics.setFont(font);

                int selectionStart = textArea.getSelectionStart();
                int selectionLength = textArea.getSelectionLength();
View Full Code Here

Examples of java.awt.font.LineMetrics

            return next;
        }

        @Override
        public int getInsertionPoint(int x, int y) {
            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
            float ascent = lm.getAscent();

            int n = glyphVector.getNumGlyphs();
            int i = 0;

            while (i < n) {
View Full Code Here

Examples of java.awt.font.LineMetrics

    @Override
    public int getPreferredHeight(int width) {
        Label label = (Label)getComponent();
        String text = label.getText();

        LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
        float lineHeight = lm.getHeight();

        float preferredHeight = lineHeight;

        if (text != null
            && wrapText
View Full Code Here

Examples of java.awt.font.LineMetrics

            preferredWidth = 0;
        }

        preferredWidth += (padding.left + padding.right);

        LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
        int preferredHeight = (int)Math.ceil(lm.getHeight()) + (padding.top + padding.bottom);

        return new Dimensions(preferredWidth, preferredHeight);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.