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