use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class XYStepRenderer method drawItem.
/**
* Draws the visual representation of a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area within which the data is being drawn.
* @param info collects information about the drawing.
* @param plot the plot (can be used to obtain standard color
* information etc).
* @param domainAxis the domain axis.
* @param rangeAxis the vertical axis.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param crosshairState crosshair information for the plot
* (<code>null</code> permitted).
* @param pass the pass index.
*/
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {
// do nothing if item is not visible
if (!getItemVisible(series, item)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
Paint seriesPaint = getItemPaint(series, item);
Stroke seriesStroke = getItemStroke(series, item);
g2.setPaint(seriesPaint);
g2.setStroke(seriesStroke);
// get the data point...
double x1 = dataset.getXValue(series, item);
double y1 = dataset.getYValue(series, item);
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
double transY1 = (Double.isNaN(y1) ? Double.NaN : rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation));
if (pass == 0 && item > 0) {
// get the previous data point...
double x0 = dataset.getXValue(series, item - 1);
double y0 = dataset.getYValue(series, item - 1);
double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
double transY0 = (Double.isNaN(y0) ? Double.NaN : rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation));
if (orientation == PlotOrientation.HORIZONTAL) {
if (transY0 == transY1) {
// this represents the situation
// for drawing a horizontal bar.
drawLine(g2, state.workingLine, transY0, transX0, transY1, transX1);
} else {
// this handles the need to perform a 'step'.
// calculate the step point
double transXs = transX0 + (getStepPoint() * (transX1 - transX0));
drawLine(g2, state.workingLine, transY0, transX0, transY0, transXs);
drawLine(g2, state.workingLine, transY0, transXs, transY1, transXs);
drawLine(g2, state.workingLine, transY1, transXs, transY1, transX1);
}
} else if (orientation == PlotOrientation.VERTICAL) {
if (transY0 == transY1) {
// this represents the situation
// for drawing a horizontal bar.
drawLine(g2, state.workingLine, transX0, transY0, transX1, transY1);
} else {
// this handles the need to perform a 'step'.
// calculate the step point
double transXs = transX0 + (getStepPoint() * (transX1 - transX0));
drawLine(g2, state.workingLine, transX0, transY0, transXs, transY0);
drawLine(g2, state.workingLine, transXs, transY0, transXs, transY1);
drawLine(g2, state.workingLine, transXs, transY1, transX1, transY1);
}
}
// submit this data item as a candidate for the crosshair point
int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation);
// collect entity and tool tip information...
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addEntity(entities, null, dataset, series, item, transX1, transY1);
}
}
if (pass == 1) {
// draw the item label if there is one...
if (isItemLabelVisible(series, item)) {
double xx = transX1;
double yy = transY1;
if (orientation == PlotOrientation.HORIZONTAL) {
xx = transY1;
yy = transX1;
}
drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0));
}
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class SamplingXYLineRenderer method drawItem.
/**
* Draws the visual representation of a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area within which the data is being drawn.
* @param info collects information about the drawing.
* @param plot the plot (can be used to obtain standard color
* information etc).
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param crosshairState crosshair information for the plot
* (<code>null</code> permitted).
* @param pass the pass index.
*/
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {
// do nothing if item is not visible
if (!getItemVisible(series, item)) {
return;
}
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
// get the data point...
double x1 = dataset.getXValue(series, item);
double y1 = dataset.getYValue(series, item);
double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
State s = (State) state;
// update path to reflect latest point
if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) {
float x = (float) transX1;
float y = (float) transY1;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
x = (float) transY1;
y = (float) transX1;
}
if (s.lastPointGood) {
if ((Math.abs(x - s.lastX) > s.dX)) {
s.seriesPath.lineTo(x, y);
if (s.lowY < s.highY) {
s.intervalPath.moveTo((float) s.lastX, (float) s.lowY);
s.intervalPath.lineTo((float) s.lastX, (float) s.highY);
}
s.lastX = x;
s.openY = y;
s.highY = y;
s.lowY = y;
s.closeY = y;
} else {
s.highY = Math.max(s.highY, y);
s.lowY = Math.min(s.lowY, y);
s.closeY = y;
}
} else {
s.seriesPath.moveTo(x, y);
s.lastX = x;
s.openY = y;
s.highY = y;
s.lowY = y;
s.closeY = y;
}
s.lastPointGood = true;
} else {
s.lastPointGood = false;
}
// if this is the last item, draw the path ...
if (item == s.getLastItemIndex()) {
// draw path
PathIterator pi = s.seriesPath.getPathIterator(null);
int count = 0;
while (!pi.isDone()) {
count++;
pi.next();
}
g2.setStroke(getItemStroke(series, item));
g2.setPaint(getItemPaint(series, item));
g2.draw(s.seriesPath);
g2.draw(s.intervalPath);
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class StackedXYAreaRenderer2 method drawItem.
/**
* Draws the visual representation of a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area within which the data is being drawn.
* @param info collects information about the drawing.
* @param plot the plot (can be used to obtain standard color information
* etc).
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param crosshairState information about crosshairs on a plot.
* @param pass the pass index.
*/
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {
// setup for collecting optional entity info...
Shape entityArea;
EntityCollection entities = null;
if (info != null) {
entities = info.getOwner().getEntityCollection();
}
TableXYDataset tdataset = (TableXYDataset) dataset;
PlotOrientation orientation = plot.getOrientation();
// get the data point...
double x1 = dataset.getXValue(series, item);
double y1 = dataset.getYValue(series, item);
if (Double.isNaN(y1)) {
y1 = 0.0;
}
double[] stack1 = getStackValues(tdataset, series, item);
// get the previous point and the next point so we can calculate a
// "hot spot" for the area (used by the chart entity)...
double x0 = dataset.getXValue(series, Math.max(item - 1, 0));
double y0 = dataset.getYValue(series, Math.max(item - 1, 0));
if (Double.isNaN(y0)) {
y0 = 0.0;
}
double[] stack0 = getStackValues(tdataset, series, Math.max(item - 1, 0));
int itemCount = dataset.getItemCount(series);
double x2 = dataset.getXValue(series, Math.min(item + 1, itemCount - 1));
double y2 = dataset.getYValue(series, Math.min(item + 1, itemCount - 1));
if (Double.isNaN(y2)) {
y2 = 0.0;
}
double[] stack2 = getStackValues(tdataset, series, Math.min(item + 1, itemCount - 1));
double xleft = (x0 + x1) / 2.0;
double xright = (x1 + x2) / 2.0;
double[] stackLeft = averageStackValues(stack0, stack1);
double[] stackRight = averageStackValues(stack1, stack2);
double[] adjStackLeft = adjustedStackValues(stack0, stack1);
double[] adjStackRight = adjustedStackValues(stack1, stack2);
RectangleEdge edge0 = plot.getDomainAxisEdge();
float transX1 = (float) domainAxis.valueToJava2D(x1, dataArea, edge0);
float transXLeft = (float) domainAxis.valueToJava2D(xleft, dataArea, edge0);
float transXRight = (float) domainAxis.valueToJava2D(xright, dataArea, edge0);
if (this.roundXCoordinates) {
transX1 = Math.round(transX1);
transXLeft = Math.round(transXLeft);
transXRight = Math.round(transXRight);
}
float transY1;
RectangleEdge edge1 = plot.getRangeAxisEdge();
GeneralPath left = new GeneralPath();
GeneralPath right = new GeneralPath();
if (y1 >= 0.0) {
// handle positive value
transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[1], dataArea, edge1);
float transStack1 = (float) rangeAxis.valueToJava2D(stack1[1], dataArea, edge1);
float transStackLeft = (float) rangeAxis.valueToJava2D(adjStackLeft[1], dataArea, edge1);
// LEFT POLYGON
if (y0 >= 0.0) {
double yleft = (y0 + y1) / 2.0 + stackLeft[1];
float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1);
if (orientation == PlotOrientation.VERTICAL) {
left.moveTo(transX1, transY1);
left.lineTo(transX1, transStack1);
left.lineTo(transXLeft, transStackLeft);
left.lineTo(transXLeft, transYLeft);
} else {
left.moveTo(transY1, transX1);
left.lineTo(transStack1, transX1);
left.lineTo(transStackLeft, transXLeft);
left.lineTo(transYLeft, transXLeft);
}
left.closePath();
} else {
if (orientation == PlotOrientation.VERTICAL) {
left.moveTo(transX1, transStack1);
left.lineTo(transX1, transY1);
left.lineTo(transXLeft, transStackLeft);
} else {
left.moveTo(transStack1, transX1);
left.lineTo(transY1, transX1);
left.lineTo(transStackLeft, transXLeft);
}
left.closePath();
}
float transStackRight = (float) rangeAxis.valueToJava2D(adjStackRight[1], dataArea, edge1);
// RIGHT POLYGON
if (y2 >= 0.0) {
double yright = (y1 + y2) / 2.0 + stackRight[1];
float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1);
if (orientation == PlotOrientation.VERTICAL) {
right.moveTo(transX1, transStack1);
right.lineTo(transX1, transY1);
right.lineTo(transXRight, transYRight);
right.lineTo(transXRight, transStackRight);
} else {
right.moveTo(transStack1, transX1);
right.lineTo(transY1, transX1);
right.lineTo(transYRight, transXRight);
right.lineTo(transStackRight, transXRight);
}
right.closePath();
} else {
if (orientation == PlotOrientation.VERTICAL) {
right.moveTo(transX1, transStack1);
right.lineTo(transX1, transY1);
right.lineTo(transXRight, transStackRight);
} else {
right.moveTo(transStack1, transX1);
right.lineTo(transY1, transX1);
right.lineTo(transStackRight, transXRight);
}
right.closePath();
}
} else {
// handle negative value
transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[0], dataArea, edge1);
float transStack1 = (float) rangeAxis.valueToJava2D(stack1[0], dataArea, edge1);
float transStackLeft = (float) rangeAxis.valueToJava2D(adjStackLeft[0], dataArea, edge1);
// LEFT POLYGON
if (y0 >= 0.0) {
if (orientation == PlotOrientation.VERTICAL) {
left.moveTo(transX1, transStack1);
left.lineTo(transX1, transY1);
left.lineTo(transXLeft, transStackLeft);
} else {
left.moveTo(transStack1, transX1);
left.lineTo(transY1, transX1);
left.lineTo(transStackLeft, transXLeft);
}
left.clone();
} else {
double yleft = (y0 + y1) / 2.0 + stackLeft[0];
float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1);
if (orientation == PlotOrientation.VERTICAL) {
left.moveTo(transX1, transY1);
left.lineTo(transX1, transStack1);
left.lineTo(transXLeft, transStackLeft);
left.lineTo(transXLeft, transYLeft);
} else {
left.moveTo(transY1, transX1);
left.lineTo(transStack1, transX1);
left.lineTo(transStackLeft, transXLeft);
left.lineTo(transYLeft, transXLeft);
}
left.closePath();
}
float transStackRight = (float) rangeAxis.valueToJava2D(adjStackRight[0], dataArea, edge1);
// RIGHT POLYGON
if (y2 >= 0.0) {
if (orientation == PlotOrientation.VERTICAL) {
right.moveTo(transX1, transStack1);
right.lineTo(transX1, transY1);
right.lineTo(transXRight, transStackRight);
} else {
right.moveTo(transStack1, transX1);
right.lineTo(transY1, transX1);
right.lineTo(transStackRight, transXRight);
}
right.closePath();
} else {
double yright = (y1 + y2) / 2.0 + stackRight[0];
float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1);
if (orientation == PlotOrientation.VERTICAL) {
right.moveTo(transX1, transStack1);
right.lineTo(transX1, transY1);
right.lineTo(transXRight, transYRight);
right.lineTo(transXRight, transStackRight);
} else {
right.moveTo(transStack1, transX1);
right.lineTo(transY1, transX1);
right.lineTo(transYRight, transXRight);
right.lineTo(transStackRight, transXRight);
}
right.closePath();
}
}
// Get series Paint and Stroke
Paint itemPaint = getItemPaint(series, item);
if (pass == 0) {
g2.setPaint(itemPaint);
g2.fill(left);
g2.fill(right);
}
// add an entity for the item...
if (entities != null) {
GeneralPath gp = new GeneralPath(left);
gp.append(right, false);
entityArea = gp;
addEntity(entities, entityArea, dataset, series, item, transX1, transY1);
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class XYShapeRenderer method drawItem.
/**
* Draws the block representing the specified item.
*
* @param g2 the graphics device.
* @param state the state.
* @param dataArea the data area.
* @param info the plot rendering info.
* @param plot the plot.
* @param domainAxis the x-axis.
* @param rangeAxis the y-axis.
* @param dataset the dataset.
* @param series the series index.
* @param item the item index.
* @param crosshairState the crosshair state.
* @param pass the pass index.
*/
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {
Shape hotspot;
EntityCollection entities = null;
if (info != null) {
entities = info.getOwner().getEntityCollection();
}
double x = dataset.getXValue(series, item);
double y = dataset.getYValue(series, item);
if (Double.isNaN(x) || Double.isNaN(y)) {
// can't draw anything
return;
}
double transX = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge());
double transY = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge());
PlotOrientation orientation = plot.getOrientation();
// draw optional guide lines
if ((pass == 0) && this.guideLinesVisible) {
g2.setStroke(this.guideLineStroke);
g2.setPaint(this.guideLinePaint);
if (orientation == PlotOrientation.HORIZONTAL) {
g2.draw(new Line2D.Double(transY, dataArea.getMinY(), transY, dataArea.getMaxY()));
g2.draw(new Line2D.Double(dataArea.getMinX(), transX, dataArea.getMaxX(), transX));
} else {
g2.draw(new Line2D.Double(transX, dataArea.getMinY(), transX, dataArea.getMaxY()));
g2.draw(new Line2D.Double(dataArea.getMinX(), transY, dataArea.getMaxX(), transY));
}
} else if (pass == 1) {
Shape shape = getItemShape(series, item);
if (orientation == PlotOrientation.HORIZONTAL) {
shape = ShapeUtilities.createTranslatedShape(shape, transY, transX);
} else if (orientation == PlotOrientation.VERTICAL) {
shape = ShapeUtilities.createTranslatedShape(shape, transX, transY);
}
hotspot = shape;
if (shape.intersects(dataArea)) {
// if (getItemShapeFilled(series, item)) {
g2.setPaint(getPaint(dataset, 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);
}
}
// add an entity for the item...
if (entities != null) {
addEntity(entities, hotspot, dataset, series, item, transX, transY);
}
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class XYDotRenderer method drawItem.
/**
* Draws the visual representation of a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area within which the data is being drawn.
* @param info collects information about the drawing.
* @param plot the plot (can be used to obtain standard color
* information etc).
* @param domainAxis the domain (horizontal) axis.
* @param rangeAxis the range (vertical) axis.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param crosshairState crosshair information for the plot
* (<code>null</code> permitted).
* @param pass the pass index.
*/
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {
// do nothing if item is not visible
if (!getItemVisible(series, item)) {
return;
}
// get the data point...
double x = dataset.getXValue(series, item);
double y = dataset.getYValue(series, item);
double adjx = (this.dotWidth - 1) / 2.0;
double adjy = (this.dotHeight - 1) / 2.0;
if (!Double.isNaN(y)) {
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation) - adjx;
double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) - adjy;
g2.setPaint(getItemPaint(series, item));
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
g2.fillRect((int) transY, (int) transX, this.dotHeight, this.dotWidth);
} else if (orientation == PlotOrientation.VERTICAL) {
g2.fillRect((int) transX, (int) transY, this.dotWidth, this.dotHeight);
}
int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation);
}
}
Aggregations