/ (float) glyphVector.getLogicalBounds().getWidth() : 1.0f; float height = (float) glyphVector.getLogicalBounds().getHeight(); float nextAdvance = 0;
double getWidth() { double width = 0; for (LineComponent lineComponent : components) { width += lineComponent.getGlyphVector().getLogicalBounds().getWidth(); } return width; }
void setMinX(double minX) { double x = minX; for (LineComponent component : components) { component.setX(x); // use the logical bounds to have spaces taken into account x += component.getGlyphVector().getLogicalBounds().getWidth(); } }
Rectangle2D getBounds() { Rectangle2D vb = null; for (LineComponent lineComponent : components) { Rectangle2D componentVisualBounds = lineComponent.getGlyphVector().getVisualBounds(); Rectangle2D componentLogicalBounds = lineComponent.getGlyphVector().getLogicalBounds(); // the logical bounds include the spaces, we want them in the horizontal direction // in order to compose the element in the row, but we need the visual bounds for // vertical alignment Rectangle2D componentBounds = new Rectangle2D.Double( componentLogicalBounds.getX(), componentVisualBounds.getY(), componentLogicalBounds.getWidth(), componentVisualBounds.getHeight()); if (vb == null) { vb = componentBounds; } else { Rectangle2D other = new Rectangle2D.Double( vb.getMaxX(), vb.getMinY(), componentBounds.getWidth(), componentBounds.getHeight()); vb = vb.createUnion(other); } } return vb; }
public java.awt.geom.Rectangle2D getLogicalBounds() { return javaGV.getLogicalBounds(); } private java.awt.font.GlyphVector javaGV;
private Rectangle2D bounds() { if ( bounds == null ) { bounds = glyphs.getLogicalBounds(); } return bounds; } }
@Override public Rectangle2D getLogicalBounds() { return this.vec.getLogicalBounds(); }
/** * Access the transformed logical bounds of the outline text. * * @return logical bounds */ Rectangle2D getLogicalBounds() { return transformedBounds(glyphs.getLogicalBounds()); }
String text = "Hello world!"; Font font = new Font(Font.SERIF, Font.PLAIN, 12); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); BufferedImage bufferedImage = new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB); Graphics2D g2d = ge.createGraphics(bufferedImage); FontRenderContext frc = g2d.getFontRenderContext(); GlyphVector glyphVector = font.createGlyphVector(frc, text); Rectangle2D rectangle2D = glyphVector.getLogicalBounds(); double w = rectangle2D.getWidth(); double h = rectangle2D.getHeight(); System.out.println("width = "+w+"\theight = "+h);
private void appendLine(String text, int start, int end, FontRenderContext fontRenderContext) { StringCharacterIterator line = new StringCharacterIterator(text, start, end, start); GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line); glyphVectors.add(glyphVector); Rectangle2D textBounds = glyphVector.getLogicalBounds(); textHeight += textBounds.getHeight(); }
private void appendLine(String text, int start, int end, FontRenderContext fontRenderContext) { StringCharacterIterator line = new StringCharacterIterator(text, start, end, start); GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line); glyphVectors.add(glyphVector); Rectangle2D textBounds = glyphVector.getLogicalBounds(); textHeight += textBounds.getHeight(); }
private static Rectangle2D getBounds(Graphics2D g, String text) { FontRenderContext frc=new FontRenderContext(new AffineTransform(), g.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING), g.getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS)); GlyphVector gv = new StandardGlyphVector(g.getFont(), text.toCharArray(), 0, text.length(), frc); return gv.getLogicalBounds(); }
private void appendLine(CharSequence characters, int start, int end, Font font, FontRenderContext fontRenderContext) { CharSequenceCharacterIterator line = new CharSequenceCharacterIterator(characters, start, end, start); GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line); rows.add(new Row(glyphVector, start)); Rectangle2D textBounds = glyphVector.getLogicalBounds(); width = Math.max(width, (float)textBounds.getWidth()); height += textBounds.getHeight(); }
private void appendLine(CharSequence characters, int start, int end, Font font, FontRenderContext fontRenderContext) { CharSequenceCharacterIterator line = new CharSequenceCharacterIterator(characters, start, end, start); GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line); rows.add(new Row(glyphVector, start)); Rectangle2D textBounds = glyphVector.getLogicalBounds(); width = Math.max(width, (float)textBounds.getWidth()); height += textBounds.getHeight(); }
public Rectangle2D getStringBounds( String str, FontRenderContext frc) { char[] array = str.toCharArray(); return getStringBounds(array, 0, array.length, frc); } public Rectangle2D getStringBounds(char [] chars, int beginIndex, int limit, FontRenderContext frc) { //some checks skipped boolean simple = values == null || (values.getKerning() == 0 && values.getLigatures() == 0 && values.getBaselineTransform() == null); if (simple) { simple = ! FontUtilities.isComplexText(chars, beginIndex, limit); } if (simple) { GlyphVector gv = new StandardGlyphVector(this, chars, beginIndex, limit - beginIndex, frc); return gv.getLogicalBounds();
public void setLineWidth(int lineWidth) { if (this.lineWidth != lineWidth) { this.lineWidth = lineWidth; int missingGlyphCode = font.getMissingGlyphCode(); FontRenderContext fontRenderContext = Platform.getFontRenderContext(); GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext, new int[] {missingGlyphCode}); Rectangle2D textBounds = missingGlyphVector.getLogicalBounds(); Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext); averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()), (int)Math.ceil(maxCharBounds.getHeight())); invalidateComponent(); } }
public void setLineWidth(int lineWidth) { if (this.lineWidth != lineWidth) { this.lineWidth = lineWidth; int missingGlyphCode = font.getMissingGlyphCode(); FontRenderContext fontRenderContext = Platform.getFontRenderContext(); GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext, new int[] {missingGlyphCode}); Rectangle2D textBounds = missingGlyphVector.getLogicalBounds(); Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext); averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()), (int)Math.ceil(maxCharBounds.getHeight())); invalidateComponent(); } }
/** * Sets the font of the text */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("font is null."); } this.font = font; int missingGlyphCode = font.getMissingGlyphCode(); FontRenderContext fontRenderContext = Platform.getFontRenderContext(); GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext, new int[] {missingGlyphCode}); Rectangle2D textBounds = missingGlyphVector.getLogicalBounds(); Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext); averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()), (int)Math.ceil(maxCharBounds.getHeight())); invalidateComponent(); }
/** * Sets the font of the text */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("font is null."); } this.font = font; int missingGlyphCode = font.getMissingGlyphCode(); FontRenderContext fontRenderContext = Platform.getFontRenderContext(); GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext, new int[] {missingGlyphCode}); Rectangle2D textBounds = missingGlyphVector.getLogicalBounds(); Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext); averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()), (int)Math.ceil(maxCharBounds.getHeight())); invalidateComponent(); }
public RotatedTextIcon(int rotate, Font font, String text) { this.rotate = rotate; this.font = font; FontRenderContext fontRenderContext = new FontRenderContext(null,true,true); glyphs = font.createGlyphVector(fontRenderContext,text); width = (int)glyphs.getLogicalBounds().getWidth() + 4; //height = (int)glyphs.getLogicalBounds().getHeight(); LineMetrics lineMetrics = font.getLineMetrics(text,fontRenderContext); ascent = lineMetrics.getAscent(); height = (int)lineMetrics.getHeight(); renderHints = new RenderingHints( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); renderHints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); renderHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); } //}}}