/** Returns the distance from the y drawing location to the top most pixel of the specified text. */ public int getYOffset (String text) { if (text == null) throw new IllegalArgumentException("text cannot be null."); if (renderType == RenderType.FreeType && bitmapFont != null) return (int)bitmapFont.getAscent(); int index = text.indexOf('\n'); if (index != -1) text = text.substring(0, index); char[] chars = text.toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int yOffset = ascent + vector.getPixelBounds(null, 0, 0).y; return yOffset; }
/** Returns the distance from the y drawing location to the top most pixel of the specified text. */ public int getYOffset (String text) { if (text == null) throw new IllegalArgumentException("text cannot be null."); if (renderType == RenderType.FreeType && bitmapFont != null) return (int)bitmapFont.getAscent(); int index = text.indexOf('\n'); if (index != -1) text = text.substring(0, index); char[] chars = text.toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int yOffset = ascent + vector.getPixelBounds(null, 0, 0).y; return yOffset; }
return gv.getPixelBounds(null, x, y);
Graphics2D g2d = (Graphics2D) g; FontRenderContext frc = g2d.getFontRenderContext(); GlyphVector gv = g2d.getFont().createGlyphVector(frc, "YOUR_STRING"); Rectangle rect = gv.getPixelBounds(null, INITIAL_X, INITIAL_Y); int width = rect.width; int height = rect.height;
@Override public Rectangle2D getBounds(GlyphVector gv, FontRenderContext frc) { Rectangle2D stringBounds = gv.getPixelBounds(frc, 0, 0); return new Rectangle2D.Double(stringBounds.getX(), stringBounds.getY(), stringBounds.getWidth() + dropShadowDepth, stringBounds.getHeight() + dropShadowDepth); }
@Override public Rectangle2D getBounds(GlyphVector gv, FontRenderContext frc) { Rectangle2D stringBounds = gv.getPixelBounds(frc, 0, 0); return new Rectangle2D.Double(stringBounds.getX(), stringBounds.getY(), stringBounds.getWidth(), stringBounds.getHeight()); }
@Override public Rectangle2D getBounds(GlyphVector gv, FontRenderContext frc) { Rectangle2D stringBounds = gv.getPixelBounds(frc, 0, 0); return new Rectangle2D.Double(stringBounds.getX(), stringBounds.getY(), stringBounds.getWidth(), stringBounds.getHeight()); }
private boolean isSmall(int c,Font font,double threhold){ Rectangle2D box=font.createGlyphVector(context,new String(new int[]{c},0,1)).getPixelBounds(context,0,0); return box.getWidth()<threhold&&box.getHeight()<threhold; } private static CombinedSet loadSet(Node element){
/** Returns a rectangle enclosing the pixels affected by drawString * assuming it is drawn at (x=0, y=0). As drawString draws above the drawing location, * the y coordinate of the rectangle is negative. */ public Rectangle getStringBounds(String s) { setupFontMetrics(); GlyphVector gv = font.createGlyphVector(fmGraphics.getFontRenderContext(), s); Rectangle2D rect = gv.getPixelBounds(null, 0.f, -fontMetrics.getDescent()); return new Rectangle((int)rect.getX(), (int)rect.getY(), (int)rect.getWidth(), (int)rect.getHeight()); }
/** Returns a rectangle enclosing the pixels affected by drawString * assuming it is drawn at (x=0, y=0). As drawString draws above the drawing location, * the y coordinate of the rectangle is negative. */ public Rectangle getStringBounds(String s) { setupFontMetrics(); GlyphVector gv = font.createGlyphVector(fmGraphics.getFontRenderContext(), s); Rectangle2D rect = gv.getPixelBounds(null, 0.f, -fontMetrics.getDescent()); return new Rectangle((int)rect.getX(), (int)rect.getY(), (int)rect.getWidth(), (int)rect.getHeight()); }
/** Returns the distance from the y drawing location to the top most pixel of the specified text. */ public int getYOffset (String text) { if (text == null) throw new IllegalArgumentException("text cannot be null."); if (renderType == RenderType.FreeType && bitmapFont != null) return (int)bitmapFont.getAscent(); int index = text.indexOf('\n'); if (index != -1) text = text.substring(0, index); char[] chars = text.toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int yOffset = ascent + vector.getPixelBounds(null, 0, 0).y; return yOffset; }
/** * Returns the distance from the y drawing location to the top most pixel of the * specified text. * * @param text The text to analyse * @return The distance fro the y drawing location ot the top most pixel of the specified text */ public int getYOffset (String text) { if (text == null) throw new IllegalArgumentException("text cannot be null."); DisplayList displayList = null; if (displayListCaching) { displayList = (DisplayList)displayLists.get(text); if (displayList != null && displayList.yOffset != null) return displayList.yOffset.intValue(); } int index = text.indexOf('\n'); if (index != -1) text = text.substring(0, index); char[] chars = text.toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int yOffset = ascent + vector.getPixelBounds(null, 0, 0).y; if (displayList != null) displayList.yOffset = new Short((short)yOffset); return yOffset; }
graphics.getFontRenderContext(), text.toCharArray(), 0, text.length(), Font.LAYOUT_LEFT_TO_RIGHT); Rectangle pixBounds = gv.getPixelBounds( graphics.getFontRenderContext(), 0, 0); System.out.println("GlyphVector - pixelBounds: " + pixBounds);
@Override void doPaint(Graphics2D g2, int x, int y) { if (color != null) { g2.setColor(color); } if (font != null) { g2.setFont(font); } GlyphVector gv = g2.getFont().layoutGlyphVector(g2.getFontRenderContext(), chars, 0, 1, Font.LAYOUT_LEFT_TO_RIGHT); Rectangle r = gv.getPixelBounds(g2.getFontRenderContext(), x, y); int dx = x + (getIconWidth() - r.width) / 2; int dy = y + getIconHeight() - (getIconHeight() - r.height) / 2; g2.drawGlyphVector(gv, dx, dy); } };
final Rectangle bounds = vector.getPixelBounds(null, 0, height); final float bw = (float) bounds.getWidth(); final float bh = (float) bounds.getHeight();
GlyphVector glyphVector = musicFont.createGlyphVector(frc, string); Rectangle rect = glyphVector.getPixelBounds( frc, xOffset.getValue(),
Rectangle2D stringBounds = gv.getPixelBounds(frc, 0, 0); return new Rectangle2D.Double(stringBounds.getX(), stringBounds.getY(), stringBounds.getWidth() + dropShadowDepth, stringBounds.getHeight() + dropShadowDepth);
temp = _GlyphVector.getPixelBounds(null, (float)_Position.getX(), (float)_Position.getY());
Rectangle2D bounds = gvSymbol.getPixelBounds(frc, 0, 0);
Rectangle glyphBounds = glyphVector.getPixelBounds( new FontRenderContext(tempTransform, true, false), 0, 0); try {