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