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: 34 | Number of AST nodes: 34 | |||
1 | double currentTickValue = lowestTickValue + (i * size);↵ | 1 | double currentTickValue = lowestTickValue + (i * size);↵ | |
2 | double xx = valueToJava2D(currentTickValue, dataArea, edge);↵ | 2 | double yy = valueToJava2D(currentTickValue, dataArea, edge);↵ | |
3 | String tickLabel;↵ | 3 | String tickLabel;↵ | |
4 | NumberFormat formatter = getNumberFormatOverride();↵ | 4 | NumberFormat formatter = getNumberFormatOverride();↵ | |
5 | if (formatter != null) {↵ | 5 | if (formatter != null) {↵ | |
6 | tickLabel = formatter.format(currentTickValue);↵ | 6 | tickLabel = formatter.format(currentTickValue);↵ | |
7 | }↵ | 7 | }↵ | |
8 | else {↵ | 8 | else {↵ | |
9 | tickLabel = valueToString(currentTickValue);↵ | 9 | tickLabel = valueToString(currentTickValue);↵ | |
10 | }↵ | 10 | }↵ | |
11 | ↵ | |||
12 | // avoid to draw overlapping tick labels↵ | 11 | // avoid to draw overlapping tick labels↵ | |
13 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, ↵ | 12 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2,↵ | |
14 | g2.getFontMetrics());↵ | 13 | g2.getFontMetrics());↵ | |
15 | double tickLabelLength = isVerticalTickLabels() ↵ | 14 | double tickLabelLength = isVerticalTickLabels() ↵ | |
16 | ? bounds.getHeight() : bounds.getWidth();↵ | 15 | ? bounds.getWidth() : bounds.getHeight();↵ | |
17 | boolean tickLabelsOverlapping = false;↵ | 16 | boolean tickLabelsOverlapping = false;↵ | |
18 | if (i > 0) {↵ | 17 | if (i > 0) {↵ | |
19 | double avgTickLabelLength = (previousDrawnTickLabelLength ↵ | 18 | double avgTickLabelLength = (previousDrawnTickLabelLength ↵ | |
20 | + tickLabelLength) / 2.0;↵ | 19 | + tickLabelLength) / 2.0;↵ | |
21 | if (Math.abs(xx - previousDrawnTickLabelPos) ↵ | 20 | if (Math.abs(yy - previousDrawnTickLabelPos) ↵ | |
22 | < avgTickLabelLength) {↵ | 21 | < avgTickLabelLength) {↵ | |
23 | tickLabelsOverlapping = true;↵ | 22 | tickLabelsOverlapping = true; ↵ | |
24 | }↵ | 23 | }↵ | |
25 | }↵ | 24 | }↵ | |
26 | if (tickLabelsOverlapping) {↵ | 25 | if (tickLabelsOverlapping) {↵ | |
27 | tickLabel = ""; // don't draw this tick label↵ | 26 | tickLabel = ""; // don't draw this tick label↵ | |
28 | }↵ | 27 | }↵ | |
29 | else {↵ | 28 | else {↵ | |
30 | // remember these values for next comparison↵ | 29 | // remember these values for next comparison↵ | |
31 | previousDrawnTickLabelPos = xx;↵ | 30 | previousDrawnTickLabelPos = yy;↵ | |
32 | previousDrawnTickLabelLength = tickLabelLength; ↵ | 31 | previousDrawnTickLabelLength = tickLabelLength; ↵ | |
33 | } ↵ | 32 | }↵ | |
34 | ↵ | 33 | ↵ | |
35 | TextAnchor anchor = null;↵ | 34 | TextAnchor anchor = null;↵ | |
36 | TextAnchor rotationAnchor = null;↵ | 35 | TextAnchor rotationAnchor = null;↵ | |
37 | double angle = 0.0;↵ | 36 | double angle = 0.0;↵ | |
38 | if (isVerticalTickLabels()) {↵ | 37 | if (isVerticalTickLabels()) {↵ | |
39 | anchor = TextAnchor.CENTER_RIGHT;↵ | 38 | anchor = TextAnchor.BOTTOM_CENTER;↵ | |
40 | rotationAnchor = TextAnchor.CENTER_RIGHT;↵ | 39 | rotationAnchor = TextAnchor.BOTTOM_CENTER;↵ | |
41 | if (edge == RectangleEdge.TOP) {↵ | 40 | if (edge == RectangleEdge.LEFT) {↵ | |
42 | angle = Math.PI / 2.0;↵ | 41 | angle = -Math.PI / 2.0;↵ | |
43 | }↵ | 42 | }↵ | |
44 | else {↵ | 43 | else {↵ | |
45 | angle = -Math.PI / 2.0;↵ | 44 | angle = Math.PI / 2.0;↵ | |
46 | }↵ | 45 | } ↵ | |
47 | }↵ | 46 | }↵ | |
48 | else {↵ | 47 | else {↵ | |
49 | if (edge == RectangleEdge.TOP) {↵ | 48 | if (edge == RectangleEdge.LEFT) {↵ | |
50 | anchor = TextAnchor.BOTTOM_CENTER;↵ | 49 | anchor = TextAnchor.CENTER_RIGHT;↵ | |
51 | rotationAnchor = TextAnchor.BOTTOM_CENTER;↵ | 50 | rotationAnchor = TextAnchor.CENTER_RIGHT;↵ | |
52 | }↵ | 51 | }↵ | |
53 | else {↵ | 52 | else {↵ | |
54 | anchor = TextAnchor.TOP_CENTER;↵ | 53 | anchor = TextAnchor.CENTER_LEFT;↵ | |
55 | rotationAnchor = TextAnchor.TOP_CENTER;↵ | 54 | rotationAnchor = TextAnchor.CENTER_LEFT;↵ | |
56 | }↵ | 55 | }↵ | |
57 | }↵ | 56 | }↵ | |
58 | Tick tick = new NumberTick(new Double(currentTickValue), ↵ | 57 | Tick tick = new NumberTick(new Double(currentTickValue), ↵ | |
59 | tickLabel, anchor, rotationAnchor, angle);↵ | 58 | tickLabel, anchor, rotationAnchor, angle);↵ | |
60 | ticks.add(tick); | 59 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 2.1 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 272 |
Number of mapped statements | 34 |
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) | 16.7 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
5 | Clone fragment #1 returns variables previousDrawnTickLabelLength, previousDrawnTickLabelPos , while Clone fragment #2 returns variables previousDrawnTickLabelLength, previousDrawnTickLabelPos |