use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class LegendTitle method arrange.
/**
* 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>).
*/
@Override
public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
Size2D result = new Size2D();
fetchLegendItems();
if (this.items.isEmpty()) {
return result;
}
BlockContainer container = this.wrapper;
if (container == null) {
container = this.items;
}
RectangleConstraint c = toContentConstraint(constraint);
Size2D size = container.arrange(g2, c);
result.height = calculateTotalHeight(size.height);
result.width = calculateTotalWidth(size.width);
return result;
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class ShortTextTitle method arrangeFN.
/**
* 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.
*/
@Override
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);
}
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class ShortTextTitle method arrangeRN.
/**
* 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.
*/
@Override
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);
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class ShortTextTitle method arrangeRR.
/**
* 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.
*/
@Override
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);
}
}
use of org.jfree.ui.Size2D in project SIMVA-SoS by SESoS.
the class ShortTextTitle method arrange.
/**
* Performs a layout for this title, subject to the supplied constraint,
* and returns the dimensions required for the title (if the title
* cannot be displayed in the available space, this method will return
* zero width and height for the dimensions).
*
* @param g2 the graphics target.
* @param constraint the layout constraints.
*
* @return The dimensions for the title.
*/
@Override
public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
RectangleConstraint cc = toContentConstraint(constraint);
LengthConstraintType w = cc.getWidthConstraintType();
LengthConstraintType h = cc.getHeightConstraintType();
Size2D contentSize = null;
if (w == LengthConstraintType.NONE) {
if (h == LengthConstraintType.NONE) {
contentSize = arrangeNN(g2);
} else if (h == LengthConstraintType.RANGE) {
throw new RuntimeException("Not yet implemented.");
} else if (h == LengthConstraintType.FIXED) {
throw new RuntimeException("Not yet implemented.");
}
} else if (w == LengthConstraintType.RANGE) {
if (h == LengthConstraintType.NONE) {
contentSize = arrangeRN(g2, cc.getWidthRange());
} else if (h == LengthConstraintType.RANGE) {
contentSize = arrangeRR(g2, cc.getWidthRange(), cc.getHeightRange());
} else if (h == LengthConstraintType.FIXED) {
throw new RuntimeException("Not yet implemented.");
}
} else if (w == LengthConstraintType.FIXED) {
if (h == LengthConstraintType.NONE) {
contentSize = arrangeFN(g2, cc.getWidth());
} else if (h == LengthConstraintType.RANGE) {
throw new RuntimeException("Not yet implemented.");
} else if (h == LengthConstraintType.FIXED) {
throw new RuntimeException("Not yet implemented.");
}
}
assert contentSize != null;
if (contentSize.width <= 0.0 || contentSize.height <= 0.0) {
return new Size2D(0.0, 0.0);
} else {
return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()));
}
}
Aggregations