File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/CombinedRangeCategoryPlot.java | File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/CombinedRangeXYPlot.java | |||
Method name: AxisSpace calculateAxisSpace(Graphics2D, Rectangle2D)
|
Method name: AxisSpace calculateAxisSpace(Graphics2D, Rectangle2D)
|
|||
Number of AST nodes: 37 | Number of AST nodes: 37 | |||
1 | AxisSpace space = new AxisSpace(); ↵ | 1 | AxisSpace space = new AxisSpace();↵ | |
2 | PlotOrientation orientation = getOrientation();↵ | 2 | PlotOrientation orientation = getOrientation();↵ | |
3 | ↵ | |||
4 | // work out the space required by the domain axis...↵ | 3 | // work out the space required by the domain axis...↵ | |
5 | AxisSpace fixed = getFixedRangeAxisSpace();↵ | 4 | AxisSpace fixed = getFixedRangeAxisSpace();↵ | |
6 | if (fixed != null) {↵ | 5 | if (fixed != null) {↵ | |
7 | if (orientation == PlotOrientation.VERTICAL) {↵ | 6 | if (orientation == PlotOrientation.VERTICAL) {↵ | |
8 | space.setLeft(fixed.getLeft());↵ | 7 | space.setLeft(fixed.getLeft());↵ | |
9 | space.setRight(fixed.getRight());↵ | 8 | space.setRight(fixed.getRight());↵ | |
10 | }↵ | 9 | }↵ | |
11 | else if (orientation == PlotOrientation.HORIZONTAL) {↵ | 10 | else if (orientation == PlotOrientation.HORIZONTAL) {↵ | |
12 | space.setTop(fixed.getTop());↵ | 11 | space.setTop(fixed.getTop());↵ | |
13 | space.setBottom(fixed.getBottom()); ↵ | 12 | space.setBottom(fixed.getBottom());↵ | |
14 | }↵ | 13 | }↵ | |
15 | }↵ | 14 | }↵ | |
16 | else {↵ | 15 | else {↵ | |
17 | ValueAxis valueAxis = getRangeAxis();↵ | 16 | ValueAxis valueAxis = getRangeAxis();↵ | |
18 | RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(↵ | 17 | RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(↵ | |
19 | getRangeAxisLocation(), orientation↵ | 18 | getRangeAxisLocation(), orientation↵ | |
20 | );↵ | 19 | );↵ | |
21 | if (valueAxis != null) {↵ | 20 | if (valueAxis != null) {↵ | |
22 | space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, ↵ | 21 | space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,↵ | |
23 | space);↵ | 22 | space);↵ | |
24 | }↵ | 23 | }↵ | |
25 | }↵ | 24 | }↵ | |
26 | ↵ | |||
27 | Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);↵ | 25 | Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);↵ | |
28 | // work out the maximum height or width of the non-shared axes...↵ | 26 | // work out the maximum height or width of the non-shared axes...↵ | |
29 | int n = this.subplots.size();↵ | 27 | int n = this.subplots.size();↵ | |
30 | // calculate plotAreas of all sub-plots, maximum vertical/horizontal ↵ | 28 | // calculate plotAreas of all sub-plots, maximum vertical/horizontal↵ | |
31 | // axis width/height↵ | 29 | // axis width/height↵ | |
32 | this.subplotArea = new Rectangle2D[n];↵ | 30 | this.subplotAreas = new Rectangle2D[n];↵ | |
33 | double x = adjustedPlotArea.getX();↵ | 31 | double x = adjustedPlotArea.getX();↵ | |
34 | double y = adjustedPlotArea.getY();↵ | 32 | double y = adjustedPlotArea.getY();↵ | |
35 | double usableSize = 0.0;↵ | 33 | double usableSize = 0.0;↵ | |
36 | if (orientation == PlotOrientation.VERTICAL) {↵ | 34 | if (orientation == PlotOrientation.VERTICAL) {↵ | |
37 | usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);↵ | 35 | usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);↵ | |
38 | }↵ | 36 | }↵ | |
39 | else if (orientation == PlotOrientation.HORIZONTAL) {↵ | 37 | else if (orientation == PlotOrientation.HORIZONTAL) {↵ | |
40 | usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);↵ | 38 | usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);↵ | |
41 | }↵ | 39 | }↵ | |
42 | for (int i = 0; i < n; i++) {↵ | 40 | for (int i = 0; i < n; i++) {↵ | |
43 | CategoryPlot plot = (CategoryPlot) this.subplots.get(i);↵ | 41 | XYPlot plot = (XYPlot) this.subplots.get(i);↵ | |
44 | // calculate sub-plot area↵ | 42 | // calculate sub-plot area↵ | |
45 | if (orientation == PlotOrientation.VERTICAL) {↵ | 43 | if (orientation == PlotOrientation.VERTICAL) {↵ | |
46 | double w = usableSize * plot.getWeight() / this.totalWeight;↵ | 44 | double w = usableSize * plot.getWeight() / this.totalWeight;↵ | |
47 | this.subplotArea[i] = new Rectangle2D.Double(x, y, w, ↵ | 45 | this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,↵ | |
48 | adjustedPlotArea.getHeight());↵ | 46 | adjustedPlotArea.getHeight());↵ | |
49 | x = x + w + this.gap;↵ | 47 | x = x + w + this.gap;↵ | |
50 | }↵ | 48 | }↵ | |
51 | else if (orientation == PlotOrientation.HORIZONTAL) {↵ | 49 | else if (orientation == PlotOrientation.HORIZONTAL) {↵ | |
52 | double h = usableSize * plot.getWeight() / this.totalWeight;↵ | 50 | double h = usableSize * plot.getWeight() / this.totalWeight;↵ | |
53 | this.subplotArea[i] = new Rectangle2D.Double(x, y, ↵ | 51 | this.subplotAreas[i] = new Rectangle2D.Double(x, y,↵ | |
54 | adjustedPlotArea.getWidth(), h);↵ | 52 | adjustedPlotArea.getWidth(), h);↵ | |
55 | y = y + h + this.gap;↵ | 53 | y = y + h + this.gap;↵ | |
56 | }↵ | 54 | }↵ | |
57 | AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, ↵ | 55 | AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,↵ | |
58 | this.subplotArea[i], null);↵ | 56 | this.subplotAreas[i], null);↵ | |
59 | space.ensureAtLeast(subSpace);↵ | 57 | space.ensureAtLeast(subSpace);↵ | |
60 | }↵ | 58 | }↵ | |
61 | return space; | 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) | 7.1 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 232 |
Number of mapped statements | 37 |
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) | 175.4 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | AxisSpace space = new AxisSpace(); | 1 | AxisSpace space = new AxisSpace(); | |||||||||||||||||||
2 | PlotOrientation orientation = getOrientation(); | 2 | PlotOrientation orientation = getOrientation(); | |||||||||||||||||||
3 | AxisSpace fixed = getFixedRangeAxisSpace(); | 3 | AxisSpace fixed = getFixedRangeAxisSpace(); | |||||||||||||||||||
4 | if (fixed != null) | 4 | if (fixed != null) | |||||||||||||||||||
5 | if (orientation == PlotOrientation.VERTICAL) | 5 | if (orientation == PlotOrientation.VERTICAL) | |||||||||||||||||||
6 | space.setLeft(fixed.getLeft()); | 6 | space.setLeft(fixed.getLeft()); | |||||||||||||||||||
7 | space.setRight(fixed.getRight()); | 7 | space.setRight(fixed.getRight()); | |||||||||||||||||||
8 | else if (orientation == PlotOrientation.HORIZONTAL) | 8 | else if (orientation == PlotOrientation.HORIZONTAL) | |||||||||||||||||||
9 | space.setTop(fixed.getTop()); | 9 | space.setTop(fixed.getTop()); | |||||||||||||||||||
10 | space.setBottom(fixed.getBottom()); | 10 | space.setBottom(fixed.getBottom()); | |||||||||||||||||||
else | else | |||||||||||||||||||||
11 | ValueAxis valueAxis = getRangeAxis(); | 11 | ValueAxis valueAxis = getRangeAxis(); | |||||||||||||||||||
12 | RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), orientation); | 12 | RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), orientation); | |||||||||||||||||||
13 | if (valueAxis != null) | 13 | if (valueAxis != null) | |||||||||||||||||||
14 | space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space); | 14 | space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space); | |||||||||||||||||||
15 | Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); | 15 | Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); | |||||||||||||||||||
16 | int n = this.subplots.size(); | 16 | int n = this.subplots.size(); | |||||||||||||||||||
17 | this.subplotArea = new Rectangle2D[n]; |
| 17 | this.subplotAreas = new Rectangle2D[n]; | ||||||||||||||||||
18 | double x = adjustedPlotArea.getX(); | 18 | double x = adjustedPlotArea.getX(); | |||||||||||||||||||
19 | double y = adjustedPlotArea.getY(); | 19 | double y = adjustedPlotArea.getY(); | |||||||||||||||||||
20 | double usableSize = 0.0; | 20 | double usableSize = 0.0; | |||||||||||||||||||
21 | if (orientation == PlotOrientation.VERTICAL) | 21 | if (orientation == PlotOrientation.VERTICAL) | |||||||||||||||||||
22 | usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); | 22 | usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); | |||||||||||||||||||
23 | else if (orientation == PlotOrientation.HORIZONTAL) | 23 | else if (orientation == PlotOrientation.HORIZONTAL) | |||||||||||||||||||
24 | usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); | 24 | usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); | |||||||||||||||||||
25 | for (int i = 0; i < n; i++) | 25 | for (int i = 0; i < n; i++) | |||||||||||||||||||
26 | CategoryPlot plot = (CategoryPlot)this.subplots.get(i); |
| 26 | XYPlot plot = (XYPlot)this.subplots.get(i); | ||||||||||||||||||
27 | if (orientation == PlotOrientation.VERTICAL) | 27 | if (orientation == PlotOrientation.VERTICAL) | |||||||||||||||||||
28 | double w = usableSize * plot.getWeight() / this.totalWeight; |
| 28 | double w = usableSize * plot.getWeight() / this.totalWeight; | ||||||||||||||||||
29 | this.subplotArea[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); |
| 29 | this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); | ||||||||||||||||||
30 | x = x + w + this.gap; | 30 | x = x + w + this.gap; | |||||||||||||||||||
31 | else if (orientation == PlotOrientation.HORIZONTAL) | 31 | else if (orientation == PlotOrientation.HORIZONTAL) | |||||||||||||||||||
32 | double h = usableSize * plot.getWeight() / this.totalWeight; |
| 32 | double h = usableSize * plot.getWeight() / this.totalWeight; | ||||||||||||||||||
33 | this.subplotArea[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); |
| 33 | this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); | ||||||||||||||||||
34 | y = y + h + this.gap; | 34 | y = y + h + this.gap; | |||||||||||||||||||
35 | AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotArea[i], null); |
| 35 | AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotAreas[i], null); | ||||||||||||||||||
36 | space.ensureAtLeast(subSpace); | 36 | space.ensureAtLeast(subSpace); | |||||||||||||||||||
37 | return space; | 37 | return space; |
Row | Violation |
---|---|
1 | Expression this.subplotArea is a field being modified, and thus it cannot be parameterized |
2 | Expression this.subplotAreas is a field being modified, and thus it cannot be parameterized |
3 | Expression (CategoryPlot)this.subplots.get(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression (XYPlot)this.subplots.get(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public int getWeight() |
6 | Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public int getWeight() |
9 | Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) protected org.jfree.chart.axis.AxisSpace calculateDomainAxisSpace(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.axis.AxisSpace) |