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: 36 | Number of AST nodes: 36 | |||
1 | if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {↵ | 1 | if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {↵ | |
2 | for (int i = 0; i < count; i++) {↵ | 2 | for (int i = 0; i < count; i++) {↵ | |
3 | double currentTickValue = lowestTickValue + (i * size);↵ | 3 | double currentTickValue = lowestTickValue + (i * size);↵ | |
4 | double xx = valueToJava2D(currentTickValue, dataArea, edge);↵ | 4 | double yy = valueToJava2D(currentTickValue, dataArea, edge);↵ | |
5 | String tickLabel;↵ | 5 | String tickLabel;↵ | |
6 | NumberFormat formatter = getNumberFormatOverride();↵ | 6 | NumberFormat formatter = getNumberFormatOverride();↵ | |
7 | if (formatter != null) {↵ | 7 | if (formatter != null) {↵ | |
8 | tickLabel = formatter.format(currentTickValue);↵ | 8 | tickLabel = formatter.format(currentTickValue);↵ | |
9 | }↵ | 9 | }↵ | |
10 | else {↵ | 10 | else {↵ | |
11 | tickLabel = valueToString(currentTickValue);↵ | 11 | tickLabel = valueToString(currentTickValue);↵ | |
12 | }↵ | 12 | }↵ | |
13 | ↵ | |||
14 | // avoid to draw overlapping tick labels↵ | 13 | // avoid to draw overlapping tick labels↵ | |
15 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, ↵ | 14 | Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2,↵ | |
16 | g2.getFontMetrics());↵ | 15 | g2.getFontMetrics());↵ | |
17 | double tickLabelLength = isVerticalTickLabels() ↵ | 16 | double tickLabelLength = isVerticalTickLabels() ↵ | |
18 | ? bounds.getHeight() : bounds.getWidth();↵ | 17 | ? bounds.getWidth() : bounds.getHeight();↵ | |
19 | boolean tickLabelsOverlapping = false;↵ | 18 | boolean tickLabelsOverlapping = false;↵ | |
20 | if (i > 0) {↵ | 19 | if (i > 0) {↵ | |
21 | double avgTickLabelLength = (previousDrawnTickLabelLength ↵ | 20 | double avgTickLabelLength = (previousDrawnTickLabelLength ↵ | |
22 | + tickLabelLength) / 2.0;↵ | 21 | + tickLabelLength) / 2.0;↵ | |
23 | if (Math.abs(xx - previousDrawnTickLabelPos) ↵ | 22 | if (Math.abs(yy - previousDrawnTickLabelPos) ↵ | |
24 | < avgTickLabelLength) {↵ | 23 | < avgTickLabelLength) {↵ | |
25 | tickLabelsOverlapping = true;↵ | 24 | tickLabelsOverlapping = true; ↵ | |
26 | }↵ | 25 | }↵ | |
27 | }↵ | 26 | }↵ | |
28 | if (tickLabelsOverlapping) {↵ | 27 | if (tickLabelsOverlapping) {↵ | |
29 | tickLabel = ""; // don't draw this tick label↵ | 28 | tickLabel = ""; // don't draw this tick label↵ | |
30 | }↵ | 29 | }↵ | |
31 | else {↵ | 30 | else {↵ | |
32 | // remember these values for next comparison↵ | 31 | // remember these values for next comparison↵ | |
33 | previousDrawnTickLabelPos = xx;↵ | 32 | previousDrawnTickLabelPos = yy;↵ | |
34 | previousDrawnTickLabelLength = tickLabelLength; ↵ | 33 | previousDrawnTickLabelLength = tickLabelLength; ↵ | |
35 | } ↵ | 34 | }↵ | |
36 | ↵ | 35 | ↵ | |
37 | TextAnchor anchor = null;↵ | 36 | TextAnchor anchor = null;↵ | |
38 | TextAnchor rotationAnchor = null;↵ | 37 | TextAnchor rotationAnchor = null;↵ | |
39 | double angle = 0.0;↵ | 38 | double angle = 0.0;↵ | |
40 | if (isVerticalTickLabels()) {↵ | 39 | if (isVerticalTickLabels()) {↵ | |
41 | anchor = TextAnchor.CENTER_RIGHT;↵ | 40 | anchor = TextAnchor.BOTTOM_CENTER;↵ | |
42 | rotationAnchor = TextAnchor.CENTER_RIGHT;↵ | 41 | rotationAnchor = TextAnchor.BOTTOM_CENTER;↵ | |
43 | if (edge == RectangleEdge.TOP) {↵ | 42 | if (edge == RectangleEdge.LEFT) {↵ | |
44 | angle = Math.PI / 2.0;↵ | 43 | angle = -Math.PI / 2.0;↵ | |
45 | }↵ | 44 | }↵ | |
46 | else {↵ | 45 | else {↵ | |
47 | angle = -Math.PI / 2.0;↵ | 46 | angle = Math.PI / 2.0;↵ | |
48 | }↵ | 47 | } ↵ | |
49 | }↵ | 48 | }↵ | |
50 | else {↵ | 49 | else {↵ | |
51 | if (edge == RectangleEdge.TOP) {↵ | 50 | if (edge == RectangleEdge.LEFT) {↵ | |
52 | anchor = TextAnchor.BOTTOM_CENTER;↵ | 51 | anchor = TextAnchor.CENTER_RIGHT;↵ | |
53 | rotationAnchor = TextAnchor.BOTTOM_CENTER;↵ | 52 | rotationAnchor = TextAnchor.CENTER_RIGHT;↵ | |
54 | }↵ | 53 | }↵ | |
55 | else {↵ | 54 | else {↵ | |
56 | anchor = TextAnchor.TOP_CENTER;↵ | 55 | anchor = TextAnchor.CENTER_LEFT;↵ | |
57 | rotationAnchor = TextAnchor.TOP_CENTER;↵ | 56 | rotationAnchor = TextAnchor.CENTER_LEFT;↵ | |
58 | }↵ | 57 | }↵ | |
59 | }↵ | 58 | }↵ | |
60 | Tick tick = new NumberTick(new Double(currentTickValue), ↵ | 59 | Tick tick = new NumberTick(new Double(currentTickValue), ↵ | |
61 | tickLabel, anchor, rotationAnchor, angle);↵ | 60 | tickLabel, anchor, rotationAnchor, angle);↵ | |
62 | ticks.add(tick);↵ | 61 | ticks.add(tick);↵ | |
63 | }↵ | 62 | }↵ | |
64 | } | 63 |
| |
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 | 36 |
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) | 78.4 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9 | if (count <= ValueAxis.MAXIMUM_TICK_COUNT) | 9 | if (count <= ValueAxis.MAXIMUM_TICK_COUNT) | ||||||||||||||||||
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 |