use of org.jfree.chart.labels.CategoryItemLabelGenerator in project SIMVA-SoS by SESoS.
the class StackedBarRenderer3D method drawStackVertical.
/**
* Draws a stack of bars for one category, with a vertical orientation.
*
* @param values the value list.
* @param category the category.
* @param g2 the graphics device.
* @param state the state.
* @param dataArea the data area (adjusted for the 3D effect).
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
*
* @since 1.0.4
*/
protected void drawStackVertical(List values, Comparable category, Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset) {
int column = dataset.getColumnIndex(category);
double barX0 = domainAxis.getCategoryMiddle(column, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0;
double barW = state.getBarWidth();
// a list to store the series index and bar region, so we can draw
// all the labels at the end...
List itemLabelList = new ArrayList();
// draw the blocks
boolean inverted = rangeAxis.isInverted();
int blockCount = values.size() - 1;
for (int k = 0; k < blockCount; k++) {
int index = (inverted ? blockCount - k - 1 : k);
Object[] prev = (Object[]) values.get(index);
Object[] curr = (Object[]) values.get(index + 1);
int series;
if (curr[0] == null) {
series = -((Integer) prev[0]).intValue() - 1;
} else {
series = ((Integer) curr[0]).intValue();
if (series < 0) {
series = -((Integer) prev[0]).intValue() - 1;
}
}
double v0 = ((Double) prev[1]).doubleValue();
double vv0 = rangeAxis.valueToJava2D(v0, dataArea, plot.getRangeAxisEdge());
double v1 = ((Double) curr[1]).doubleValue();
double vv1 = rangeAxis.valueToJava2D(v1, dataArea, plot.getRangeAxisEdge());
Shape[] faces = createVerticalBlock(barX0, barW, vv0, vv1, inverted);
Paint fillPaint = getItemPaint(series, column);
Paint fillPaintDark = PaintAlpha.darker(fillPaint);
boolean drawOutlines = isDrawBarOutline();
Paint outlinePaint = fillPaint;
if (drawOutlines) {
outlinePaint = getItemOutlinePaint(series, column);
g2.setStroke(getItemOutlineStroke(series, column));
}
for (int f = 0; f < 6; f++) {
if (f == 5) {
g2.setPaint(fillPaint);
} else {
g2.setPaint(fillPaintDark);
}
g2.fill(faces[f]);
if (drawOutlines) {
g2.setPaint(outlinePaint);
g2.draw(faces[f]);
}
}
itemLabelList.add(new Object[] { new Integer(series), faces[5].getBounds2D(), BooleanUtilities.valueOf(v0 < getBase()) });
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, series, column, faces[5]);
}
}
for (int i = 0; i < itemLabelList.size(); i++) {
Object[] record = (Object[]) itemLabelList.get(i);
int series = ((Integer) record[0]).intValue();
Rectangle2D bar = (Rectangle2D) record[1];
boolean neg = ((Boolean) record[2]).booleanValue();
CategoryItemLabelGenerator generator = getItemLabelGenerator(series, column);
if (generator != null && isItemLabelVisible(series, column)) {
drawItemLabel(g2, dataset, series, column, plot, generator, bar, neg);
}
}
}
use of org.jfree.chart.labels.CategoryItemLabelGenerator in project SIMVA-SoS by SESoS.
the class IntervalBarRenderer method drawInterval.
/**
* Draws a single interval.
*
* @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 drawInterval(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, IntervalCategoryDataset dataset, int row, int column) {
int visibleRow = state.getVisibleSeriesIndex(row);
if (visibleRow < 0) {
return;
}
PlotOrientation orientation = plot.getOrientation();
double rectX = 0.0;
double rectY = 0.0;
RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();
// Y0
Number value0 = dataset.getEndValue(row, column);
if (value0 == null) {
return;
}
double java2dValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), dataArea, rangeAxisLocation);
// Y1
Number value1 = dataset.getStartValue(row, column);
if (value1 == null) {
return;
}
double java2dValue1 = rangeAxis.valueToJava2D(value1.doubleValue(), dataArea, rangeAxisLocation);
if (java2dValue1 < java2dValue0) {
double temp = java2dValue1;
java2dValue1 = java2dValue0;
java2dValue0 = temp;
}
// BAR WIDTH
double rectWidth = state.getBarWidth();
// BAR HEIGHT
double rectHeight = Math.abs(java2dValue1 - java2dValue0);
RectangleEdge barBase = RectangleEdge.LEFT;
if (orientation == PlotOrientation.HORIZONTAL) {
// BAR Y
rectX = java2dValue0;
rectY = calculateBarW0(getPlot(), orientation, dataArea, domainAxis, state, visibleRow, column);
rectHeight = state.getBarWidth();
rectWidth = Math.abs(java2dValue1 - java2dValue0);
barBase = RectangleEdge.LEFT;
} else if (orientation == PlotOrientation.VERTICAL) {
// BAR X
rectX = calculateBarW0(getPlot(), orientation, dataArea, domainAxis, state, visibleRow, column);
rectY = java2dValue0;
barBase = RectangleEdge.BOTTOM;
}
Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight);
BarPainter painter = getBarPainter();
if (getShadowsVisible()) {
painter.paintBarShadow(g2, this, row, column, bar, barBase, false);
}
getBarPainter().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, false);
}
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, row, column, bar);
}
}
Aggregations