private Shape getOutline(final TextLayout textLayout) { return textLayout.getOutline(null); }
public String getCharDesc(char c) { final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); final Shape sh = t.getOutline(null); final double current[] = new double[6]; final PathIterator it = sh.getPathIterator(null); int sum = 0; final StringBuilder result = new StringBuilder(); while (it.isDone() == false) { final double oldX = current[0]; final double oldY = current[1]; final int nb = it.currentSegment(current); sum += nb; result.append(getType(nb, oldX, oldY, current[0], current[1])); it.next(); } return result.toString(); }
public String getCharDescVerbose(char c) { final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); final Shape sh = t.getOutline(null); final double current[] = new double[6]; final PathIterator it = sh.getPathIterator(null); int sum = 0; final StringBuilder result = new StringBuilder(); while (it.isDone() == false) { final double oldX = current[0]; final double oldY = current[1]; final int nb = it.currentSegment(current); sum += nb; result.append(getType(nb, oldX, oldY, current[0], current[1])); appendValue(result, current); it.next(); } return result.toString(); }
AffineTransform.getScaleInstance(1, fontHeightMultiple) ); bounds = layout.getOutline(trans).getBounds(); } else { bounds = layout.getBounds();
public void drawString(AttributedCharacterIterator attributedcharacteriterator, float x, float y) { TextLayout textlayout = new TextLayout(attributedcharacteriterator, getFontRenderContext()); Paint paint1 = getPaint(); setColor(getColor()); fill(textlayout.getOutline(AffineTransform.getTranslateInstance(x, y))); setPaint(paint1); }
final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext); g2d.translate(x, y); g2d.fill(t.getOutline(null)); g2d.translate(-x, -y);
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) { final UClip clip = clipContainer.getClip(); if (clip != null && clip.isInside(x, y) == false) { return; } final UText shape = (UText) ushape; final FontConfiguration fontConfiguration = shape.getFontConfiguration(); final UFont font = fontConfiguration.getFont(); final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext); drawPathIterator(svg, x, y, t.getOutline(null).getPathIterator(null)); }
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) { final UCenteredCharacter centeredCharacter = (UCenteredCharacter) ushape; final char c = centeredCharacter.getChar(); final UFont font = centeredCharacter.getFont(); final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c); final double xpos = x - unusedSpace.getCenterX() - 0.5; final double ypos = y - unusedSpace.getCenterY() - 0.5; final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); eps.setStrokeColor(mapper.getMappedColor(param.getColor())); DriverTextEps.drawPathIterator(eps, xpos, ypos, t.getOutline(null)); }
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) { final UCenteredCharacter centeredCharacter = (UCenteredCharacter) ushape; final char c = centeredCharacter.getChar(); final UFont font = centeredCharacter.getFont(); final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c); final double xpos = x - unusedSpace.getCenterX() - 0.5; final double ypos = y - unusedSpace.getCenterY() - 0.5; final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); tikz.setStrokeColor(mapper.getMappedColor(param.getColor())); tikz.drawPathIterator(xpos, ypos, t.getOutline(null).getPathIterator(null)); }
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) { final UCenteredCharacter characterCircled = (UCenteredCharacter) ushape; final char c = characterCircled.getChar(); final UFont font = characterCircled.getFont(); final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c); final double xpos = x - unusedSpace.getCenterX() - 0.5; final double ypos = y - unusedSpace.getCenterY() - 0.5; final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); svg.setStrokeColor(StringUtils.getAsHtml(mapper.getMappedColor(param.getColor()))); DriverTextAsPathSvg.drawPathIterator(svg, xpos, ypos, t.getOutline(null).getPathIterator(null)); } }
@Override public void drawText(String text, int x, int y, Paint paint) { if (text == null || text.trim().isEmpty()) { return; } if (paint.isTransparent()) { return; } AwtPaint awtPaint = AwtGraphicFactory.getPaint(paint); if (awtPaint.stroke == null) { this.graphics2D.setColor(awtPaint.color); this.graphics2D.setFont(awtPaint.font); this.graphics2D.drawString(text, x, y); } else { setColorAndStroke(awtPaint); TextLayout textLayout = new TextLayout(text, awtPaint.font, this.graphics2D.getFontRenderContext()); AffineTransform affineTransform = new AffineTransform(); affineTransform.translate(x, y); this.graphics2D.draw(textLayout.getOutline(affineTransform)); } }
void paintSeriesText( Graphics2D g, Map<String, Rectangle2D> seriesTextBounds, int markerSize, double x, double starty) { g.setColor(chart.getStyler().getChartFontColor()); g.setFont(chart.getStyler().getLegendFont()); double multiLineOffset = 0.0; for (Map.Entry<String, Rectangle2D> entry : seriesTextBounds.entrySet()) { double height = entry.getValue().getHeight(); double centerOffsetY = (Math.max(markerSize, height) - height) / 2.0; FontRenderContext frc = g.getFontRenderContext(); TextLayout tl = new TextLayout(entry.getKey(), chart.getStyler().getLegendFont(), frc); Shape shape = tl.getOutline(null); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); at.translate(x, starty + height + centerOffsetY + multiLineOffset); g.transform(at); g.fill(shape); g.setTransform(orig); // // debug box // Rectangle2D boundsTemp = new Rectangle2D.Double(x, starty + centerOffsetY, // entry.getValue().getWidth(), height); // g.setColor(Color.blue); // g.draw(boundsTemp); multiLineOffset += height + MULTI_LINE_SPACE; } }
Shape shape = textLayout.getOutline(null); g.setColor(styler.getChartFontColor()); g.setFont(styler.getToolTipFont());
private void paintSum(Graphics2D g, Rectangle2D pieBounds, double total) { // draw total value if visible if (pieStyler.isSumVisible()) { SumFormatter sumFormatter = pieStyler.getSumFormatter(); String annotation = sumFormatter.format(total); TextLayout textLayout = new TextLayout( annotation, pieStyler.getSumFont(), new FontRenderContext(null, true, false)); Shape shape = textLayout.getOutline(null); g.setColor(pieStyler.getChartFontColor()); // compute center Rectangle2D annotationRectangle = textLayout.getBounds(); double xCenter = pieBounds.getX() + pieBounds.getWidth() / 2 - annotationRectangle.getWidth() / 2; double yCenter = pieBounds.getY() + pieBounds.getHeight() / 2 + annotationRectangle.getHeight() / 2; // set text AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); at.translate(xCenter, yCenter); g.transform(at); g.fill(shape); g.setTransform(orig); } } }
new TextLayout( line, chart.getStyler().getLegendFont(), new FontRenderContext(null, true, false)); Shape shape = textLayout.getOutline(null); Rectangle2D bounds = shape.getBounds2D();
: AffineTransform.getRotateInstance( -1 * Math.toRadians(styler.getXAxisLabelRotation())); Shape shape = textLayout.getOutline(rot); Rectangle2D rectangle = shape.getBounds(); double largestLabelWidth = rectangle.getWidth();
public Path getPath() { Path p = new Path(); p.setFillColor(fillColor == null ? null : fillColor.clone()); TextLayoutIterator iterator = new TextLayoutIterator(); while (iterator.hasNext()) { TextLayout layout = iterator.next(); AffineTransform trans = new AffineTransform(); trans.translate(baseLineX + iterator.getX(), baseLineY + iterator.getY()); Shape shape = layout.getOutline(trans); p.extend(shape); } p.transform(getTransform()); return p; }
Shape shape = textLayout.getOutline(null); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform();
: AffineTransform.getRotateInstance( -1 * Math.toRadians(axesChartStyler.getXAxisLabelRotation())); Shape shape = textLayout.getOutline(rot); Rectangle2D rectangle = shape.getBounds();
AffineTransform affineTransform = new AffineTransform(); affineTransform.translate(posX, posY); awtCanvas.getGraphicObject().draw(layout.getOutline(affineTransform)); if (filter != Filter.NONE) { this.paintBack.setColor(colorB);