/** * @return the leading height before/after a text line */ public float getLeading() { // fix invalid leadings (leading == 0) double l = layout.getLeading(); if (l == 0) { // see https://stackoverflow.com/questions/925147 // we use a 115% value instead of the 120% proposed one, as this seems to be closer to LO/OO l = (layout.getAscent()+layout.getDescent())*0.15; } return (float)l; }
int height = ((Float) (layout.getDescent() + layout.getAscent() + layout.getLeading())).intValue(); currentX, currentY); currentY += textLayout.getDescent() + textLayout.getLeading();
+ layout.getLeading();
(float) tX, textY); textY += tl.getDescent() + tl.getLeading() + (interline - 1.0f) * tl.getAscent();
float getLineOffset() { float offset = Float.NEGATIVE_INFINITY; for (LineComponent component : components) { float co = component.getLayout().getAscent() + component.getLayout().getDescent() + component.getLayout().getLeading(); if (co > offset) { offset = co; } } return offset; }
layout.draw(g, x + inset, yPos); yPos += layout.getDescent() + layout.getLeading() - 2;
textLayout.draw(g2d, textX + glowSize / 2, textY + glowSize / 2); textY += textLayout.getDescent() + textLayout.getLeading(); // Move down to top of next line.
while (lineMeasurer.getPosition() < paragraphEnd) { TextLayout layout = lineMeasurer.nextLayout(maxTextWidth); layoutHeight += layout.getAscent() + layout.getDescent() + layout.getLeading(); } else if (Position.BELOW == this.position) { posX += -layout.getAdvance() * 0.5f; posY += (layout.getAscent() + layout.getDescent() + layout.getLeading()) * 0.5f; } else if (Position.BELOW_LEFT == this.position) { posX += -layout.getAdvance(); posY += (layout.getAscent() + layout.getDescent() + layout.getLeading()) * 0.5f; } else if (Position.BELOW_RIGHT == this.position) { posY += (layout.getAscent() + layout.getDescent() + layout.getLeading()) * 0.5f; } else if (Position.ABOVE == this.position) { posX += -layout.getAdvance() * 0.5f; posY += layout.getAscent() + layout.getDescent() + layout.getLeading() - layoutHeight; } else if (Position.ABOVE_LEFT == this.position) { posX += -layout.getAdvance(); posY += layout.getAscent() + layout.getDescent() + layout.getLeading() - layoutHeight; } else if (Position.ABOVE_RIGHT == this.position) { posY += layout.getAscent() + layout.getDescent() + layout.getLeading() - layoutHeight; } else if (Position.LEFT == this.position) { posX += -layout.getAdvance(); drawPosY += layout.getAscent() + layout.getDescent() + layout.getLeading(); if (filter != Filter.NONE) { this.paintFront.setColor(colorF);
public void update( TextLayout textLayout ) { ascent = Math.max( ascent, textLayout.getAscent() ); descent = Math.max( descent, textLayout.getDescent() ); leading = Math.max( leading, textLayout.getLeading() ); }
/** * @return full height of this text run which is sum of ascent, descent and leading */ public float getHeight(){ double h = Math.ceil(_layout.getAscent()) + Math.ceil(_layout.getDescent()) + _layout.getLeading(); return (float)h; }
public float getBaseline(FontRenderContext fontRenderContext) { TextLayout tl = getTextLayout(fontRenderContext); return tl.getLeading() + tl.getAscent(); }
private void paintTitle(Graphics2D g2) { if (title != null && title.length() > 0) { float x = DEFAULT_START_TITLE_X; float y = (float) this.getHeight() / 2.0f + titleTextLayoutCache.getLeading() + titleTextLayoutCache.getDescent(); g2.setColor(colorTitle); titleTextLayoutCache.draw(g2, x, y); } }
private void paintSubTitle(Graphics2D g2) { if (subTitle != null && subTitle.length() > 0) { g2.setColor(colorSubTitle); float x = DEFAULT_START_SUBTITLE_X; float y = (float) this.getHeight() / 2.0f + startSubTitleY + subTitleTextLayoutCache.getLeading() + subTitleTextLayoutCache.getDescent(); subTitleTextLayoutCache.draw(g2, x, y); } }
public float getHeight(FontRenderContext fontRenderContext) { TextLayout tl = getTextLayout(fontRenderContext); return tl.getLeading() + tl.getAscent() + tl.getDescent(); }
public void addLink(LinkSpan linkSpan, int linkStart, int linkEnd) { Rectangle linkBounds = textLayout.getLogicalHighlightShape(linkStart, linkEnd).getBounds(); linkBounds.translate(0, (int)(textLayout.getAscent() + textLayout.getLeading())); AttributedString linkString = new AttributedString(attributedString.getIterator()); linkString.addAttribute(TextAttribute.FOREGROUND, Color.MAGENTA.darker(), linkStart, linkEnd); linkString.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL, linkStart, linkEnd); LinkBox linkBox = new LinkBox(linkSpan.getLink()); linkBox.setBounds(linkBounds); add(linkBox); }
public void addLink(LinkSpan linkSpan, int linkStart, int linkEnd) { Rectangle linkBounds = textLayout.getLogicalHighlightShape(linkStart, linkEnd).getBounds(); linkBounds.translate(0, (int)(textLayout.getAscent() + textLayout.getLeading())); AttributedString linkString = new AttributedString(attributedString.getIterator()); linkString.addAttribute(TextAttribute.FOREGROUND, Color.MAGENTA.darker(), linkStart, linkEnd); linkString.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL, linkStart, linkEnd); LinkBox linkBox = new LinkBox(linkSpan.getLink()); linkBox.setBounds(linkBounds); add(linkBox); }
public void addLink(LinkSpan linkSpan, int linkStart, int linkEnd) { Rectangle linkBounds = textLayout.getLogicalHighlightShape(linkStart, linkEnd).getBounds(); linkBounds.translate(0, (int)(textLayout.getAscent() + textLayout.getLeading())); AttributedString linkString = new AttributedString(attributedString.getIterator()); linkString.addAttribute(TextAttribute.FOREGROUND, Color.MAGENTA.darker(), linkStart, linkEnd); linkString.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL, linkStart, linkEnd); LinkBox linkBox = new LinkBox(linkSpan.getLink()); linkBox.setBounds(linkBounds); add(linkBox); }
public void layout(FontRenderContext fontRenderContext) { this.textLayout = new TextLayout(attributedString.getIterator(), fontRenderContext); int textHeight = (int) (textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading()); int totalHeight = textHeight + getInsetsTop() + getInsetsBottom(); setHeight(totalHeight); }
public void layout(FontRenderContext fontRenderContext) { this.textLayout = new TextLayout(attributedString.getIterator(), fontRenderContext); int textHeight = (int) (textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading()); int totalHeight = textHeight + getInsetsTop() + getInsetsBottom(); setHeight(totalHeight); }
public void layout(FontRenderContext fontRenderContext) { this.textLayout = new TextLayout(attributedString.getIterator(), fontRenderContext); int textHeight = (int) (textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading()); int totalHeight = textHeight + getInsetsTop() + getInsetsBottom(); setHeight(totalHeight); }