File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/SymbolAxis.java | File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/SymbolAxis.java | |||
Method name: List refreshTicksHorizontal(Graphics2D, Rectangle2D, RectangleEdge)
|
Method name: List refreshTicksVertical(Graphics2D, Rectangle2D, RectangleEdge)
|
|||
Number of AST nodes: 35 | Number of AST nodes: 35 | |||
1 | for (int i = 0; i < count; i++) {↵ | 1 | for (int i = 0; i < count; i++) {↵ | |
2 | double currentTickValue = lowestTickValue + (i * size);↵ | 2 | double currentTickValue = lowestTickValue + (i * size);↵ | |
3 | double xx = valueToJava2D(currentTickValue, dataArea, edge);↵ | 3 | double yy = valueToJava2D(currentTickValue, dataArea, edge);↵ | |
4 | String tickLabel;↵ | 4 | String tickLabel;↵ | |
5 | NumberFormat formatter = getNumberFormatOverride();↵ | 5 | NumberFormat formatter = getNumberFormatOverride();↵ | |
6 | if (formatter != null) {↵ | 6 | if (formatter != null) {↵ | |
7 | tickLabel = formatter.format(currentTickValue);↵ | 7 | tickLabel = formatter.format(currentTickValue);↵ | |
8 | }↵ | 8 | }↵ | |
9 | else {↵ | 9 | else {↵ | |
10 | tickLabel = valueToString(currentTickValue);↵ | 10 | tickLabel = valueToString(currentTickValue);↵ | |
11 | }↵ | 11 | }↵ | |
12 | ↵ | |||
13 | // avoid to draw overlapping tick labels↵ | 12 | // avoid to draw overlapping tick labels↵ | |
14 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, ↵ | 13 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2,↵ | |
15 | g2.getFontMetrics());↵ | 14 | g2.getFontMetrics());↵ | |
16 | double tickLabelLength = isVerticalTickLabels() ↵ | 15 | double tickLabelLength = isVerticalTickLabels() ↵ | |
17 | ? bounds.getHeight() : bounds.getWidth();↵ | 16 | ? bounds.getWidth() : bounds.getHeight();↵ | |
18 | boolean tickLabelsOverlapping = false;↵ | 17 | boolean tickLabelsOverlapping = false;↵ | |
19 | if (i > 0) {↵ | 18 | if (i > 0) {↵ | |
20 | double avgTickLabelLength = (previousDrawnTickLabelLength ↵ | 19 | double avgTickLabelLength = (previousDrawnTickLabelLength ↵ | |
21 | + tickLabelLength) / 2.0;↵ | 20 | + tickLabelLength) / 2.0;↵ | |
22 | if (Math.abs(xx - previousDrawnTickLabelPos) ↵ | 21 | if (Math.abs(yy - previousDrawnTickLabelPos) ↵ | |
23 | < avgTickLabelLength) {↵ | 22 | < avgTickLabelLength) {↵ | |
24 | tickLabelsOverlapping = true;↵ | 23 | tickLabelsOverlapping = true; ↵ | |
25 | }↵ | 24 | }↵ | |
26 | }↵ | 25 | }↵ | |
27 | if (tickLabelsOverlapping) {↵ | 26 | if (tickLabelsOverlapping) {↵ | |
28 | tickLabel = ""; // don't draw this tick label↵ | 27 | tickLabel = ""; // don't draw this tick label↵ | |
29 | }↵ | 28 | }↵ | |
30 | else {↵ | 29 | else {↵ | |
31 | // remember these values for next comparison↵ | 30 | // remember these values for next comparison↵ | |
32 | previousDrawnTickLabelPos = xx;↵ | 31 | previousDrawnTickLabelPos = yy;↵ | |
33 | previousDrawnTickLabelLength = tickLabelLength; ↵ | 32 | previousDrawnTickLabelLength = tickLabelLength; ↵ | |
34 | } ↵ | 33 | }↵ | |
35 | ↵ | 34 | ↵ | |
36 | TextAnchor anchor = null;↵ | 35 | TextAnchor anchor = null;↵ | |
37 | TextAnchor rotationAnchor = null;↵ | 36 | TextAnchor rotationAnchor = null;↵ | |
38 | double angle = 0.0;↵ | 37 | double angle = 0.0;↵ | |
39 | if (isVerticalTickLabels()) {↵ | 38 | if (isVerticalTickLabels()) {↵ | |
40 | anchor = TextAnchor.CENTER_RIGHT;↵ | 39 | anchor = TextAnchor.BOTTOM_CENTER;↵ | |
41 | rotationAnchor = TextAnchor.CENTER_RIGHT;↵ | 40 | rotationAnchor = TextAnchor.BOTTOM_CENTER;↵ | |
42 | if (edge == RectangleEdge.TOP) {↵ | 41 | if (edge == RectangleEdge.LEFT) {↵ | |
43 | angle = Math.PI / 2.0;↵ | 42 | angle = -Math.PI / 2.0;↵ | |
44 | }↵ | 43 | }↵ | |
45 | else {↵ | 44 | else {↵ | |
46 | angle = -Math.PI / 2.0;↵ | 45 | angle = Math.PI / 2.0;↵ | |
47 | }↵ | 46 | } ↵ | |
48 | }↵ | 47 | }↵ | |
49 | else {↵ | 48 | else {↵ | |
50 | if (edge == RectangleEdge.TOP) {↵ | 49 | if (edge == RectangleEdge.LEFT) {↵ | |
51 | anchor = TextAnchor.BOTTOM_CENTER;↵ | 50 | anchor = TextAnchor.CENTER_RIGHT;↵ | |
52 | rotationAnchor = TextAnchor.BOTTOM_CENTER;↵ | 51 | rotationAnchor = TextAnchor.CENTER_RIGHT;↵ | |
53 | }↵ | 52 | }↵ | |
54 | else {↵ | 53 | else {↵ | |
55 | anchor = TextAnchor.TOP_CENTER;↵ | 54 | anchor = TextAnchor.CENTER_LEFT;↵ | |
56 | rotationAnchor = TextAnchor.TOP_CENTER;↵ | 55 | rotationAnchor = TextAnchor.CENTER_LEFT;↵ | |
57 | }↵ | 56 | }↵ | |
58 | }↵ | 57 | }↵ | |
59 | Tick tick = new NumberTick(new Double(currentTickValue), ↵ | 58 | Tick tick = new NumberTick(new Double(currentTickValue), ↵ | |
60 | tickLabel, anchor, rotationAnchor, angle);↵ | 59 | tickLabel, anchor, rotationAnchor, angle);↵ | |
61 | ticks.add(tick);↵ | 60 | ticks.add(tick);↵ | |
62 | } | 61 |
| |
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) | 1.7 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 283 |
Number of mapped statements | 35 |
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) | 75.3 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10 | for (int i = 0; i < count; i++) | 10 | for (int i = 0; i < count; i++) | ||||||||||||||||||
11 | double currentTickValue = lowestTickValue + (i * size); | 11 | double currentTickValue = lowestTickValue + (i * size); | ||||||||||||||||||
12 | double xx = valueToJava2D(currentTickValue, dataArea, edge); |
| 12 | double yy = valueToJava2D(currentTickValue, dataArea, edge); | |||||||||||||||||
13 | String tickLabel; | 13 | String tickLabel; | ||||||||||||||||||
14 | NumberFormat formatter = getNumberFormatOverride(); | 14 | NumberFormat formatter = getNumberFormatOverride(); | ||||||||||||||||||
15 | if (formatter != null) | 15 | if (formatter != null) | ||||||||||||||||||
16 | tickLabel = formatter.format(currentTickValue); | 16 | tickLabel = formatter.format(currentTickValue); | ||||||||||||||||||
else | else | ||||||||||||||||||||
17 | tickLabel = valueToString(currentTickValue); | 17 | tickLabel = valueToString(currentTickValue); | ||||||||||||||||||
18 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); | 18 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); | ||||||||||||||||||
19 | double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth(); |
| 19 | double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight(); | |||||||||||||||||
20 | boolean tickLabelsOverlapping = false; | 20 | boolean tickLabelsOverlapping = false; | ||||||||||||||||||
21 | if (i > 0) | 21 | if (i > 0) | ||||||||||||||||||
22 | double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; | 22 | double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; | ||||||||||||||||||
23 | if (Math.abs(xx - previousDrawnTickLabelPos) < avgTickLabelLength) |
| 23 | if (Math.abs(yy - previousDrawnTickLabelPos) < avgTickLabelLength) | |||||||||||||||||
24 | tickLabelsOverlapping = true; | 24 | tickLabelsOverlapping = true; | ||||||||||||||||||
25 | if (tickLabelsOverlapping) | 25 | if (tickLabelsOverlapping) | ||||||||||||||||||
26 | tickLabel = ""; | 26 | tickLabel = ""; | ||||||||||||||||||
else | else | ||||||||||||||||||||
27 | previousDrawnTickLabelPos = xx; |
| 27 | previousDrawnTickLabelPos = yy; | |||||||||||||||||
28 | previousDrawnTickLabelLength = tickLabelLength; | 28 | previousDrawnTickLabelLength = tickLabelLength; | ||||||||||||||||||
29 | TextAnchor anchor = null; | 29 | TextAnchor anchor = null; | ||||||||||||||||||
30 | TextAnchor rotationAnchor = null; | 30 | TextAnchor rotationAnchor = null; | ||||||||||||||||||
31 | double angle = 0.0; | 31 | double angle = 0.0; | ||||||||||||||||||
32 | if (isVerticalTickLabels()) | 32 | if (isVerticalTickLabels()) | ||||||||||||||||||
33 | anchor = TextAnchor.CENTER_RIGHT; |
| 33 | anchor = TextAnchor.BOTTOM_CENTER; | |||||||||||||||||
34 | rotationAnchor = TextAnchor.CENTER_RIGHT; |
| 34 | rotationAnchor = TextAnchor.BOTTOM_CENTER; | |||||||||||||||||
35 | if (edge == RectangleEdge.TOP) |
| 35 | if (edge == RectangleEdge.LEFT) | |||||||||||||||||
36 | angle = Math.PI / 2.0; |
| 36 | angle = -Math.PI / 2.0; | |||||||||||||||||
else | else | ||||||||||||||||||||
37 | angle = -Math.PI / 2.0; |
| 37 | angle = Math.PI / 2.0; | |||||||||||||||||
else | else | ||||||||||||||||||||
38 | if (edge == RectangleEdge.TOP) |
| 38 | if (edge == RectangleEdge.LEFT) | |||||||||||||||||
39 | anchor = TextAnchor.BOTTOM_CENTER; |
| 39 | anchor = TextAnchor.CENTER_RIGHT; | |||||||||||||||||
40 | rotationAnchor = TextAnchor.BOTTOM_CENTER; |
| 40 | rotationAnchor = TextAnchor.CENTER_RIGHT; | |||||||||||||||||
else | else | ||||||||||||||||||||
41 | anchor = TextAnchor.TOP_CENTER; |
| 41 | anchor = TextAnchor.CENTER_LEFT; | |||||||||||||||||
42 | rotationAnchor = TextAnchor.TOP_CENTER; |
| 42 | rotationAnchor = TextAnchor.CENTER_LEFT; | |||||||||||||||||
43 | Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); | 43 | Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); | ||||||||||||||||||
44 | ticks.add(tick); | 44 | ticks.add(tick); |
Row | Violation |
---|---|
1 | Expression bounds.getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression bounds.getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression bounds.getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression bounds.getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted |