Search in sources :

Example 26 with Size2D

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);
    }
}
Also used : Size2D(org.jfree.chart.block.Size2D) FontMetrics(java.awt.FontMetrics) Rectangle2D(java.awt.geom.Rectangle2D)

Example 27 with Size2D

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);
}
Also used : Size2D(org.jfree.chart.block.Size2D)

Aggregations

Size2D (org.jfree.chart.block.Size2D)27 Rectangle2D (java.awt.geom.Rectangle2D)11 RectangleConstraint (org.jfree.chart.block.RectangleConstraint)8 RectangleEdge (org.jfree.chart.api.RectangleEdge)5 FontMetrics (java.awt.FontMetrics)4 Shape (java.awt.Shape)4 LengthConstraintType (org.jfree.chart.block.LengthConstraintType)4 Point2D (java.awt.geom.Point2D)2 RectangleInsets (org.jfree.chart.api.RectangleInsets)2 BlockParams (org.jfree.chart.block.BlockParams)2 EntityBlockResult (org.jfree.chart.block.EntityBlockResult)2 G2TextMeasurer (org.jfree.chart.text.G2TextMeasurer)2 Range (org.jfree.data.Range)2 Arc2D (java.awt.geom.Arc2D)1 AxisLocation (org.jfree.chart.axis.AxisLocation)1 AxisSpace (org.jfree.chart.axis.AxisSpace)1 BlockContainer (org.jfree.chart.block.BlockContainer)1 EntityCollection (org.jfree.chart.entity.EntityCollection)1 PlotOrientation (org.jfree.chart.plot.PlotOrientation)1