congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
LineMetrics.getLeading
Code IndexAdd Tabnine to your IDE (free)

How to use
getLeading
method
in
java.awt.font.LineMetrics

Best Java code snippets using java.awt.font.LineMetrics.getLeading (Showing top 20 results out of 315)

origin: geotools/geotools

/**
 * Vertical centering is not trivial, because visually we want centering on characters such as
 * a,m,e, and not centering on d,g whose center is affected by the full ascent or the full
 * descent. This method tries to computes the y anchor taking into account those.
 */
public double getLinePlacementYAnchor() {
  TextStyle2D textStyle = getLabel().getTextStyle();
  LineMetrics lm =
      textStyle
          .getFont()
          .getLineMetrics(textStyle.getLabel(), graphics.getFontRenderContext());
  // gracefully handle font size = 0
  if (lm.getHeight() > 0) {
    return (Math.abs(lm.getStrikethroughOffset()) + lm.getDescent() + lm.getLeading())
        / lm.getHeight();
  } else {
    return 0;
  }
}
origin: io.leopard.thirdparty/jcaptcha-core

public String toString() {
  StringBuffer buf = new StringBuffer();
  buf.append("{text=");
  for (int i = 0; i < length(); i++) {
    buf.append(aStrings[i].getIterator().current());
  }
  final String RS = "\n\t";
  buf.append(RS);
  for (int i = 0; i < length(); i++) {
    buf.append(bounds[i].toString());
    final String FS = " ";
    final LineMetrics m = metrics[i];
    // height = ascent + descent + leading
    buf.append(" ascent=").append(m.getAscent()).append(FS);
    buf.append("descent=").append(m.getDescent()).append(FS);
    buf.append("leading=").append(m.getLeading()).append(FS);
    buf.append(RS);
  }
  buf.append("}");
  return buf.toString();
}
origin: org.apache.pivot/pivot-wtk

@Override
public int getPreferredHeight(int width) {
  int preferredHeight = thickness;
  Separator separator = (Separator)getComponent();
  String heading = separator.getHeading();
  if (heading != null
    && heading.length() > 0) {
    FontRenderContext fontRenderContext = Platform.getFontRenderContext();
    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;
}
origin: com.barchart.pivot/pivot-wtk

@Override
public int getPreferredHeight(int width) {
  int preferredHeight = thickness;
  Separator separator = (Separator)getComponent();
  String heading = separator.getHeading();
  if (heading != null
    && heading.length() > 0) {
    FontRenderContext fontRenderContext = Platform.getFontRenderContext();
    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;
}
origin: jfree/jcommon

/**
 * Calculates the vertical offset between the baseline and the specified 
 * text anchor.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor.
 * 
 * @return the offset.
 */
public float calculateBaselineOffset(final Graphics2D g2, 
                   final TextAnchor anchor) {
  float result = 0.0f;
  final FontMetrics fm = g2.getFontMetrics(this.font);
  final LineMetrics lm = fm.getLineMetrics("ABCxyz", g2);
  if (anchor == TextAnchor.TOP_LEFT || anchor == TextAnchor.TOP_CENTER
                   || anchor == TextAnchor.TOP_RIGHT) {
    result = lm.getAscent();
  }
  else if (anchor == TextAnchor.BOTTOM_LEFT 
      || anchor == TextAnchor.BOTTOM_CENTER
      || anchor == TextAnchor.BOTTOM_RIGHT) {
    result = -lm.getDescent() - lm.getLeading();
  }
  return result;                                             
}
 
origin: org.jfree/com.springsource.org.jfree

/**
 * Calculates the vertical offset between the baseline and the specified 
 * text anchor.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor.
 * 
 * @return the offset.
 */
public float calculateBaselineOffset(final Graphics2D g2, 
                   final TextAnchor anchor) {
  float result = 0.0f;
  final FontMetrics fm = g2.getFontMetrics(this.font);
  final LineMetrics lm = fm.getLineMetrics("ABCxyz", g2);
  if (anchor == TextAnchor.TOP_LEFT || anchor == TextAnchor.TOP_CENTER
                   || anchor == TextAnchor.TOP_RIGHT) {
    result = lm.getAscent();
  }
  else if (anchor == TextAnchor.BOTTOM_LEFT 
      || anchor == TextAnchor.BOTTOM_CENTER
      || anchor == TextAnchor.BOTTOM_RIGHT) {
    result = -lm.getDescent() - lm.getLeading();
  }
  return result;                                             
}
 
origin: com.barchart.pivot/pivot-wtk

@Override
public Dimensions getPreferredSize() {
  int preferredWidth = 0;
  int preferredHeight = thickness;
  Separator separator = (Separator)getComponent();
  String heading = separator.getHeading();
  if (heading != null
    && heading.length() > 0) {
    FontRenderContext fontRenderContext = Platform.getFontRenderContext();
    Rectangle2D headingBounds = font.getStringBounds(heading, fontRenderContext);
    LineMetrics lm = font.getLineMetrics(heading, fontRenderContext);
    preferredWidth = (int)Math.ceil(headingBounds.getWidth());
    preferredHeight = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
      + lm.getLeading()), preferredHeight);
  }
  preferredHeight += (padding.top + padding.bottom);
  preferredWidth += (padding.left + padding.right);
  return new Dimensions(preferredWidth, preferredHeight);
}
origin: xyz.cofe/gui.swing

