/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
rotateX, rotateY, angle ); x = x + (float) d.getWidth();
/** * 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) { g2.setFont(this.font); Size2D s = this.label.calculateDimensions(g2); return new Size2D(calculateTotalWidth(s.getWidth()), calculateTotalHeight(s.getHeight())); }
/** * A utility method for determining the width of a text block. * * @param block the text block. * @param position the position. * @param g2 the graphics device. * * @return The width. */ protected double calculateTextBlockWidth(TextBlock block, CategoryLabelPosition position, Graphics2D g2) { RectangleInsets insets = getTickLabelInsets(); Size2D size = block.calculateDimensions(g2); Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight()); Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), 0.0f, 0.0f); double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft() + insets.getRight(); return w; }
/** * A utility method for determining the height of a text block. * * @param block the text block. * @param position the label position. * @param g2 the graphics device. * * @return The height. */ protected double calculateTextBlockHeight(TextBlock block, CategoryLabelPosition position, Graphics2D g2) { RectangleInsets insets = getTickLabelInsets(); Size2D size = block.calculateDimensions(g2); Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight()); Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), 0.0f, 0.0f); double h = rotatedBox.getBounds2D().getHeight() + insets.getTop() + insets.getBottom(); return h; }
/** * 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())); }
/** * Arrange with a fixed height and a width within a given range. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size of the arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint c1 = constraint.toUnconstrainedWidth(); Size2D size1 = arrange(container, g2, c1); if (constraint.getWidthRange().contains(size1.getWidth())) { return size1; } else { double w = constraint.getWidthRange().constrain(size1.getWidth()); RectangleConstraint c2 = constraint.toFixedWidth(w); return arrange(container, g2, c2); } }
/** * Arrange with a fixed width and no height constraint. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size of the arrangement. */ protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint c1 = constraint.toUnconstrainedWidth(); Size2D size1 = arrange(container, g2, c1); if (constraint.getWidthRange().contains(size1.getWidth())) { return size1; } else { double w = constraint.getWidthRange().constrain(size1.getWidth()); RectangleConstraint c2 = constraint.toFixedWidth(w); return arrange(container, g2, c2); } }
/** * 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) { RectangleConstraint contentConstraint = toContentConstraint(constraint); Size2D contentSize = this.container.arrange(g2, contentConstraint); return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight())); }
/** * Arranges the blocks in the container with a range constraint on the * width and a fixed height. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size following the arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeNF(container, g2, constraint); if (constraint.getWidthRange().contains(s.width)) { return s; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().constrain(s.getWidth())); return arrangeFF(container, g2, c); } }
/** * Arranges the blocks in the container using a fixed height and a * range for the width. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size of the container after arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeNF(container, g2, constraint); if (constraint.getWidthRange().contains(s.width)) { return s; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().constrain(s.getWidth()) ); return arrangeFF(container, g2, c); } }
/** * Arranges the blocks in the container with a range constraint on the * width and a fixed height. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size following the arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeNF(container, g2, constraint); if (constraint.getWidthRange().contains(s.width)) { return s; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().constrain(s.getWidth()) ); return arrangeFF(container, g2, c); } }