use of org.jfree.ui.RectangleEdge in project SIMVA-SoS by SESoS.
the class XYLineAndShapeRenderer method drawSecondaryPass.
/**
* Draws the item shapes and adds chart entities (second pass). This method
* draws the shapes which mark the item positions. If <code>entities</code>
* is not <code>null</code> it will be populated with entity information
* for points that fall within the data area.
*
* @param g2 the graphics device.
* @param plot the plot (can be used to obtain standard color
* information etc).
* @param domainAxis the domain axis.
* @param dataArea the area within which the data is being drawn.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param pass the pass.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param crosshairState the crosshair state.
* @param entities the entity collection.
*/
protected void drawSecondaryPass(Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, Rectangle2D dataArea, ValueAxis rangeAxis, CrosshairState crosshairState, EntityCollection entities) {
Shape entityArea = null;
// get the data point...
double x1 = dataset.getXValue(series, item);
double y1 = dataset.getYValue(series, item);
if (Double.isNaN(y1) || Double.isNaN(x1)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
if (getItemShapeVisible(series, item)) {
Shape shape = getItemShape(series, item);
if (orientation == PlotOrientation.HORIZONTAL) {
shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
} else if (orientation == PlotOrientation.VERTICAL) {
shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
}
entityArea = shape;
if (shape.intersects(dataArea)) {
if (getItemShapeFilled(series, item)) {
if (this.useFillPaint) {
g2.setPaint(getItemFillPaint(series, item));
} else {
g2.setPaint(getItemPaint(series, item));
}
g2.fill(shape);
}
if (this.drawOutlines) {
if (getUseOutlinePaint()) {
g2.setPaint(getItemOutlinePaint(series, item));
} else {
g2.setPaint(getItemPaint(series, item));
}
g2.setStroke(getItemOutlineStroke(series, item));
g2.draw(shape);
}
}
}
double xx = transX1;
double yy = transY1;
if (orientation == PlotOrientation.HORIZONTAL) {
xx = transY1;
yy = transX1;
}
// draw the item label if there is one...
if (isItemLabelVisible(series, item)) {
drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0));
}
int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation);
// area...
if (entities != null && isPointInRect(dataArea, xx, yy)) {
addEntity(entities, entityArea, dataset, series, item, xx, yy);
}
}
use of org.jfree.ui.RectangleEdge in project SIMVA-SoS by SESoS.
the class PaintScaleLegend method arrangeRR.
/**
* Returns the content size for the title. This will reflect the fact that
* a text title positioned on the left or right of a chart will be rotated
* 90 degrees.
*
* @param g2 the graphics device.
* @param widthRange the width range.
* @param heightRange the height range.
*
* @return The content size.
*/
protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange) {
RectangleEdge position = getPosition();
if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
float maxWidth = (float) widthRange.getUpperBound();
// determine the space required for the axis
AxisSpace space = this.axis.reserveSpace(g2, null, new Rectangle2D.Double(0, 0, maxWidth, 100), RectangleEdge.BOTTOM, null);
return new Size2D(maxWidth, this.stripWidth + this.axisOffset + space.getTop() + space.getBottom());
} else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) {
float maxHeight = (float) heightRange.getUpperBound();
AxisSpace space = this.axis.reserveSpace(g2, null, new Rectangle2D.Double(0, 0, 100, maxHeight), RectangleEdge.RIGHT, null);
return new Size2D(this.stripWidth + this.axisOffset + space.getLeft() + space.getRight(), maxHeight);
} else {
throw new RuntimeException("Unrecognised position.");
}
}
use of org.jfree.ui.RectangleEdge in project SIMVA-SoS by SESoS.
the class TextTitle 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.
*
* @since 1.0.9
*/
protected Size2D arrangeFN(Graphics2D g2, double w) {
RectangleEdge position = getPosition();
if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
float maxWidth = (float) w;
g2.setFont(this.font);
this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
this.content.setLineAlignment(this.textAlignment);
Size2D contentSize = this.content.calculateDimensions(g2);
if (this.expandToFitSpace) {
return new Size2D(maxWidth, contentSize.getHeight());
} else {
return contentSize;
}
} else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) {
float maxWidth = Float.MAX_VALUE;
g2.setFont(this.font);
this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
this.content.setLineAlignment(this.textAlignment);
Size2D contentSize = this.content.calculateDimensions(g2);
// transpose the dimensions, because the title is rotated
if (this.expandToFitSpace) {
return new Size2D(contentSize.getHeight(), maxWidth);
} else {
return new Size2D(contentSize.height, contentSize.width);
}
} else {
throw new RuntimeException("Unrecognised exception.");
}
}
use of org.jfree.ui.RectangleEdge in project SIMVA-SoS by SESoS.
the class TextTitle method drawVertical.
/**
* Draws a the title vertically within the specified area. This method
* will be called from the {@link #draw(Graphics2D, Rectangle2D) draw}
* method.
*
* @param g2 the graphics device.
* @param area the area for the title.
*/
protected void drawVertical(Graphics2D g2, Rectangle2D area) {
Rectangle2D titleArea = (Rectangle2D) area.clone();
g2.setFont(this.font);
g2.setPaint(this.paint);
TextBlockAnchor anchor = null;
float y = 0.0f;
VerticalAlignment verticalAlignment = getVerticalAlignment();
if (verticalAlignment == VerticalAlignment.TOP) {
y = (float) titleArea.getY();
anchor = TextBlockAnchor.TOP_RIGHT;
} else if (verticalAlignment == VerticalAlignment.BOTTOM) {
y = (float) titleArea.getMaxY();
anchor = TextBlockAnchor.TOP_LEFT;
} else if (verticalAlignment == VerticalAlignment.CENTER) {
y = (float) titleArea.getCenterY();
anchor = TextBlockAnchor.TOP_CENTER;
}
float x = 0.0f;
RectangleEdge position = getPosition();
if (position == RectangleEdge.LEFT) {
x = (float) titleArea.getX();
} else if (position == RectangleEdge.RIGHT) {
x = (float) titleArea.getMaxX();
if (verticalAlignment == VerticalAlignment.TOP) {
anchor = TextBlockAnchor.BOTTOM_RIGHT;
} else if (verticalAlignment == VerticalAlignment.CENTER) {
anchor = TextBlockAnchor.BOTTOM_CENTER;
} else if (verticalAlignment == VerticalAlignment.BOTTOM) {
anchor = TextBlockAnchor.BOTTOM_LEFT;
}
}
this.content.draw(g2, x, y, anchor, x, y, -Math.PI / 2.0);
}
use of org.jfree.ui.RectangleEdge in project SIMVA-SoS by SESoS.
the class TextTitle method draw.
/**
* Draws the block within the specified area.
*
* @param g2 the graphics device.
* @param area the area.
* @param params if this is an instance of {@link EntityBlockParams} it
* is used to determine whether or not an
* {@link EntityCollection} is returned by this method.
*
* @return An {@link EntityCollection} containing a chart entity for the
* title, or <code>null</code>.
*/
@Override
public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
if (this.content == null) {
return null;
}
area = trimMargin(area);
drawBorder(g2, area);
if (this.text.equals("")) {
return null;
}
ChartEntity entity = null;
if (params instanceof EntityBlockParams) {
EntityBlockParams p = (EntityBlockParams) params;
if (p.getGenerateEntities()) {
entity = new TitleEntity(area, this, this.toolTipText, this.urlText);
}
}
area = trimBorder(area);
if (this.backgroundPaint != null) {
g2.setPaint(this.backgroundPaint);
g2.fill(area);
}
area = trimPadding(area);
RectangleEdge position = getPosition();
if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
drawHorizontal(g2, area);
} else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) {
drawVertical(g2, area);
}
BlockResult result = new BlockResult();
if (entity != null) {
StandardEntityCollection sec = new StandardEntityCollection();
sec.add(entity);
result.setEntityCollection(sec);
}
return result;
}
Aggregations