File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/StackedBarRenderer3D.java | File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/StackedBarRenderer3D.java | |||
Method name: void drawStackHorizontal(List, Comparable, Graphics2D, CategoryItemRendererState, Rectangle2D, CategoryPlot, CategoryAxis, ValueAxis, CategoryDataset)
|
Method name: void drawStackVertical(List, Comparable, Graphics2D, CategoryItemRendererState, Rectangle2D, CategoryPlot, CategoryAxis, ValueAxis, CategoryDataset)
|
|||
Number of AST nodes: 50 | Number of AST nodes: 50 | |||
1 | int column = dataset.getColumnIndex(category);↵ | 1 | int column = dataset.getColumnIndex(category);↵ | |
2 | double barX0 = domainAxis.getCategoryMiddle(column,↵ | 2 | double barX0 = domainAxis.getCategoryMiddle(column,↵ | |
3 | dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge())↵ | 3 | dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge())↵ | |
4 | - state.getBarWidth() / 2.0;↵ | 4 | - state.getBarWidth() / 2.0;↵ | |
5 | double barW = state.getBarWidth();↵ | 5 | double barW = state.getBarWidth();↵ | |
6 | // a list to store the series index and bar region, so we can draw↵ | 6 | // a list to store the series index and bar region, so we can draw↵ | |
7 | // all the labels at the end...↵ | 7 | // all the labels at the end...↵ | |
8 | List itemLabelList = new ArrayList();↵ | 8 | List itemLabelList = new ArrayList();↵ | |
9 | // draw the blocks↵ | 9 | // draw the blocks↵ | |
10 | boolean inverted = rangeAxis.isInverted();↵ | 10 | boolean inverted = rangeAxis.isInverted();↵ | |
11 | int blockCount = values.size() - 1;↵ | 11 | int blockCount = values.size() - 1;↵ | |
12 | for (int k = 0; k < blockCount; k++) {↵ | 12 | for (int k = 0; k < blockCount; k++) {↵ | |
13 | int index = (inverted ? blockCount - k - 1 : k);↵ | 13 | int index = (inverted ? blockCount - k - 1 : k);↵ | |
14 | Object[] prev = (Object[]) values.get(index);↵ | 14 | Object[] prev = (Object[]) values.get(index);↵ | |
15 | Object[] curr = (Object[]) values.get(index + 1);↵ | 15 | Object[] curr = (Object[]) values.get(index + 1);↵ | |
16 | int series = 0;↵ | 16 | int series = 0;↵ | |
17 | if (curr[0] == null) {↵ | 17 | if (curr[0] == null) {↵ | |
18 | series = -((Integer) prev[0]).intValue();↵ | 18 | series = -((Integer) prev[0]).intValue();↵ | |
19 | }↵ | 19 | }↵ | |
20 | else {↵ | 20 | else {↵ | |
21 | series = ((Integer) curr[0]).intValue();↵ | 21 | series = ((Integer) curr[0]).intValue();↵ | |
22 | if (series < 0) {↵ | 22 | if (series < 0) {↵ | |
23 | series = -((Integer) prev[0]).intValue();↵ | 23 | series = -((Integer) prev[0]).intValue();↵ | |
24 | }↵ | 24 | }↵ | |
25 | }↵ | 25 | }↵ | |
26 | double v0 = ((Double) prev[1]).doubleValue();↵ | 26 | double v0 = ((Double) prev[1]).doubleValue();↵ | |
27 | double vv0 = rangeAxis.valueToJava2D(v0, dataArea,↵ | 27 | double vv0 = rangeAxis.valueToJava2D(v0, dataArea,↵ | |
28 | plot.getRangeAxisEdge());↵ | 28 | plot.getRangeAxisEdge());↵ | |
29 | double v1 = ((Double) curr[1]).doubleValue();↵ | 29 | double v1 = ((Double) curr[1]).doubleValue();↵ | |
30 | double vv1 = rangeAxis.valueToJava2D(v1, dataArea,↵ | 30 | double vv1 = rangeAxis.valueToJava2D(v1, dataArea,↵ | |
31 | plot.getRangeAxisEdge());↵ | 31 | plot.getRangeAxisEdge());↵ | |
32 | Shape[] faces = createHorizontalBlock(barX0, barW, vv0, vv1,↵ | 32 | Shape[] faces = createVerticalBlock(barX0, barW, vv0, vv1,↵ | |
33 | inverted);↵ | 33 | inverted);↵ | |
34 | Paint fillPaint = getItemPaint(series, column);↵ | 34 | Paint fillPaint = getItemPaint(series, column);↵ | |
35 | Paint fillPaintDark = fillPaint;↵ | 35 | Paint fillPaintDark = fillPaint;↵ | |
36 | if (fillPaintDark instanceof Color) {↵ | 36 | if (fillPaintDark instanceof Color) {↵ | |
37 | fillPaintDark = ((Color) fillPaint).darker();↵ | 37 | fillPaintDark = ((Color) fillPaint).darker();↵ | |
38 | }↵ | 38 | }↵ | |
39 | boolean drawOutlines = isDrawBarOutline();↵ | 39 | boolean drawOutlines = isDrawBarOutline();↵ | |
40 | Paint outlinePaint = fillPaint;↵ | 40 | Paint outlinePaint = fillPaint;↵ | |
41 | if (drawOutlines) {↵ | 41 | if (drawOutlines) {↵ | |
42 | outlinePaint = getItemOutlinePaint(series, column);↵ | 42 | outlinePaint = getItemOutlinePaint(series, column);↵ | |
43 | g2.setStroke(getItemOutlineStroke(series, column));↵ | 43 | g2.setStroke(getItemOutlineStroke(series, column));↵ | |
44 | }↵ | 44 | }↵ | |
45 | for (int f = 0; f < 6; f++) {↵ | 45 | for (int f = 0; f < 6; f++) {↵ | |
46 | if (f == 5) {↵ | 46 | if (f == 5) {↵ | |
47 | g2.setPaint(fillPaint);↵ | 47 | g2.setPaint(fillPaint);↵ | |
48 | }↵ | 48 | }↵ | |
49 | else {↵ | 49 | else {↵ | |
50 | g2.setPaint(fillPaintDark);↵ | 50 | g2.setPaint(fillPaintDark);↵ | |
51 | }↵ | 51 | }↵ | |
52 | g2.fill(faces[f]);↵ | 52 | g2.fill(faces[f]);↵ | |
53 | if (drawOutlines) {↵ | 53 | if (drawOutlines) {↵ | |
54 | g2.setPaint(outlinePaint);↵ | 54 | g2.setPaint(outlinePaint);↵ | |
55 | g2.draw(faces[f]);↵ | 55 | g2.draw(faces[f]);↵ | |
56 | }↵ | 56 | }↵ | |
57 | }↵ | 57 | }↵ | |
58 | itemLabelList.add(new Object[] {new Integer(series),↵ | 58 | itemLabelList.add(new Object[] {new Integer(series),↵ | |
59 | faces[5].getBounds2D(),↵ | 59 | faces[5].getBounds2D(),↵ | |
60 | BooleanUtilities.valueOf(v0 < getBase())});↵ | 60 | BooleanUtilities.valueOf(v0 < getBase())});↵ | |
61 | // add an item entity, if this information is being collected↵ | 61 | // add an item entity, if this information is being collected↵ | |
62 | EntityCollection entities = state.getEntityCollection();↵ | 62 | EntityCollection entities = state.getEntityCollection();↵ | |
63 | if (entities != null) {↵ | 63 | if (entities != null) {↵ | |
64 | addItemEntity(entities, dataset, series, column, faces[5]);↵ | 64 | addItemEntity(entities, dataset, series, column, faces[5]);↵ | |
65 | }↵ | 65 | }↵ | |
66 | }↵ | 66 | }↵ | |
67 | for (int i = 0; i < itemLabelList.size(); i++) {↵ | 67 | for (int i = 0; i < itemLabelList.size(); i++) {↵ | |
68 | Object[] record = (Object[]) itemLabelList.get(i);↵ | 68 | Object[] record = (Object[]) itemLabelList.get(i);↵ | |
69 | int series = ((Integer) record[0]).intValue();↵ | 69 | int series = ((Integer) record[0]).intValue();↵ | |
70 | Rectangle2D bar = (Rectangle2D) record[1];↵ | 70 | Rectangle2D bar = (Rectangle2D) record[1];↵ | |
71 | boolean neg = ((Boolean) record[2]).booleanValue();↵ | 71 | boolean neg = ((Boolean) record[2]).booleanValue();↵ | |
72 | CategoryItemLabelGenerator generator↵ | 72 | CategoryItemLabelGenerator generator↵ | |
73 | = getItemLabelGenerator(series, column);↵ | 73 | = getItemLabelGenerator(series, column);↵ | |
74 | if (generator != null && isItemLabelVisible(series, column)) {↵ | 74 | if (generator != null && isItemLabelVisible(series, column)) {↵ | |
75 | drawItemLabel(g2, dataset, series, column, plot, generator,↵ | 75 | drawItemLabel(g2, dataset, series, column, plot, generator,↵ | |
76 | bar, neg);↵ | 76 | bar, neg);↵ | |
77 | }↵ | 77 | }↵ | |
78 | } | 78 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 8.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 410 |
Number of mapped statements | 50 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 151.1 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | int column = dataset.getColumnIndex(category); | 1 | int column = dataset.getColumnIndex(category); | |||||||||||||
2 | double barX0 = domainAxis.getCategoryMiddle(column, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; | 2 | double barX0 = domainAxis.getCategoryMiddle(column, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; | |||||||||||||
3 | double barW = state.getBarWidth(); | 3 | double barW = state.getBarWidth(); | |||||||||||||
4 | List itemLabelList = new ArrayList(); | 4 | List itemLabelList = new ArrayList(); | |||||||||||||
5 | boolean inverted = rangeAxis.isInverted(); | 5 | boolean inverted = rangeAxis.isInverted(); | |||||||||||||
6 | int blockCount = values.size() - 1; | 6 | int blockCount = values.size() - 1; | |||||||||||||
7 | for (int k = 0; k < blockCount; k++) | 7 | for (int k = 0; k < blockCount; k++) | |||||||||||||
8 | int index = (inverted ? blockCount - k - 1 : k); | 8 | int index = (inverted ? blockCount - k - 1 : k); | |||||||||||||
9 | Object[] prev = (Object[])values.get(index); | 9 | Object[] prev = (Object[])values.get(index); | |||||||||||||
10 | Object[] curr = (Object[])values.get(index + 1); | 10 | Object[] curr = (Object[])values.get(index + 1); | |||||||||||||
11 | int series = 0; | 11 | int series = 0; | |||||||||||||
12 | if (curr[0] == null) | 12 | if (curr[0] == null) | |||||||||||||
13 | series = -((Integer)prev[0]).intValue(); | 13 | series = -((Integer)prev[0]).intValue(); | |||||||||||||
else | else | |||||||||||||||
14 | series = ((Integer)curr[0]).intValue(); | 14 | series = ((Integer)curr[0]).intValue(); | |||||||||||||
15 | if (series < 0) | 15 | if (series < 0) | |||||||||||||
16 | series = -((Integer)prev[0]).intValue(); | 16 | series = -((Integer)prev[0]).intValue(); | |||||||||||||
17 | double v0 = ((Double)prev[1]).doubleValue(); | 17 | double v0 = ((Double)prev[1]).doubleValue(); | |||||||||||||
18 | double vv0 = rangeAxis.valueToJava2D(v0, dataArea, plot.getRangeAxisEdge()); | 18 | double vv0 = rangeAxis.valueToJava2D(v0, dataArea, plot.getRangeAxisEdge()); | |||||||||||||
19 | double v1 = ((Double)curr[1]).doubleValue(); | 19 | double v1 = ((Double)curr[1]).doubleValue(); | |||||||||||||
20 | double vv1 = rangeAxis.valueToJava2D(v1, dataArea, plot.getRangeAxisEdge()); | 20 | double vv1 = rangeAxis.valueToJava2D(v1, dataArea, plot.getRangeAxisEdge()); | |||||||||||||
21 | Shape[] faces = createHorizontalBlock(barX0, barW, vv0, vv1, inverted); |
| 21 | Shape[] faces = createVerticalBlock(barX0, barW, vv0, vv1, inverted); | ||||||||||||
22 | Paint fillPaint = getItemPaint(series, column); | 22 | Paint fillPaint = getItemPaint(series, column); | |||||||||||||
23 | Paint fillPaintDark = fillPaint; | 23 | Paint fillPaintDark = fillPaint; | |||||||||||||
24 | if (fillPaintDark instanceof Color) | 24 | if (fillPaintDark instanceof Color) | |||||||||||||
25 | fillPaintDark = ((Color)fillPaint).darker(); | 25 | fillPaintDark = ((Color)fillPaint).darker(); | |||||||||||||
26 | boolean drawOutlines = isDrawBarOutline(); | 26 | boolean drawOutlines = isDrawBarOutline(); | |||||||||||||
27 | Paint outlinePaint = fillPaint; | 27 | Paint outlinePaint = fillPaint; | |||||||||||||
28 | if (drawOutlines) | 28 | if (drawOutlines) | |||||||||||||
29 | outlinePaint = getItemOutlinePaint(series, column); | 29 | outlinePaint = getItemOutlinePaint(series, column); | |||||||||||||
30 | g2.setStroke(getItemOutlineStroke(series, column)); | 30 | g2.setStroke(getItemOutlineStroke(series, column)); | |||||||||||||
31 | for (int f = 0; f < 6; f++) | 31 | for (int f = 0; f < 6; f++) | |||||||||||||
32 | if (f == 5) | 32 | if (f == 5) | |||||||||||||
33 | g2.setPaint(fillPaint); | 33 | g2.setPaint(fillPaint); | |||||||||||||
else | else | |||||||||||||||
34 | g2.setPaint(fillPaintDark); | 34 | g2.setPaint(fillPaintDark); | |||||||||||||
35 | g2.fill(faces[f]); | 35 | g2.fill(faces[f]); | |||||||||||||
36 | if (drawOutlines) | 36 | if (drawOutlines) | |||||||||||||
37 | g2.setPaint(outlinePaint); | 37 | g2.setPaint(outlinePaint); | |||||||||||||
38 | g2.draw(faces[f]); | 38 | g2.draw(faces[f]); | |||||||||||||
39 | itemLabelList.add(new Object[] {new Integer(series), faces[5].getBounds2D(), BooleanUtilities.valueOf(v0 < getBase())}); | 39 | itemLabelList.add(new Object[] {new Integer(series), faces[5].getBounds2D(), BooleanUtilities.valueOf(v0 < getBase())}); | |||||||||||||
40 | EntityCollection entities = state.getEntityCollection(); | 40 | EntityCollection entities = state.getEntityCollection(); | |||||||||||||
41 | if (entities != null) | 41 | if (entities != null) | |||||||||||||
42 | addItemEntity(entities, dataset, series, column, faces[5]); | 42 | addItemEntity(entities, dataset, series, column, faces[5]); | |||||||||||||
43 | for (int i = 0; i < itemLabelList.size(); i++) | 43 | for (int i = 0; i < itemLabelList.size(); i++) | |||||||||||||
44 | Object[] record = (Object[])itemLabelList.get(i); | 44 | Object[] record = (Object[])itemLabelList.get(i); | |||||||||||||
45 | int series = ((Integer)record[0]).intValue(); | 45 | int series = ((Integer)record[0]).intValue(); | |||||||||||||
46 | Rectangle2D bar = (Rectangle2D)record[1]; | 46 | Rectangle2D bar = (Rectangle2D)record[1]; | |||||||||||||
47 | boolean neg = ((Boolean)record[2]).booleanValue(); | 47 | boolean neg = ((Boolean)record[2]).booleanValue(); | |||||||||||||
48 | CategoryItemLabelGenerator generator = getItemLabelGenerator(series, column); | 48 | CategoryItemLabelGenerator generator = getItemLabelGenerator(series, column); | |||||||||||||
49 | if (generator != null && isItemLabelVisible(series, column)) | 49 | if (generator != null && isItemLabelVisible(series, column)) | |||||||||||||
50 | drawItemLabel(g2, dataset, series, column, plot, generator, bar, neg); | 50 | drawItemLabel(g2, dataset, series, column, plot, generator, bar, neg); |
Row | Violation |
---|---|
1 | Expression createHorizontalBlock(barX0,barW,vv0,vv1,inverted) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression createVerticalBlock(barX0,barW,vv0,vv1,inverted) cannot be parameterized, because it has dependencies to/from statements that will be extracted |