use of org.jfree.chart.block.Size2D in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class TextTitle 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. 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.
*/
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.chart.block.Size2D in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class TextLine method calculateDimensions.
/**
* Calculates the width and height of the text line.
*
* @param g2 the graphics device.
*
* @return The width and height.
*/
public Size2D calculateDimensions(Graphics2D g2) {
double width = 0.0;
double height = 0.0;
for (TextFragment fragment : this.fragments) {
final Size2D dimension = fragment.calculateDimensions(g2);
width = width + dimension.getWidth();
height = Math.max(height, dimension.getHeight());
}
return new Size2D(width, height);
}
use of org.jfree.chart.block.Size2D in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryAxis method calculateCategoryLabelWidth.
/**
* Calculates the width of a category label when rendered.
*
* @param label the text block ({@code null} not permitted).
* @param position the position.
* @param insets the label insets.
* @param g2 the graphics device.
*
* @return The width.
*/
protected double calculateCategoryLabelWidth(TextBlock label, CategoryLabelPosition position, RectangleInsets insets, Graphics2D g2) {
Size2D size = label.calculateDimensions(g2);
Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight());
Shape rotatedBox = ShapeUtils.rotateShape(box, position.getAngle(), 0.0f, 0.0f);
double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft() + insets.getRight();
return w;
}
use of org.jfree.chart.block.Size2D in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryAxis method calculateCategoryLabelHeight.
/**
* Calculates the height of a category label when rendered.
*
* @param block the text block ({@code null} not permitted).
* @param position the label position ({@code null} not permitted).
* @param insets the label insets ({@code null} not permitted).
* @param g2 the graphics device ({@code null} not permitted).
*
* @return The height.
*/
protected double calculateCategoryLabelHeight(TextBlock block, CategoryLabelPosition position, RectangleInsets insets, Graphics2D g2) {
Size2D size = block.calculateDimensions(g2);
Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight());
Shape rotatedBox = ShapeUtils.rotateShape(box, position.getAngle(), 0.0f, 0.0f);
double h = rotatedBox.getBounds2D().getHeight() + insets.getTop() + insets.getBottom();
return h;
}
use of org.jfree.chart.block.Size2D in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class TextBlock method draw.
/**
* Draws the text block, aligning it with the specified anchor point and
* rotating it about the specified rotation point.
*
* @param g2 the graphics device.
* @param anchorX the x-coordinate for the anchor point.
* @param anchorY the y-coordinate for the anchor point.
* @param anchor the point on the text block that is aligned to the
* anchor point.
* @param rotateX the x-coordinate for the rotation point.
* @param rotateY the x-coordinate for the rotation point.
* @param angle the rotation (in radians).
*/
public void draw(Graphics2D g2, float anchorX, float anchorY, TextBlockAnchor anchor, float rotateX, float rotateY, double angle) {
Size2D d = calculateDimensions(g2);
float[] offsets = calculateOffsets(anchor, d.getWidth(), d.getHeight());
float yCursor = 0.0f;
for (TextLine line : this.lines) {
Size2D dimension = line.calculateDimensions(g2);
float lineOffset = 0.0f;
if (this.lineAlignment == HorizontalAlignment.CENTER) {
lineOffset = (float) (d.getWidth() - dimension.getWidth()) / 2.0f;
} else if (this.lineAlignment == HorizontalAlignment.RIGHT) {
lineOffset = (float) (d.getWidth() - dimension.getWidth());
}
line.draw(g2, anchorX + offsets[0] + lineOffset, anchorY + offsets[1] + yCursor, TextAnchor.TOP_LEFT, rotateX, rotateY, angle);
yCursor = yCursor + (float) dimension.getHeight();
}
}
Aggregations