/** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (<code>null</code> not permitted). * * @return The block size (in Java2D units, never <code>null</code>). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { Size2D s = new Size2D(this.image.getWidth(null), this.image.getHeight(null)); return new Size2D(calculateTotalWidth(s.getWidth()), calculateTotalHeight(s.getHeight())); }
/** * Calculates the dimensions of the text fragment. * * @param g2 the graphics device. * * @return The width and height of the text. */ public Size2D calculateDimensions(final Graphics2D g2) { final FontMetrics fm = g2.getFontMetrics(this.font); final Rectangle2D bounds = TextUtilities.getTextBounds(this.text, g2, fm); final Size2D result = new Size2D(bounds.getWidth(), bounds.getHeight()); return result; }
/** * Arranges the content for this title assuming a range constraint for the * width and no bounds on the height, and returns the required size. * * @param g2 the graphics target. * @param widthRange the range for the width. * * @return The content size. */ protected Size2D arrangeRN(Graphics2D g2, Range widthRange) { Size2D s = arrangeNN(g2); if (widthRange.contains(s.getWidth())) { return s; } double ww = widthRange.constrain(s.getWidth()); return arrangeFN(g2, ww); }
/** * Returns the height of the text box. * * @param g2 the graphics device. * * @return The height (in Java2D units). */ public double getHeight(final Graphics2D g2) { final Size2D d = this.textBlock.calculateDimensions(g2); return this.interiorGap.extendHeight(d.getHeight()); }
final float[] offsets = calculateOffsets(anchor, d.getWidth(), d.getHeight()); final Iterator iterator = this.lines.iterator(); float yCursor = 0.0f; float lineOffset = 0.0f; if (this.lineAlignment == HorizontalAlignment.CENTER) { lineOffset = (float) (d.getWidth() - dimension.getWidth()) / 2.0f; lineOffset = (float) (d.getWidth() - dimension.getWidth()); TextAnchor.TOP_LEFT, rotateX, rotateY, angle ); yCursor = yCursor + (float) dimension.getHeight();
/** * Calculates the dimensions of the text fragment. * * @param g2 the graphics device. * * @return The width and height of the text. */ public Size2D calculateDimensions(final Graphics2D g2) { final FontMetrics fm = g2.getFontMetrics(this.font); final Rectangle2D bounds = TextUtilities.getTextBounds(this.text, g2, fm); final Size2D result = new Size2D(bounds.getWidth(), bounds.getHeight()); return result; }
/** * Arranges the content for this title assuming a range constraint for the * width and no bounds on the height, and returns the required size. This * will reflect the fact that a text title positioned on the left or right * of a chart will be rotated by 90 degrees. * * @param g2 the graphics target. * @param widthRange the range for the width. * * @return The content size. * * @since 1.0.9 */ protected Size2D arrangeRN(Graphics2D g2, Range widthRange) { Size2D s = arrangeNN(g2); if (widthRange.contains(s.getWidth())) { return s; } double ww = widthRange.constrain(s.getWidth()); return arrangeFN(g2, ww); }
/** * Returns the height of the text box. * * @param g2 the graphics device. * * @return The height (in Java2D units). */ public double getHeight(final Graphics2D g2) { final Size2D d = this.textBlock.calculateDimensions(g2); return this.interiorGap.extendHeight(d.getHeight()); }
/** * Calculates the width and height of the text line. * * @param g2 the graphics device. * * @return The width and height. */ public Size2D calculateDimensions(final Graphics2D g2) { double width = 0.0; double height = 0.0; final Iterator iterator = this.fragments.iterator(); while (iterator.hasNext()) { final TextFragment fragment = (TextFragment) iterator.next(); final Size2D dimension = fragment.calculateDimensions(g2); width = width + dimension.getWidth(); height = Math.max(height, dimension.getHeight()); } return new Size2D(width, height); }
/** * Calculates the dimensions of the text fragment. * * @param g2 the graphics device. * * @return The width and height of the text. */ public Size2D calculateDimensions(final Graphics2D g2) { final FontMetrics fm = g2.getFontMetrics(this.font); final Rectangle2D bounds = TextUtilities.getTextBounds(this.text, g2, fm); final Size2D result = new Size2D(bounds.getWidth(), bounds.getHeight()); return result; }
/** * Returns the height of the text box. * * @param g2 the graphics device. * * @return The height (in Java2D units). */ public double getHeight(final Graphics2D g2) { final Size2D d = this.textBlock.calculateDimensions(g2); return this.interiorGap.extendHeight(d.getHeight()); }
/** * Returns the width and height of the text block. * * @param g2 the graphics device. * * @return The width and height. */ public Size2D calculateDimensions(final Graphics2D g2) { double width = 0.0; double height = 0.0; final Iterator iterator = this.lines.iterator(); while (iterator.hasNext()) { final TextLine line = (TextLine) iterator.next(); final Size2D dimension = line.calculateDimensions(g2); width = Math.max(width, dimension.getWidth()); height = height + dimension.getHeight(); } return new Size2D(width, height); }