use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class ImageTitle method drawVertical.
/**
* Draws the title on a Java 2D graphics device (such as the screen or a
* printer).
*
* @param g2 the graphics device.
* @param chartArea the area within which the title (and plot) should be
* drawn.
*
* @return The size of the area used by the title.
*/
protected Size2D drawVertical(Graphics2D g2, Rectangle2D chartArea) {
double startX = 0.0;
double topSpace = 0.0;
double bottomSpace = 0.0;
double leftSpace = 0.0;
double rightSpace = 0.0;
double w = getWidth();
double h = getHeight();
RectangleInsets padding = getPadding();
if (padding != null) {
topSpace = padding.calculateTopOutset(h);
bottomSpace = padding.calculateBottomOutset(h);
leftSpace = padding.calculateLeftOutset(w);
rightSpace = padding.calculateRightOutset(w);
}
if (getPosition() == RectangleEdge.LEFT) {
startX = chartArea.getX() + leftSpace;
} else {
startX = chartArea.getMaxX() - rightSpace - w;
}
// what is our alignment?
VerticalAlignment alignment = getVerticalAlignment();
double startY = 0.0;
if (alignment == VerticalAlignment.CENTER) {
startY = chartArea.getMinY() + topSpace + chartArea.getHeight() / 2.0 - h / 2.0;
} else if (alignment == VerticalAlignment.TOP) {
startY = chartArea.getMinY() + topSpace;
} else if (alignment == VerticalAlignment.BOTTOM) {
startY = chartArea.getMaxY() - bottomSpace - h;
}
g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, null);
return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, h + topSpace + bottomSpace);
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class ImageTitle method drawHorizontal.
/**
* Draws the title on a Java 2D graphics device (such as the screen or a
* printer).
*
* @param g2 the graphics device.
* @param chartArea the area within which the title (and plot) should be
* drawn.
*
* @return The size of the area used by the title.
*/
protected Size2D drawHorizontal(Graphics2D g2, Rectangle2D chartArea) {
double startY = 0.0;
double topSpace = 0.0;
double bottomSpace = 0.0;
double leftSpace = 0.0;
double rightSpace = 0.0;
double w = getWidth();
double h = getHeight();
RectangleInsets padding = getPadding();
topSpace = padding.calculateTopOutset(h);
bottomSpace = padding.calculateBottomOutset(h);
leftSpace = padding.calculateLeftOutset(w);
rightSpace = padding.calculateRightOutset(w);
if (getPosition() == RectangleEdge.TOP) {
startY = chartArea.getY() + topSpace;
} else {
startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - h;
}
// what is our alignment?
HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
double startX = 0.0;
if (horizontalAlignment == HorizontalAlignment.CENTER) {
startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0 - w / 2.0;
} else if (horizontalAlignment == HorizontalAlignment.LEFT) {
startX = chartArea.getX() + leftSpace;
} else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w;
}
g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, null);
return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, h + topSpace + bottomSpace);
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class LegendGraphic 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>).
*/
public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
RectangleConstraint contentConstraint = toContentConstraint(constraint);
LengthConstraintType w = contentConstraint.getWidthConstraintType();
LengthConstraintType h = contentConstraint.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) {
throw new RuntimeException("Not yet implemented.");
} 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.FIXED) {
if (h == LengthConstraintType.NONE) {
throw new RuntimeException("Not yet implemented.");
} else if (h == LengthConstraintType.RANGE) {
throw new RuntimeException("Not yet implemented.");
} else if (h == LengthConstraintType.FIXED) {
contentSize = new Size2D(contentConstraint.getWidth(), contentConstraint.getHeight());
}
}
return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()));
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
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());
Iterator iterator = this.lines.iterator();
float yCursor = 0.0f;
while (iterator.hasNext()) {
TextLine line = (TextLine) iterator.next();
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();
}
}
use of org.jfree.chart.util.Size2D in project graphcode2vec by graphcode2vec.
the class TextBlock method calculateDimensions.
/**
* Returns the width and height of the text block.
*
* @param g2 the graphics device.
*
* @return The width and height.
*/
public Size2D calculateDimensions(Graphics2D g2) {
double width = 0.0;
double height = 0.0;
Iterator iterator = this.lines.iterator();
while (iterator.hasNext()) {
TextLine line = (TextLine) iterator.next();
Size2D dimension = line.calculateDimensions(g2);
width = Math.max(width, dimension.getWidth());
height = height + dimension.getHeight();
}
return new Size2D(width, height);
}
Aggregations