use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class AbstractCategoryItemRenderer method drawRangeLine.
/**
* Draws a line perpendicular to the range axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the value axis.
* @param dataArea the area for plotting data (not yet adjusted for any 3D
* effect).
* @param value the value at which the grid line should be drawn.
* @param paint the paint (<code>null</code> not permitted).
* @param stroke the stroke (<code>null</code> not permitted).
*
* @see #drawRangeGridline
*
* @since 1.0.13
*/
public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {
// TODO: In JFreeChart 1.2.0, put this method in the
// CategoryItemRenderer interface
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
} else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
}
g2.setPaint(paint);
g2.setStroke(stroke);
Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g2.draw(line);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved);
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class AbstractCategoryItemRenderer method drawDomainMarker.
/**
* Draws a marker for the domain axis.
*
* @param g2 the graphics device (not <code>null</code>).
* @param plot the plot (not <code>null</code>).
* @param axis the range axis (not <code>null</code>).
* @param marker the marker to be drawn (not <code>null</code>).
* @param dataArea the area inside the axes (not <code>null</code>).
*
* @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker,
* Rectangle2D)
*/
@Override
public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea) {
Comparable category = marker.getKey();
CategoryDataset dataset = plot.getDataset(plot.getIndexOf(this));
int columnIndex = dataset.getColumnIndex(category);
if (columnIndex < 0) {
return;
}
final Composite savedComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha()));
PlotOrientation orientation = plot.getOrientation();
Rectangle2D bounds;
if (marker.getDrawAsLine()) {
double v = axis.getCategoryMiddle(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge());
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
} else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
} else {
throw new IllegalStateException();
}
g2.setPaint(marker.getPaint());
g2.setStroke(marker.getStroke());
g2.draw(line);
bounds = line.getBounds2D();
} else {
double v0 = axis.getCategoryStart(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge());
double v1 = axis.getCategoryEnd(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge());
Rectangle2D area = null;
if (orientation == PlotOrientation.HORIZONTAL) {
area = new Rectangle2D.Double(dataArea.getMinX(), v0, dataArea.getWidth(), (v1 - v0));
} else if (orientation == PlotOrientation.VERTICAL) {
area = new Rectangle2D.Double(v0, dataArea.getMinY(), (v1 - v0), dataArea.getHeight());
}
g2.setPaint(marker.getPaint());
g2.fill(area);
bounds = area;
}
String label = marker.getLabel();
RectangleAnchor anchor = marker.getLabelAnchor();
if (label != null) {
Font labelFont = marker.getLabelFont();
g2.setFont(labelFont);
g2.setPaint(marker.getLabelPaint());
Point2D coordinates = calculateDomainMarkerTextAnchorPoint(g2, orientation, dataArea, bounds, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor);
TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor());
}
g2.setComposite(savedComposite);
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class BarRenderer method drawItem.
/**
* Draws the bar for a single (series, category) data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the data area.
* @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) {
// nothing is drawn if the row index is not included in the list with
// the indices of the visible rows...
int visibleRow = state.getVisibleSeriesIndex(row);
if (visibleRow < 0) {
return;
}
// nothing is drawn for null values...
Number dataValue = dataset.getValue(row, column);
if (dataValue == null) {
return;
}
final double value = dataValue.doubleValue();
PlotOrientation orientation = plot.getOrientation();
double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, state, visibleRow, column);
double[] barL0L1 = calculateBarL0L1(value);
if (barL0L1 == null) {
// the bar is not visible
return;
}
RectangleEdge edge = plot.getRangeAxisEdge();
double transL0 = rangeAxis.valueToJava2D(barL0L1[0], dataArea, edge);
double transL1 = rangeAxis.valueToJava2D(barL0L1[1], dataArea, edge);
// in the following code, barL0 is (in Java2D coordinates) the LEFT
// end of the bar for a horizontal bar chart, and the TOP end of the
// bar for a vertical bar chart. Whether this is the BASE of the bar
// or not depends also on (a) whether the data value is 'negative'
// relative to the base value and (b) whether or not the range axis is
// inverted. This only matters if/when we apply the minimumBarLength
// attribute, because we should extend the non-base end of the bar
boolean positive = (value >= this.base);
boolean inverted = rangeAxis.isInverted();
double barL0 = Math.min(transL0, transL1);
double barLength = Math.abs(transL1 - transL0);
double barLengthAdj = 0.0;
if (barLength > 0.0 && barLength < getMinimumBarLength()) {
barLengthAdj = getMinimumBarLength() - barLength;
}
double barL0Adj = 0.0;
RectangleEdge barBase;
if (orientation == PlotOrientation.HORIZONTAL) {
if (positive && inverted || !positive && !inverted) {
barL0Adj = barLengthAdj;
barBase = RectangleEdge.RIGHT;
} else {
barBase = RectangleEdge.LEFT;
}
} else {
if (positive && !inverted || !positive && inverted) {
barL0Adj = barLengthAdj;
barBase = RectangleEdge.BOTTOM;
} else {
barBase = RectangleEdge.TOP;
}
}
// draw the bar...
Rectangle2D bar;
if (orientation == PlotOrientation.HORIZONTAL) {
bar = new Rectangle2D.Double(barL0 - barL0Adj, barW0, barLength + barLengthAdj, state.getBarWidth());
} else {
bar = new Rectangle2D.Double(barW0, barL0 - barL0Adj, state.getBarWidth(), barLength + barLengthAdj);
}
if (getShadowsVisible()) {
this.barPainter.paintBarShadow(g2, this, row, column, bar, barBase, true);
}
this.barPainter.paintBar(g2, this, row, column, bar, barBase);
CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column);
if (generator != null && isItemLabelVisible(row, column)) {
drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0));
}
// submit the current data point as a crosshair candidate
int datasetIndex = plot.indexOf(dataset);
updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value, datasetIndex, barW0, barL0, orientation);
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, row, column, bar);
}
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class AbstractXYItemRenderer method drawRangeLine.
/**
* Draws a line perpendicular to the range axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the value axis.
* @param dataArea the area for plotting data (not yet adjusted for any 3D
* effect).
* @param value the value at which the grid line should be drawn.
* @param paint the paint.
* @param stroke the stroke.
*/
@Override
public void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
} else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
}
g2.setPaint(paint);
g2.setStroke(stroke);
Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g2.draw(line);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved);
}
use of org.jfree.chart.plot.PlotOrientation in project SIMVA-SoS by SESoS.
the class AbstractXYItemRenderer method drawDomainLine.
/**
* Draws a line perpendicular to the domain axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the value axis.
* @param dataArea the area for plotting data (not yet adjusted for any 3D
* effect).
* @param value the value at which the grid line should be drawn.
* @param paint the paint (<code>null</code> not permitted).
* @param stroke the stroke (<code>null</code> not permitted).
*
* @since 1.0.5
*/
public void drawDomainLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
double v = axis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge());
if (orientation.isHorizontal()) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
} else if (orientation.isVertical()) {
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
}
g2.setPaint(paint);
g2.setStroke(stroke);
Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g2.draw(line);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved);
}
Aggregations