Graphics2D g = ...; Point2D loc = ...; Font font = Font.getFont("Helvetica-bold-italic"); FontRenderContext frc = g.getFontRenderContext(); TextLayout layout = new TextLayout("This is a string", font, frc); layout.draw(g, (float)loc.getX(), (float)loc.getY()); Rectangle2D bounds = layout.getBounds(); bounds.setRect(bounds.getX()+loc.getX(), bounds.getY()+loc.getY(), bounds.getWidth(), bounds.getHeight()); g.draw(bounds);
public void draw(Graphics2D graphics){ if(str == null) { return; } double yBaseline = y + layout.getAscent(); Integer textMode = (Integer)graphics.getRenderingHint(Drawable.TEXT_RENDERING_MODE); if(textMode != null && textMode == Drawable.TEXT_AS_SHAPES){ layout.draw(graphics, (float)x, (float)yBaseline); } else { graphics.drawString(str.getIterator(), (float)x, (float)yBaseline ); } }
currentX = x + (centered ? ((boxWidth - ((Double) textLayout.getBounds().getWidth()).intValue()) / 2) : 0); textLayout.draw(g, currentX, currentY);
tX += (int) (graphicInfo.getWidth() / 2 - bb.getWidth() / 2); tl.draw(g, (float) tX, textY);
private void drawLines(WrappedLines lines, Graphics2D g) { Colors colors = look.colors(); float y = originY(lines); for(TextLayout line : lines.list) { float x = xFor(line); y += line.getAscent() - line.getDescent(); Color shadowColor = colors.shadow(); g.setColor(shadowColor); line.draw(g, x-1, y-1); g.setColor(colors.text()); line.draw(g, x, y); y += line.getDescent(); } }
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f)); int glowSize = key.glowSize; textLayout.draw(g2d, textX + glowSize / 2 + 1, textY + glowSize / 2 - 1); textLayout.draw(g2d, textX + glowSize / 2 + 1, textY + glowSize / 2 + 1); textLayout.draw(g2d, textX + glowSize / 2 - 1, textY + glowSize / 2 - 1); textLayout.draw(g2d, textX + glowSize / 2 - 1, textY + glowSize / 2 + 1); textLayout.draw(g2d, textX + glowSize / 2, textY + glowSize / 2);
public void draw(Graphics2D g) { if (fillColor == null) return; setupTransform(g); if (text == null || text.length() == 0) return; TextLayoutIterator iterator = new TextLayoutIterator(); while (iterator.hasNext()) { TextLayout layout = iterator.next(); layout.draw(g, (float) (baseLineX + iterator.getX()), (float) (baseLineY + iterator.getY())); } restoreTransform(g); }
TextLayout layout = measure.getLayout(0, breakIndex); g.setColor(getBoxTextColor()); layout.draw(g, x, y + (h - boxTextHeight) / 2 + boxTextHeight - 1);
layout.draw(g, x + inset, yPos);
/** * */ public void draw(TextLayout layout) { layout.draw( grx, drawPosX + x + leftPadding, drawPosY + y + topPadding + verticalOffset + leadingOffset ); }
TextLayout layout = measure.getLayout(0, breakIndex); g.setColor(getBoxTextColor()); layout.draw(g, x, y + boxTextOffset + boxTextHeight - 1);
@Override public void draw(Graphics2DInterface graphics, int x, int y) { // can be GraphicsStub if (graphics instanceof Graphics2DD) { Graphics2DD g2 = (Graphics2DD) graphics; layout.draw(g2.getImpl(), x, y); } }
/** {@inheritDoc} */ public void paint(final float x, final float y, final Graphics2D g) { g.setColor(this.color); final AffineTransform oldTrans = g.getTransform(); g.translate(x + this.xoffset, y + this.yoffset); if (this.trans != null) { g.transform(this.trans); } this.layout.draw(g, 0, 0); g.setTransform(oldTrans); } }
private void doDrawString(Graphics2D g, int fragmentIndex, int x, int y) { String text = myFragments.get(fragmentIndex); if (StringUtil.isEmpty(text)) return; TextLayout layout = getTextLayout(fragmentIndex, g.getFont(), g.getFontRenderContext()); if (layout != null) { layout.draw(g, x, y); } else { g.drawString(text, x, y); } }
Graphics2D g = ...; Point2D loc = ...; Font font = Font.getFont("Helvetica-bold-italic"); FontRenderContext frc = g.getFontRenderContext(); TextLayout layout = new TextLayout("This is a string", font, frc); layout.draw(g, (float)loc.getX(), (float)loc.getY()); Rectangle2D bounds = layout.getBounds(); bounds.setRect(bounds.getX()+loc.getX(), bounds.getY()+loc.getY(), bounds.getWidth(), bounds.getHeight()); g.draw(bounds);
@Override public void draw(Graphics2D graphics, Point location) { TextLayout tl = new TextLayout(text, graphics.getFont(), graphics.getFontRenderContext()); float x = location.x; if (alignment.equals(TextAlignment.RIGHT)) x -= tl.getAdvance(); tl.draw(graphics, x, location.y); }
public void draw(Graphics2D graphics){ if(str == null) { return; } double yBaseline = y + layout.getAscent(); Integer textMode = (Integer)graphics.getRenderingHint(Drawable.TEXT_RENDERING_MODE); if(textMode != null && textMode == Drawable.TEXT_AS_SHAPES){ layout.draw(graphics, (float)x, (float)yBaseline); } else { graphics.drawString(str.getIterator(), (float)x, (float)yBaseline ); } }
void drawText(Graphics2D g2) { if (BLACK.equals(getForeground())) { g2.setColor(WHITE); } else { g2.setColor(BLACK); } g2.setFont(getFont()); TextLayout layout = new TextLayout(getStatusMessage(), getFont(), g2.getFontRenderContext()); layout.draw(g2, 10, (getHeight() / 2) + getBaselineOffset(layout)); }
layout.draw(awtCanvas.getGraphicObject(), posX, posY); drawPosY += layout.getAscent() + layout.getDescent() + layout.getLeading(); if (filter != Filter.NONE) {