/** * 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; }
/** * 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; }
/** * 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; }
/** * Performs the layout with no constraint, so the content size is * determined by the bounds of the shape and/or line drawn to represent * the series. * * @param g2 the graphics device. * * @return The content size. */ protected Size2D arrangeNN(Graphics2D g2) { Rectangle2D contentSize = new Rectangle2D.Double(); if (this.line != null) { contentSize.setRect(this.line.getBounds2D()); } if (this.shape != null) { contentSize = contentSize.createUnion(this.shape.getBounds2D()); } return new Size2D(contentSize.getWidth(), contentSize.getHeight()); }
/** * Arranges the content for this title assuming a fixed 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 w the width. * * @return The content size. */ protected Size2D arrangeFN(Graphics2D g2, double w) { g2.setFont(getFont()); FontMetrics fm = g2.getFontMetrics(getFont()); Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); if (bounds.getWidth() <= w) { return new Size2D(w, bounds.getHeight()); } else { return new Size2D(0.0, 0.0); } }
/** * 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 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); }
/** * 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); }
/** * Arranges the blocks without any constraints. This puts all blocks * into a single row. * * @param container the container. * @param g2 the graphics device. * * @return The size after the arrangement. */ protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { List blocks = container.getBlocks(); Block b = (Block) blocks.get(0); Size2D s = b.arrange(g2, RectangleConstraint.NONE); b.setBounds(new Rectangle2D.Double(0.0, 0.0, s.width, s.height)); return new Size2D(s.width, s.height); }
/** * 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())); }
/** * Returns the content size for the title. * * @param g2 the graphics device. * @param widthRange the width range. * @param heightRange the height range. * * @return The content size. */ protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange) { g2.setFont(getFont()); FontMetrics fm = g2.getFontMetrics(getFont()); Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); if (bounds.getWidth() <= widthRange.getUpperBound() && bounds.getHeight() <= heightRange.getUpperBound()) { return new Size2D(bounds.getWidth(), bounds.getHeight()); } else { return new Size2D(0.0, 0.0); } }
/** * 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 base = new Size2D(getWidth(), getHeight()); return constraint.calculateConstrainedSize(base); }
/** * Arranges the blocks in the container with a fixed width and no height * constraint. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size. */ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { List blocks = container.getBlocks(); Block b = (Block) blocks.get(0); Size2D s = b.arrange(g2, RectangleConstraint.NONE); double width = constraint.getWidth(); Rectangle2D bounds = new Rectangle2D.Double((width - s.width) / 2.0, 0.0, s.width, s.height); b.setBounds(bounds); return new Size2D((width - s.width) / 2.0, s.height); }
/** * 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) { return new Size2D(calculateTotalWidth(getWidth()), calculateTotalHeight(getHeight())); }
/** * 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())); }
/** * 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 base = new Size2D(calculateTotalWidth(getWidth()), calculateTotalHeight(getHeight())); return constraint.calculateConstrainedSize(base); }
/** * 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())); }