float ah = ch - insets.top - insets.bottom;
float th = lm.getAscent() + lm.getDescent() + lm.getLeading();
origin: org.apache.pivot/pivot-wtk

@Override
public Dimensions getPreferredSize() {
  int preferredWidth = 0;
  int preferredHeight = thickness;
  Separator separator = (Separator)getComponent();
  String heading = separator.getHeading();
  if (heading != null
    && heading.length() > 0) {
    FontRenderContext fontRenderContext = Platform.getFontRenderContext();
    Rectangle2D headingBounds = font.getStringBounds(heading, fontRenderContext);
    LineMetrics lm = font.getLineMetrics(heading, fontRenderContext);
    preferredWidth = (int)Math.ceil(headingBounds.getWidth());
    preferredHeight = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
      + lm.getLeading()), preferredHeight);
  }
  preferredHeight += (padding.top + padding.bottom);
  preferredWidth += (padding.left + padding.right);
  return new Dimensions(preferredWidth, preferredHeight);
}
origin: freehep/freehep-vectorgraphics

private void writeFootline(AffineTransform pageTrafo) throws IOException {
  if (footerText != null) {
    LineMetrics metrics = footerFont.getLineMetrics("mM",
        getFontRenderContext());
    double y = getHeight() + footerFont.getSize2D() / 2;
    writeLine(pageTrafo, footerFont, footerText, y
        + metrics.getLeading(), TEXT_TOP, y, footerUnderline);
  }
}
origin: freehep/freehep-vectorgraphics

private void writeHeadline(AffineTransform pageTrafo) throws IOException {
  if (headerText != null) {
    LineMetrics metrics = headerFont.getLineMetrics("mM",
        getFontRenderContext());
    writeLine(pageTrafo, headerFont, headerText, -metrics.getLeading()
        - headerFont.getSize2D() / 2, TEXT_BOTTOM, -headerFont
        .getSize2D() / 2, headerUnderline);
  }
}
origin: org.geotools/gt-render

/**
 * Vertical centering is not trivial, because visually we want centering on
 * characters such as a,m,e, and not centering on d,g whose center is
 * affected by the full ascent or the full descent. This method tries to
 * computes the y anchor taking into account those.
 */
public double getLinePlacementYAnchor() {
  TextStyle2D textStyle = getLabel().getTextStyle();
  LineMetrics lm = textStyle.getFont().getLineMetrics(textStyle.getLabel(),
      graphics.getFontRenderContext());
  
  // gracefully handle font size = 0
  if(lm.getHeight() > 0)
    return (Math.abs(lm.getStrikethroughOffset()) + lm.getDescent() + lm.getLeading())
        / lm.getHeight();
  else 
    return 0;
}
origin: google/sagetv

