public int getZHeight(Font font){ int height = (int) font.createGlyphVector(fakeRenderContext, "Z").getOutline().getBounds().getHeight(); if(DEBUG) System.out.println("Z height: "+height); return height; }
public void drawGlyphVector(GlyphVector g, float x, float y) { fill(g.getOutline(x, y)); }
/** * Renders the text of the specified * {@link GlyphVector} using * the <code>Graphics2D</code> context's rendering attributes. * The rendering attributes applied include the <code>Clip</code>, * <code>Transform</code>, <code>Paint</code>, and * <code>Composite</code> attributes. The <code>GlyphVector</code> * specifies individual glyphs from a {@link Font}. * The <code>GlyphVector</code> can also contain the glyph positions. * This is the fastest way to render a set of characters to the * screen. * * @param g the <code>GlyphVector</code> to be rendered * @param x the x position in user space where the glyphs should be * rendered * @param y the y position in user space where the glyphs should be * rendered * * @see java.awt.Font#createGlyphVector(FontRenderContext, char[]) * @see java.awt.font.GlyphVector * @see #setPaint * @see java.awt.Graphics#setColor * @see #setTransform * @see #setComposite * @see #setClip(Shape) */ public void drawGlyphVector(GlyphVector g, float x, float y) { Shape glyphOutline = g.getOutline(x, y); fill(glyphOutline); }
int xOff = 25+(int)-box.getX(); int yOff = 80+(int)-box.getY(); Shape shape = gv.getOutline(xOff,yOff); g.setClip(shape); g.drawImage(originalImage,0,0,null);
/** */ public Shape getHaloShape(Graphics2D graphics) { GlyphVector gv = getTextGlyphVector(graphics); haloShape = new BasicStroke(2f * haloRadius, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) .createStrokedShape(gv.getOutline()); return haloShape; }
if (font.canDisplay(i)) System.out.println(((int) i) + ": " + Long.toHexString(i)); GlyphVector textGlyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, new char[] {,}); Shape shape = textGlyphVector.getOutline(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.translate(150, 150);
Font f = getFont().deriveFont(Font.BOLD, 70); GlyphVector v = f.createGlyphVector(getFontMetrics(f).getFontRenderContext(), "Hello"); s = v.getOutline(); setPreferredSize(new Dimension(300,300));
private Shape getShape(String fontFamilyName, char character) { Font font = FontCache.getDefaultInstance().getFont(fontFamilyName); if (font == null) { throw new IllegalArgumentException("Unknown font " + fontFamilyName); } // handle charmap code reporting issues if (!font.canDisplay(character)) { char alternative = (char) (0xF000 | character); if (font.canDisplay(alternative)) { character = alternative; } } // build the shape out of the font GlyphVector textGlyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, new char[] {(char) character}); Shape s = textGlyphVector.getOutline(); // have the shape be centered in the origin, and sitting in a square of side 1 Rectangle2D bounds = s.getBounds2D(); AffineTransform tx = new AffineTransform(); double max = Math.max(bounds.getWidth(), bounds.getHeight()); // all shapes are defined looking "upwards" (see ShapeMarkFactory or WellKnownMarkFactory) // but the fonts ones are flipped to compensate for the fact the y coords grow from top // to bottom on the screen. We have to flip the symbol so that it conforms to the // other marks convention tx.scale(1 / max, -1 / max); tx.translate(-bounds.getCenterX(), -bounds.getCenterY()); ExplicitBoundsShape shape = new ExplicitBoundsShape(tx.createTransformedShape(s)); shape.setBounds(new Rectangle2D.Double(-0.5, 0.5, 1.0, 1.0)); return shape; }
Rectangle2D box1 = gv.getVisualBounds(); Shape shape1 = gv.getOutline(); Rectangle r = shape1.getBounds(); System.out.println("shape rect: " + r);
Rectangle2D box1 = gv.getVisualBounds(); Shape shape1 = gv.getOutline(); Rectangle r = shape1.getBounds(); int spaceX = sz - r.width;
LineMetrics metrics = computeLineMetricsIfNeeded(component); GlyphVector gv = component.getGlyphVector(); java.awt.Shape outline = gv.getOutline(); if (labelItem.getTextStyle().getHaloFill() != null) { configureHalo();
/** * @see Graphics2D#drawGlyphVector(GlyphVector, float, float) */ @Override public void drawGlyphVector(GlyphVector g, float x, float y) { Shape s = g.getOutline(x, y); fill(s); }
/** * Draws a GlyphVector at (x,y) */ public void drawGlyphVector(GlyphVector g, float x, float y) { Shape shape = g.getOutline(x, y); draw(shape, "fill"); }
/** {@inheritDoc} */ public void drawString(Graphics2D g2d, String text, float x, float y) throws IOException { java.awt.Font awtFont = g2d.getFont(); FontRenderContext frc = g2d.getFontRenderContext(); GlyphVector gv = awtFont.createGlyphVector(frc, text); Shape glyphOutline = gv.getOutline(x, y); g2d.fill(glyphOutline); }
public int getZHeight(Font font){ int height = (int) font.createGlyphVector(fakeRenderContext, "Z").getOutline().getBounds().getHeight(); if(DEBUG) System.out.println("Z height: "+height); return height; }
/** * Draws the specified glyph vector at the location {@code (x, y)}. * * @param g the glyph vector ({@code null} not permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawGlyphVector(GlyphVector g, float x, float y) { fill(g.getOutline(x, y)); }
/** * Use the transformation of the glyphvector and draw it * * @param g * @param x * @param y */ public void drawGlyphVector(GlyphVector g, float x, float y) { fill(g.getOutline(x, y)); }
@Override public Dimension findOptimalSize(Graphics2D g2d, WMSMapContent mapContent) throws Exception { Font font = getFont(); String message = evaluateMessage(mapContent); GlyphVector gv = font.createGlyphVector(g2d.getFontRenderContext(), message.toCharArray()); Shape outline = gv.getOutline(); Rectangle2D bounds = outline.getBounds2D(); double width = bounds.getWidth() + haloRadius * 2; double height = bounds.getHeight() + haloRadius * 2; return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); }
@Override public void draw(Graphics2D g2d, AttributedCharacterIterator arg1) { if (arg1.getAttribute(TextAttribute.PAINT_INFO) != null) { TextPaintInfo info = (TextPaintInfo) arg1.getAttribute(TextAttribute.PAINT_INFO); // TODO: Rest of stuff in info. g2d.setPaint(info.fillPaint); } g2d.fill(this.vec.getOutline()); }
/** {@inheritDoc} */ public void drawString(String s, float x, float y) { java.awt.Font awtFont = getFont(); FontRenderContext frc = getFontRenderContext(); GlyphVector gv = awtFont.createGlyphVector(frc, s); Shape glyphOutline = gv.getOutline(x, y); fill(glyphOutline); }