Java 8 LineMetrics - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 LineMetrics class.

This code example shows how to use the following methods:getAscent, getDescent, getLeading
                + 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;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getAscent
    public LineMetricsAdapter(LineMetrics lineMetrics) {
        _lineMetrics = lineMetrics;
    } 
 
    public float getAscent() { 
        return _lineMetrics.getAscent();
    } 
 
    public float getDescent() { 
        return _lineMetrics.getDescent();
    } 
 
    public float getStrikethroughOffset() { 
        return _lineMetrics.getStrikethroughOffset();
    } 
 
    public float getStrikethroughThickness() { 
        return _lineMetrics.getStrikethroughThickness();
    } 
 
5
CodeRank
This code example shows how to use the following methods:getAscent, getDescent
    public float calculateBaselineOffset(Graphics2D g2, TextAnchor anchor) {
        float result = 0.0f;
        FontMetrics fm = g2.getFontMetrics(this.font);
        LineMetrics lm = fm.getLineMetrics("ABCxyz", g2);
        if (anchor.isTop()) {
            result = lm.getAscent();
        } 
        else if (anchor.isHalfAscent()) {
            result = lm.getAscent() / 2.0f;
        } 
        else if (anchor.isHalfHeight()) {
            result = lm.getAscent() / 2.0f - lm.getDescent() / 2.0f;
        } 
        else if (anchor.isBottom()) {
            result = -lm.getDescent() - lm.getLeading();
        } 
        return result;
    } 
 
    /** 
5
CodeRank
This code example shows how to use the following methods:getHeight
        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;
 
    } 
 
    /** 
     * A utility method that draws a string inside a rectangle. 
     * 
     * @param g2  the graphics device. 
     * @param bounds  the rectangle. 
     * @param font  the font. 
     * @param text  the text. 
     */ 
5
CodeRank
This code example shows how to use the following methods:getAscent, getHeight
This code example shows how to use the following methods:getDescent, getHeight, getLeading
This code example shows how to use the following methods:getDescent, getHeight, getLeading
This code example shows how to use the following methods:getUnderlineOffset
        return xHeight * 1000;
    } 
 
    public int getUnderlinePosition(String family, int style, int size) {
        setFont(family, style, size);
        return -Math.round(lineMetrics.getUnderlineOffset());
    } 
 
    public int getUnderlineThickness(String family, int style, int size) {
        setFont(family, style, size);
        return Math.round(lineMetrics.getUnderlineThickness());
    } 
 
    public int getStrikeoutPosition(String family, int style, int size) {
        setFont(family, style, size);
        return -Math.round(lineMetrics.getStrikethroughOffset());
    } 
 
    public int getStrikeoutThickness(String family, int style, int size) {
        setFont(family, style, size);
3
CodeRank
This code example shows how to use the following methods:getAscent
 
    final FontRenderContext frc = g2.getFontRenderContext();
    final Font f = g2.getFont();
//    final FontMetrics fm = g2.getFontMetrics(f); 
    final LineMetrics metrics = f.getLineMetrics(label, frc);
    final float ascent = metrics.getAscent();
    final float halfAscent = ascent / 2.0f;
    g2.drawString(label, (float) x, (float) (y + halfAscent));
  } 
 
  public boolean isDraw() 
  { 
    return draw;
  } 
 
  public void setDraw(final boolean draw)
  { 
    this.draw = draw;
  } 
 
4
CodeRank
This code example shows how to use the following methods:getAscent, getDescent
            g2.drawImage(closed, PAD, 0, h, h, this); 
             */ // Uncomment once you have your own images 
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            LineMetrics lm = font.getLineMetrics(text_, frc);
            float height = lm.getAscent() + lm.getDescent();
            float x = OFFSET;
            float y = (h + height) / 2 - lm.getDescent();
            g2.drawString(text_, x, y);
        } 
 
        public void mouseClicked(MouseEvent e) {
            toggleSelection(); 
        } 
 
        public void mouseEntered(MouseEvent e) {
        } 
 
        public void mouseExited(MouseEvent e) {
        } 
4
CodeRank
See Code Examples for Java 8 LineMetrics Methods: