1 | Number dataValue = dataset.getValue(row, column);↵ | | 1 | Number dataValue = dataset.getValue(row, column);↵
|
2 | if (dataValue == null) {↵ | | 2 | if (dataValue == null) {↵
|
3 | return;↵ | | 3 | return;↵
|
4 | }↵ | | 4 | }↵
|
|
5 | double value = dataValue.doubleValue();↵ | | 5 | double value = dataValue.doubleValue();↵
|
6 | Comparable group = this.seriesToGroupMap.getGroup(↵ | | 6 | ↵
|
7 | dataset.getRowKey(row));↵ | | 7 | double total = 0.0; // only needed if calculating percentages↵
|
| | | 8 | if (this.renderAsPercentages) {↵
|
| | | 9 | total = DataUtilities.calculateColumnTotal(dataset, column);↵
|
| | | 10 | value = value / total;↵
|
| | | 11 | }↵
|
|
8 | PlotOrientation orientation = plot.getOrientation();↵ | | 12 | PlotOrientation orientation = plot.getOrientation();↵
|
9 | double barW0 = calculateBarW0(plot, orientation,↵ | | 13 | double barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(),↵
|
10 | dataArea, domainAxis,↵ | | 14 | dataArea, plot.getDomainAxisEdge())↵
|
11 | state, row, column);↵ | | 15 | - state.getBarWidth() / 2.0;↵
|
|
12 | double positiveBase = 0.0;↵ | | 16 | double positiveBase = getBase();↵
|
13 | double negativeBase = 0.0;↵ | | 17 | double negativeBase = positiveBase;↵
|
|
14 | for (int i = 0; i < row; i++) {↵ | | 18 | for (int i = 0; i < row; i++) {↵
|
15 | if (group.equals(this.seriesToGroupMap.getGroup(↵ | | 19 | ↵
|
16 | dataset.getRowKey(i)))↵ | | 20 | Number v = dataset.getValue(i, column);↵
|
17 | ) {↵ | | 21 | if (v != null) {↵
|
18 | Number v = dataset.getValue(i, column);↵ | | 22 | ↵
|
19 | if (v != null↵ | | 23 | double d = v.doubleValue();↵
|
20 | ) {↵ | | 24 | if (this.renderAsPercentages) {↵
|
21 | double d = v.doubleValue();↵ | | 25 | d↵
|
22 | ↵ | | 26 | = d / total;↵
|
| | | 27 | }↵
|
23 | if (d > 0) {↵ | | 28 | if (d > 0) {↵
|
24 | positiveBase = positiveBase + d;↵ | | 29 | positiveBase = positiveBase + d;↵
|
25 | }↵ | | 30 | }↵
|
26 | else {↵ | | 31 | else {↵
|
27 | negativeBase = negativeBase + d;↵ | | 32 | negativeBase = negativeBase + d;↵
|
28 | }↵ | | |
|
29 | }↵ | | 33 | }↵
|
30 | }↵ | | 34 | }↵
|
31 | }↵ | | 35 | }↵
|
|
32 | double translatedBase;↵ | | 36 | double translatedBase;↵
|
33 | double translatedValue;↵ | | 37 | double translatedValue;↵
|
34 | RectangleEdge location = plot.getRangeAxisEdge();↵ | | 38 | RectangleEdge location = plot.getRangeAxisEdge();↵
|
35 | if (value > 0.0) {↵ | | 39 | if (value >= 0.0) {↵
|
36 | translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea,↵ | | 40 | translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea,↵
|
37 | location);↵ | | 41 | location);↵
|
38 | translatedValue = rangeAxis.valueToJava2D(positiveBase + value,↵ | | 42 | translatedValue = rangeAxis.valueToJava2D(positiveBase + value,↵
|
39 | dataArea, location);↵ | | 43 | dataArea, location);↵
|
40 | }↵ | | 44 | }↵
|
41 | else {↵ | | 45 | else {↵
|
42 | translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea,↵ | | 46 | translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea,↵
|
43 | location);↵ | | 47 | location);↵
|
44 | translatedValue = rangeAxis.valueToJava2D(negativeBase + value,↵ | | 48 | translatedValue = rangeAxis.valueToJava2D(negativeBase + value,↵
|
45 | dataArea, location);↵ | | 49 | dataArea, location);↵
|
46 | }↵ | | 50 | }↵
|
47 | double barL0 = Math.min(translatedBase, translatedValue);↵ | | 51 | double barL0 = Math.min(translatedBase, translatedValue);↵
|
48 | double barLength = Math.max(Math.abs(translatedValue - translatedBase),↵ | | 52 | double barLength = Math.max(Math.abs(translatedValue - translatedBase),↵
|
49 | getMinimumBarLength());↵ | | 53 | getMinimumBarLength());↵
|
|
50 | Rectangle2D bar = null;↵ | | 54 | Rectangle2D bar = null;↵
|
51 | if (orientation == PlotOrientation.HORIZONTAL) {↵ | | 55 | if (orientation == PlotOrientation.HORIZONTAL) {↵
|
52 | bar = new Rectangle2D.Double(barL0, barW0, barLength,↵ | | 56 | bar = new Rectangle2D.Double(barL0, barW0, barLength,↵
|
53 | state.getBarWidth());↵ | | 57 | state.getBarWidth());↵
|
54 | }↵ | | 58 | }↵
|
55 | else {↵ | | 59 | else {↵
|
56 | bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(),↵ | | 60 | bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(),↵
|
57 | barLength);↵ | | 61 | barLength);↵
|
58 | }↵ | | 62 | }↵
|
| | | 63 | if (pass == 0) {↵
|
59 | Paint itemPaint = getItemPaint(row, column);↵ | | 64 | Paint itemPaint = getItemPaint(row, column);↵
|
60 | if (getGradientPaintTransformer() != null↵ | | 65 | GradientPaintTransformer t = getGradientPaintTransformer();↵
|
61 | && itemPaint instanceof GradientPaint) {↵ | | 66 | if (t != null && itemPaint instanceof GradientPaint) {↵
|
62 | GradientPaint gp = (GradientPaint) itemPaint;↵ | | 67 | itemPaint = t.transform((GradientPaint) itemPaint, bar);↵
|
63 | itemPaint = getGradientPaintTransformer().transform(gp, bar);↵ | | 68 | }↵
|
64 | }↵ | | 69 | ↵
|
65 | g2.setPaint(itemPaint);↵ | | 70 | g2.setPaint(itemPaint);↵
|
66 | g2.fill(bar);↵ | | 71 | g2.fill(bar);↵
|
67 | if (isDrawBarOutline()↵ | | 72 | if (isDrawBarOutline()↵
|
68 | && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {↵ | | 73 | && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {↵
|
69 | g2.setStroke(getItemStroke(row, column));↵ | | 74 | g2.setStroke(getItemOutlineStroke(row, column));↵
|
70 | g2.setPaint(getItemOutlinePaint(row, column));↵ | | 75 | g2.setPaint(getItemOutlinePaint(row, column));↵
|
71 | g2.draw(bar);↵ | | 76 | g2.draw(bar);↵
|
72 | }↵ | | 77 | }↵
|
|
73 | CategoryItemLabelGenerator generator = getItemLabelGenerator(row,↵ | | 78 | ↵
|
74 | column);↵ | | |
|
| | | 79 | // add an item entity, if this information is being collected↵
|
| | | 80 | EntityCollection entities = state.getEntityCollection();↵
|
75 | if (generator != null && isItemLabelVisible(row, column)) {↵ | | 81 | if (entities != null↵
|
76 | drawItemLabel(g2↵ | | 82 | ) {↵
|
77 | , dataset, row, column, plot, generator, bar,↵ | | 83 | addItemEntity(entities, dataset, row, column, ↵
|
78 | (value < 0.0));↵ | | 84 | bar);↵
|
| | | 85 | }↵
|
79 | }↵ | | 86 | }↵
|
|
80 | // collect entity and tool tip information...↵ | | 87 | else if (pass == 1) {↵
|
81 | if (state.getInfo() != null) {↵ | | 88 | ↵
|
82 | EntityCollection entities = state.getEntityCollection(↵ | | 89 | CategoryItemLabelGenerator generator = getItemLabelGenerator(row,↵
|
83 | );↵ | | 90 | column);↵
|
84 | if (entities != null) {↵ | | 91 | if (generator != null↵
|
85 | addItemEntity(entities, dataset, row, column, bar↵ | | 92 | && isItemLabelVisible(row, column)) {↵
|
| | | 93 | drawItemLabel(g2, dataset, row, column, plot, generator, bar,↵
|
86 | );↵ | | 94 | (value < 0.0));↵
|
87 | }↵ | | 95 | }↵
|
88 | } | | 96 | }
|