use of java.awt.font.LineMetrics in project intellij-community by JetBrains.
the class TextPainter method drawHeader.
private double drawHeader(Graphics2D g, Rectangle2D clip) {
LineMetrics lineMetrics = getHeaderFooterLineMetrics(g);
double w = clip.getWidth();
double x = clip.getX();
double y = clip.getY();
double h = 0;
boolean wasDrawn = false;
String headerText1 = myPrintSettings.FOOTER_HEADER_TEXT1;
if (headerText1 != null && headerText1.length() > 0 && PrintSettings.HEADER.equals(myPrintSettings.FOOTER_HEADER_PLACEMENT1)) {
h = drawHeaderOrFooterLine(g, x, y, w, headerText1, myPrintSettings.FOOTER_HEADER_ALIGNMENT1);
wasDrawn = true;
y += h;
}
String headerText2 = myPrintSettings.FOOTER_HEADER_TEXT2;
if (headerText2 != null && headerText2.length() > 0 && PrintSettings.HEADER.equals(myPrintSettings.FOOTER_HEADER_PLACEMENT2)) {
if (PrintSettings.LEFT.equals(myPrintSettings.FOOTER_HEADER_ALIGNMENT1) && PrintSettings.RIGHT.equals(myPrintSettings.FOOTER_HEADER_ALIGNMENT2) && wasDrawn) {
y -= h;
}
h = drawHeaderOrFooterLine(g, x, y, w, headerText2, myPrintSettings.FOOTER_HEADER_ALIGNMENT2);
y += h;
wasDrawn = true;
}
return wasDrawn ? y - clip.getY() + lineMetrics.getHeight() / 3 : 0;
}
use of java.awt.font.LineMetrics in project intellij-community by JetBrains.
the class TextPainter method getDescent.
private float getDescent(Graphics g) {
if (myDescent >= 0) {
return myDescent;
}
FontRenderContext fontRenderContext = ((Graphics2D) g).getFontRenderContext();
LineMetrics lineMetrics = myPlainFont.getLineMetrics(DEFAULT_MEASURE_HEIGHT_TEXT, fontRenderContext);
myDescent = lineMetrics.getDescent();
return myDescent;
}
use of java.awt.font.LineMetrics in project intellij-community by JetBrains.
the class TextPainter method getLineHeight.
private float getLineHeight(Graphics g) {
if (myLineHeight >= 0) {
return myLineHeight;
}
FontRenderContext fontRenderContext = ((Graphics2D) g).getFontRenderContext();
LineMetrics lineMetrics = myPlainFont.getLineMetrics(DEFAULT_MEASURE_HEIGHT_TEXT, fontRenderContext);
myLineHeight = lineMetrics.getHeight();
return myLineHeight;
}
use of java.awt.font.LineMetrics in project jdk8u_jdk by JetBrains.
the class StandardGlyphVector method getLogicalBounds.
// !!! not cached, assume TextLayout will cache if necessary
// !!! reexamine for per-glyph-transforms
// !!! revisit for text-on-a-path, vertical
public Rectangle2D getLogicalBounds() {
setFRCTX();
initPositions();
LineMetrics lm = font.getLineMetrics("", frc);
float minX, minY, maxX, maxY;
// horiz only for now...
minX = 0;
minY = -lm.getAscent();
maxX = 0;
maxY = lm.getDescent() + lm.getLeading();
if (glyphs.length > 0) {
maxX = positions[positions.length - 2];
}
return new Rectangle2D.Float(minX, minY, maxX - minX, maxY - minY);
}
use of java.awt.font.LineMetrics in project processdash by dtuma.
the class RadarPlot method drawLabel.
/**
* Draws the label for one radar axis.
*
* @param g2 The graphics device.
* @param chartArea The area for the radar chart.
* @param data The data for the plot.
* @param axis The axis (zero-based index).
* @param startAngle The starting angle.
*/
protected void drawLabel(Graphics2D g2, Rectangle2D chartArea, String label, int axis, double labelX, double labelY) {
// handle label drawing...
FontRenderContext frc = g2.getFontRenderContext();
Rectangle2D labelBounds = this.axisLabelFont.getStringBounds(label, frc);
LineMetrics lm = this.axisLabelFont.getLineMetrics(label, frc);
double ascent = lm.getAscent();
if (labelX == chartArea.getCenterX())
labelX -= labelBounds.getWidth() / 2;
else if (labelX < chartArea.getCenterX())
labelX -= labelBounds.getWidth();
if (labelY > chartArea.getCenterY())
labelY += ascent;
g2.setPaint(this.axisLabelPaint);
g2.setFont(this.axisLabelFont);
g2.drawString(label, (float) labelX, (float) labelY);
}
Aggregations