public JavaFont(String fontName, int fontStyle, int fontSize)
{
 super(fontName, fontStyle, fontSize);
 myFont = UIManager.getCachedJavaFont(fontName, fontStyle, fontSize);
 frc = new java.awt.font.FontRenderContext(null, true, false);
 java.awt.font.LineMetrics metrics = myFont.getLineMetrics("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopwrstuvwxyz0123456789", frc);
 height = metrics.getHeight();
 ascent = metrics.getAscent();
 leading = metrics.getLeading();
 descent = metrics.getDescent();
}
public MetaFont deriveFontSize(int newSize, UIManager uiLoader)
origin: jfree/jfreechart

/**
 * Calculates the vertical offset between the baseline and the specified 
 * text anchor.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor.
 * 
 * @return the offset.
 */
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.isVerticalCenter()) {
    result = lm.getAscent() / 2.0f - lm.getDescent() / 2.0f;
  }
  else if (anchor.isBottom()) {
    result = -lm.getDescent() - lm.getLeading();
  }
  return result;                                             
}

origin: org.jfree/jcommon

/**
 * Calculates the vertical offset between the baseline and the specified 
 * text anchor.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor.
 * 
 * @return the offset.
 */
public float calculateBaselineOffset(Graphics2D g2, TextAnchor anchor) {
  float result = 0.0f;
  final FontMetrics fm = g2.getFontMetrics(this.font);
  final LineMetrics lm = fm.getLineMetrics("ABCxyz", g2);
  if (anchor.isTop()) {
    result = lm.getAscent();
  }
  else if (anchor.isHalfAscent()) {
    result = lm.getAscent() / 2.0f;
  }
  else if (anchor.isVerticalCenter()) {
    result = lm.getAscent() / 2.0f - lm.getDescent() / 2.0f;
  }
  else if (anchor.isBottom()) {
    result = -lm.getDescent() - lm.getLeading();
  }
  return result;                                             
}
 
origin: org.apache.xmlgraphics/batik-gvt

/**
 * Constructs a GVTLineMetrics object based on the specified line metrics.
 *
 * @param lineMetrics The lineMetrics object that this metrics object will
 * be based upon.
 */
public GVTLineMetrics(LineMetrics lineMetrics) {
  this.ascent = lineMetrics.getAscent();
  this.baselineIndex = lineMetrics.getBaselineIndex();
  this.baselineOffsets = lineMetrics.getBaselineOffsets();
  this.descent = lineMetrics.getDescent();
  this.height = lineMetrics.getHeight();
  this.leading = lineMetrics.getLeading();
  this.numChars = lineMetrics.getNumChars();
  this.strikethroughOffset = lineMetrics.getStrikethroughOffset();
  this.strikethroughThickness = lineMetrics.getStrikethroughThickness();
  this.underlineOffset = lineMetrics.getUnderlineOffset();
  this.underlineThickness = lineMetrics.getUnderlineThickness();
  this.overlineOffset = -this.ascent;
  this.overlineThickness = this.underlineThickness;
}
origin: fr.avianey.apache-xmlgraphics/batik

/**
 * Constructs a GVTLineMetrics object based on the specified line metrics.
 *
 * @param lineMetrics The lineMetrics object that this metrics object will
 * be based upon.
 */
public GVTLineMetrics(LineMetrics lineMetrics) {
  this.ascent = lineMetrics.getAscent();
  this.baselineIndex = lineMetrics.getBaselineIndex();
  this.baselineOffsets = lineMetrics.getBaselineOffsets();
  this.descent = lineMetrics.getDescent();
  this.height = lineMetrics.getHeight();
  this.leading = lineMetrics.getLeading();
  this.numChars = lineMetrics.getNumChars();
  this.strikethroughOffset = lineMetrics.getStrikethroughOffset();
  this.strikethroughThickness = lineMetrics.getStrikethroughThickness();
  this.underlineOffset = lineMetrics.getUnderlineOffset();
  this.underlineThickness = lineMetrics.getUnderlineThickness();
  this.overlineOffset = -this.ascent;
  this.overlineThickness = this.underlineThickness;
}
origin: apache/batik

/**
 * Constructs a GVTLineMetrics object based on the specified line metrics.
 *
 * @param lineMetrics The lineMetrics object that this metrics object will
 * be based upon.
 */
