use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class BarRenderer3D method drawDomainGridline.
/**
* Draws a grid line against the domain axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area for plotting data (not yet adjusted for any
* 3D effect).
* @param value the Java2D value at which the grid line should be drawn.
*/
@Override
public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value) {
Line2D line1 = null;
Line2D line2 = null;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
double y0 = value;
double y1 = value - getYOffset();
double x0 = dataArea.getMinX();
double x1 = x0 + getXOffset();
double x2 = dataArea.getMaxX();
line1 = new Line2D.Double(x0, y0, x1, y1);
line2 = new Line2D.Double(x1, y1, x2, y1);
} else if (orientation == PlotOrientation.VERTICAL) {
double x0 = value;
double x1 = value + getXOffset();
double y0 = dataArea.getMaxY();
double y1 = y0 - getYOffset();
double y2 = dataArea.getMinY();
line1 = new Line2D.Double(x0, y0, x1, y1);
line2 = new Line2D.Double(x1, y1, x1, y2);
}
Paint paint = plot.getDomainGridlinePaint();
Stroke stroke = plot.getDomainGridlineStroke();
g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
g2.draw(line1);
g2.draw(line2);
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class LineRenderer3D method drawRangeMarker.
/**
* Draws a range marker.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the value axis.
* @param marker the marker.
* @param dataArea the area for plotting data (not including 3D effect).
*/
@Override
public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea) {
Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset());
if (marker instanceof ValueMarker) {
ValueMarker vm = (ValueMarker) marker;
double value = vm.getValue();
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
GeneralPath path = null;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
float x = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge());
float y = (float) adjusted.getMaxY();
path = new GeneralPath();
path.moveTo(x, y);
path.lineTo((float) (x + getXOffset()), y - (float) getYOffset());
path.lineTo((float) (x + getXOffset()), (float) (adjusted.getMinY() - getYOffset()));
path.lineTo(x, (float) adjusted.getMinY());
path.closePath();
} else if (orientation == PlotOrientation.VERTICAL) {
float y = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge());
float x = (float) dataArea.getX();
path = new GeneralPath();
path.moveTo(x, y);
path.lineTo(x + (float) this.xOffset, y - (float) this.yOffset);
path.lineTo((float) (adjusted.getMaxX() + this.xOffset), y - (float) this.yOffset);
path.lineTo((float) (adjusted.getMaxX()), y);
path.closePath();
}
g2.setPaint(marker.getPaint());
g2.fill(path);
g2.setPaint(marker.getOutlinePaint());
g2.draw(path);
} else {
super.drawRangeMarker(g2, plot, axis, marker, adjusted);
// TODO: draw the interval marker with a 3D effect
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class ScatterRenderer method drawItem.
/**
* Draw a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area in which the data is drawn.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
* @param pass the pass index.
*/
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {
// do nothing if item is not visible
if (!getItemVisible(row, column)) {
return;
}
int visibleRow = state.getVisibleSeriesIndex(row);
if (visibleRow < 0) {
return;
}
int visibleRowCount = state.getVisibleSeriesCount();
PlotOrientation orientation = plot.getOrientation();
MultiValueCategoryDataset d = (MultiValueCategoryDataset) dataset;
List values = d.getValues(row, column);
if (values == null) {
return;
}
int valueCount = values.size();
for (int i = 0; i < valueCount; i++) {
// current data point...
double x1;
if (this.useSeriesOffset) {
x1 = domainAxis.getCategorySeriesMiddle(column, dataset.getColumnCount(), visibleRow, visibleRowCount, this.itemMargin, dataArea, plot.getDomainAxisEdge());
} else {
x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
}
Number n = (Number) values.get(i);
double value = n.doubleValue();
double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
Shape shape = getItemShape(row, column);
if (orientation == PlotOrientation.HORIZONTAL) {
shape = ShapeUtilities.createTranslatedShape(shape, y1, x1);
} else if (orientation == PlotOrientation.VERTICAL) {
shape = ShapeUtilities.createTranslatedShape(shape, x1, y1);
}
if (getItemShapeFilled(row, column)) {
if (this.useFillPaint) {
g2.setPaint(getItemFillPaint(row, column));
} else {
g2.setPaint(getItemPaint(row, column));
}
g2.fill(shape);
}
if (this.drawOutlines) {
if (this.useOutlinePaint) {
g2.setPaint(getItemOutlinePaint(row, column));
} else {
g2.setPaint(getItemPaint(row, column));
}
g2.setStroke(getItemOutlineStroke(row, column));
g2.draw(shape);
}
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class CategoryStepRenderer method drawItem.
/**
* Draw a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area in which the data is drawn.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
* @param pass the pass index.
*/
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {
// do nothing if item is not visible
if (!getItemVisible(row, column)) {
return;
}
Number value = dataset.getValue(row, column);
if (value == null) {
return;
}
PlotOrientation orientation = plot.getOrientation();
// current data point...
double x1s = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
// or: x1s + 2*(x1-x1s)
double x1e = 2 * x1 - x1s;
double y1 = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, plot.getRangeAxisEdge());
g2.setPaint(getItemPaint(row, column));
g2.setStroke(getItemStroke(row, column));
if (column != 0) {
Number previousValue = dataset.getValue(row, column - 1);
if (previousValue != null) {
// previous data point...
double previous = previousValue.doubleValue();
double x0s = domainAxis.getCategoryStart(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge());
double x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge());
// or: x0s + 2*(x0-x0s)
double x0e = 2 * x0 - x0s;
double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge());
if (getStagger()) {
int xStagger = row * STAGGER_WIDTH;
if (xStagger > (x1s - x0e)) {
xStagger = (int) (x1s - x0e);
}
x1s = x0e + xStagger;
}
drawLine(g2, (State) state, orientation, x0e, y0, x1s, y0);
// extend x0's flat bar
drawLine(g2, (State) state, orientation, x1s, y0, x1s, y1);
// upright bar
}
}
drawLine(g2, (State) state, orientation, x1s, y1, x1e, y1);
// draw the item labels if there are any...
if (isItemLabelVisible(row, column)) {
drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value.doubleValue() < 0.0));
}
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
Rectangle2D hotspot = new Rectangle2D.Double();
if (orientation == PlotOrientation.VERTICAL) {
hotspot.setRect(x1s, y1, x1e - x1s, 4.0);
} else {
hotspot.setRect(y1 - 2.0, x1s, 4.0, x1e - x1s);
}
addItemEntity(entities, dataset, row, column, hotspot);
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class GanttRenderer method drawTasks.
/**
* Draws the tasks/subtasks for one item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the data plot area.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the data.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
*/
protected void drawTasks(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, GanttCategoryDataset dataset, int row, int column) {
int count = dataset.getSubIntervalCount(row, column);
if (count == 0) {
drawTask(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column);
}
PlotOrientation orientation = plot.getOrientation();
for (int subinterval = 0; subinterval < count; subinterval++) {
RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();
// value 0
Number value0 = dataset.getStartValue(row, column, subinterval);
if (value0 == null) {
return;
}
double translatedValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), dataArea, rangeAxisLocation);
// value 1
Number value1 = dataset.getEndValue(row, column, subinterval);
if (value1 == null) {
return;
}
double translatedValue1 = rangeAxis.valueToJava2D(value1.doubleValue(), dataArea, rangeAxisLocation);
if (translatedValue1 < translatedValue0) {
double temp = translatedValue1;
translatedValue1 = translatedValue0;
translatedValue0 = temp;
}
double rectStart = calculateBarW0(plot, plot.getOrientation(), dataArea, domainAxis, state, row, column);
double rectLength = Math.abs(translatedValue1 - translatedValue0);
double rectBreadth = state.getBarWidth();
// DRAW THE BARS...
Rectangle2D bar = null;
RectangleEdge barBase = null;
if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
bar = new Rectangle2D.Double(translatedValue0, rectStart, rectLength, rectBreadth);
barBase = RectangleEdge.LEFT;
} else if (plot.getOrientation() == PlotOrientation.VERTICAL) {
bar = new Rectangle2D.Double(rectStart, translatedValue0, rectBreadth, rectLength);
barBase = RectangleEdge.BOTTOM;
}
Rectangle2D completeBar = null;
Rectangle2D incompleteBar = null;
Number percent = dataset.getPercentComplete(row, column, subinterval);
double start = getStartPercent();
double end = getEndPercent();
if (percent != null) {
double p = percent.doubleValue();
if (orientation == PlotOrientation.HORIZONTAL) {
completeBar = new Rectangle2D.Double(translatedValue0, rectStart + start * rectBreadth, rectLength * p, rectBreadth * (end - start));
incompleteBar = new Rectangle2D.Double(translatedValue0 + rectLength * p, rectStart + start * rectBreadth, rectLength * (1 - p), rectBreadth * (end - start));
} else if (orientation == PlotOrientation.VERTICAL) {
completeBar = new Rectangle2D.Double(rectStart + start * rectBreadth, translatedValue0 + rectLength * (1 - p), rectBreadth * (end - start), rectLength * p);
incompleteBar = new Rectangle2D.Double(rectStart + start * rectBreadth, translatedValue0, rectBreadth * (end - start), rectLength * (1 - p));
}
}
if (getShadowsVisible()) {
getBarPainter().paintBarShadow(g2, this, row, column, bar, barBase, true);
}
getBarPainter().paintBar(g2, this, row, column, bar, barBase);
if (completeBar != null) {
g2.setPaint(getCompletePaint());
g2.fill(completeBar);
}
if (incompleteBar != null) {
g2.setPaint(getIncompletePaint());
g2.fill(incompleteBar);
}
if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
g2.setStroke(getItemStroke(row, column));
g2.setPaint(getItemOutlinePaint(row, column));
g2.draw(bar);
}
if (subinterval == count - 1) {
// submit the current data point as a crosshair candidate
int datasetIndex = plot.indexOf(dataset);
Comparable columnKey = dataset.getColumnKey(column);
Comparable rowKey = dataset.getRowKey(row);
double xx = domainAxis.getCategorySeriesMiddle(columnKey, rowKey, dataset, getItemMargin(), dataArea, plot.getDomainAxisEdge());
updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value1.doubleValue(), datasetIndex, xx, translatedValue1, orientation);
}
// collect entity and tool tip information...
if (state.getInfo() != null) {
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, row, column, bar);
}
}
}
}
Aggregations