use of org.jfree.chart.block.Size2D in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
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 = TextUtils.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.chart.block.Size2D in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
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);
}
Aggregations