public GVTLineMetrics(LineMetrics lineMetrics) {
  this.ascent = lineMetrics.getAscent();
  this.baselineIndex = lineMetrics.getBaselineIndex();
  this.baselineOffsets = lineMetrics.getBaselineOffsets();
  this.descent = lineMetrics.getDescent();
  this.height = lineMetrics.getHeight();
  this.leading = lineMetrics.getLeading();
  this.numChars = lineMetrics.getNumChars();
  this.strikethroughOffset = lineMetrics.getStrikethroughOffset();
  this.strikethroughThickness = lineMetrics.getStrikethroughThickness();
  this.underlineOffset = lineMetrics.getUnderlineOffset();
  this.underlineThickness = lineMetrics.getUnderlineThickness();
  this.overlineOffset = -this.ascent;
  this.overlineThickness = this.underlineThickness;
}
origin: org.apache.xmlgraphics/batik-gvt

/**
 * Constructs a GVTLineMetrics object based on the specified line metrics
 * with a scale factor applied.
 *
 * @param lineMetrics The lineMetrics object that this metrics object will
 * be based upon.
 * @param scaleFactor The scale factor to apply to all metrics.
 */
public GVTLineMetrics(LineMetrics lineMetrics, float scaleFactor) {
  this.ascent = lineMetrics.getAscent() * scaleFactor;
  this.baselineIndex = lineMetrics.getBaselineIndex();
  this.baselineOffsets = lineMetrics.getBaselineOffsets();
  for (int i=0; i<baselineOffsets.length; i++) {
    this.baselineOffsets[i] *= scaleFactor;
  }
  this.descent = lineMetrics.getDescent() * scaleFactor;
  this.height = lineMetrics.getHeight() * scaleFactor;
  this.leading = lineMetrics.getLeading();
  this.numChars = lineMetrics.getNumChars();
  this.strikethroughOffset = 
    lineMetrics.getStrikethroughOffset() * scaleFactor;
  this.strikethroughThickness = 
    lineMetrics.getStrikethroughThickness() * scaleFactor;
  this.underlineOffset = lineMetrics.getUnderlineOffset() * scaleFactor;
  this.underlineThickness = 
    lineMetrics.getUnderlineThickness() * scaleFactor;
  this.overlineOffset = -this.ascent;
  this.overlineThickness = this.underlineThickness;
}
origin: fr.avianey.apache-xmlgraphics/batik

/**
 * Constructs a GVTLineMetrics object based on the specified line metrics
 * with a scale factor applied.
 *
 * @param lineMetrics The lineMetrics object that this metrics object will
 * be based upon.
 * @param scaleFactor The scale factor to apply to all metrics.
 */
public GVTLineMetrics(LineMetrics lineMetrics, float scaleFactor) {
  this.ascent = lineMetrics.getAscent() * scaleFactor;
  this.baselineIndex = lineMetrics.getBaselineIndex();
  this.baselineOffsets = lineMetrics.getBaselineOffsets();
  for (int i=0; i<baselineOffsets.length; i++) {
    this.baselineOffsets[i] *= scaleFactor;
  }
  this.descent = lineMetrics.getDescent() * scaleFactor;
  this.height = lineMetrics.getHeight() * scaleFactor;
  this.leading = lineMetrics.getLeading();
  this.numChars = lineMetrics.getNumChars();
  this.strikethroughOffset = 
    lineMetrics.getStrikethroughOffset() * scaleFactor;
  this.strikethroughThickness = 
    lineMetrics.getStrikethroughThickness() * scaleFactor;
  this.underlineOffset = lineMetrics.getUnderlineOffset() * scaleFactor;
  this.underlineThickness = 
    lineMetrics.getUnderlineThickness() * scaleFactor;
  this.overlineOffset = -this.ascent;
  this.overlineThickness = this.underlineThickness;
}
java.awt.fontLineMetricsgetLeading

Popular methods of LineMetrics

  • getAscent
  • getDescent
  • getHeight
  • getStrikethroughOffset
  • getUnderlineOffset
  • getStrikethroughThickness
  • getUnderlineThickness
  • getBaselineIndex
  • getBaselineOffsets
  • getNumChars

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (Timer)
  • compareTo (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • JLabel (javax.swing)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now