File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java | File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java | |||
Method name: void drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker, Rectangle2D)
|
Method name: void drawDomainMarker(Graphics2D, XYPlot, ValueAxis, Marker, Rectangle2D)
|
|||
Number of AST nodes: 65 | Number of AST nodes: 65 | |||
1 | if (marker instanceof IntervalMarker) {↵ | 1 | if (marker instanceof IntervalMarker) {↵ | |
2 | IntervalMarker im = (IntervalMarker) marker;↵ | 2 | IntervalMarker im = (IntervalMarker) marker;↵ | |
3 | double start = im.getStartValue();↵ | 3 | double start = im.getStartValue();↵ | |
4 | double end = im.getEndValue();↵ | 4 | double end = im.getEndValue();↵ | |
5 | Range range = axis.getRange();↵ | 5 | Range range = domainAxis.getRange();↵ | |
6 | if (!(range.intersects(start, end))) {↵ | 6 | if (!(range.intersects(start, end))) {↵ | |
7 | return;↵ | 7 | return;↵ | |
8 | }↵ | 8 | }↵ | |
9 | final Composite savedComposite = g2.getComposite();↵ | |||
10 | g2.setComposite(AlphaComposite.getInstance(↵ | |||
11 | AlphaComposite.SRC_OVER, marker.getAlpha()));↵ | |||
12 | double start2d = axis.valueToJava2D(start, dataArea,↵ | 9 | double start2d = domainAxis.valueToJava2D(start, dataArea,↵ | |
13 | plot.getRangeAxisEdge());↵ | 10 | plot.getDomainAxisEdge());↵ | |
14 | double end2d = axis.valueToJava2D(end, dataArea,↵ | 11 | double end2d = domainAxis.valueToJava2D(end, dataArea,↵ | |
15 | plot.getRangeAxisEdge());↵ | 12 | plot.getDomainAxisEdge());↵ | |
16 | double low = Math.min(start2d, end2d);↵ | 13 | double low = Math.min(start2d, end2d);↵ | |
17 | double high = Math.max(start2d, end2d);↵ | 14 | double high = Math.max(start2d, end2d);↵ | |
18 | PlotOrientation orientation = plot.getOrientation();↵ | 15 | PlotOrientation orientation = plot.getOrientation();↵ | |
19 | Rectangle2D rect = null;↵ | 16 | Rectangle2D rect = null;↵ | |
20 | if (orientation == PlotOrientation.HORIZONTAL) {↵ | 17 | if (orientation == PlotOrientation.HORIZONTAL) {↵ | |
21 | // clip left and right bounds to data area↵ | 18 | // clip top and bottom bounds to data area↵ | |
22 | low = Math.max(low, dataArea.getMinX());↵ | 19 | low = Math.max(low, dataArea.getMinY());↵ | |
23 | high = Math.min(high, dataArea.getMaxX());↵ | 20 | high = Math.min(high, dataArea.getMaxY());↵ | |
24 | rect = new Rectangle2D.Double(low,↵ | 21 | rect = new Rectangle2D.Double(dataArea.getMinX(),↵ | |
25 | dataArea.getMinY(), high - low,↵ | 22 | low, dataArea.getWidth(),↵ | |
26 | dataArea.getHeight());↵ | 23 | high - low);↵ | |
27 | }↵ | 24 | }↵ | |
28 | else if (orientation == PlotOrientation.VERTICAL) {↵ | 25 | else if (orientation == PlotOrientation.VERTICAL) {↵ | |
29 | // clip top and bottom bounds to data area↵ | 26 | // clip left and right bounds to data area↵ | |
30 | low = Math.max(low, dataArea.getMinY());↵ | 27 | low = Math.max(low, dataArea.getMinX());↵ | |
31 | high = Math.min(high, dataArea.getMaxY());↵ | 28 | high = Math.min(high, dataArea.getMaxX());↵ | |
32 | rect = new Rectangle2D.Double(↵ | 29 | rect = new Rectangle2D.Double(low,↵ | |
33 | dataArea.getMinX(),↵ | 30 | dataArea.getMinY(), high - low,↵ | |
34 | low, dataArea.getWidth(),↵ | 31 | dataArea.getHeight());↵ | |
35 | ↵ | 32 | }↵ | |
36 | high - low);↵ | 33 | ↵ | |
37 | }↵ | 34 | final Composite originalComposite = g2.getComposite();↵ | |
35 | g2.setComposite(AlphaComposite.getInstance(↵ | |||
36 | AlphaComposite.SRC_OVER, marker.getAlpha()));↵ | |||
38 | Paint p = marker.getPaint();↵ | 37 | Paint p = marker.getPaint();↵ | |
39 | if (p instanceof GradientPaint) {↵ | 38 | if (p instanceof GradientPaint) {↵ | |
40 | GradientPaint gp = (GradientPaint) p;↵ | 39 | GradientPaint gp = (GradientPaint) p;↵ | |
41 | GradientPaintTransformer t = im.getGradientPaintTransformer();↵ | 40 | GradientPaintTransformer t = im.getGradientPaintTransformer();↵ | |
42 | if (t != null) {↵ | 41 | if (t != null) {↵ | |
43 | gp = t.transform(gp, rect);↵ | 42 | gp = t.transform(gp, rect);↵ | |
44 | }↵ | 43 | }↵ | |
45 | g2.setPaint(gp);↵ | 44 | g2.setPaint(gp);↵ | |
46 | }↵ | 45 | }↵ | |
47 | else {↵ | 46 | else {↵ | |
48 | g2.setPaint(p);↵ | 47 | g2.setPaint(p);↵ | |
49 | }↵ | 48 | }↵ | |
50 | g2.fill(rect);↵ | 49 | g2.fill(rect);↵ | |
51 | // now draw the outlines, if visible...↵ | 50 | // now draw the outlines, if visible...↵ | |
52 | if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) {↵ | 51 | if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) {↵ | |
53 | if (orientation == PlotOrientation.VERTICAL) {↵ | 52 | if (orientation == PlotOrientation.VERTICAL) {↵ | |
54 | Line2D line = new Line2D.Double();↵ | 53 | Line2D line = new Line2D.Double();↵ | |
55 | double x0 = dataArea.getMinX();↵ | 54 | double y0 = dataArea.getMinY();↵ | |
56 | double x1 = dataArea.getMaxX();↵ | 55 | double y1 = dataArea.getMaxY();↵ | |
57 | g2.setPaint(im.getOutlinePaint());↵ | 56 | g2.setPaint(im.getOutlinePaint());↵ | |
58 | g2.setStroke(im.getOutlineStroke());↵ | 57 | g2.setStroke(im.getOutlineStroke());↵ | |
59 | if (range.contains(start)) {↵ | 58 | if (range.contains(start)) {↵ | |
60 | line.setLine(x0, start2d, x1, start2d);↵ | 59 | line.setLine(start2d, y0, start2d, y1);↵ | |
61 | g2.draw(line);↵ | 60 | g2.draw(line);↵ | |
62 | }↵ | 61 | }↵ | |
63 | if (range.contains(end)) {↵ | 62 | if (range.contains(end)) {↵ | |
64 | line.setLine(x0, end2d, x1, end2d);↵ | 63 | line.setLine(end2d, y0, end2d, y1);↵ | |
65 | g2.draw(line);↵ | 64 | g2.draw(line);↵ | |
66 | }↵ | 65 | }↵ | |
67 | }↵ | 66 | }↵ | |
68 | else { // PlotOrientation.HORIZONTAL↵ | 67 | else { // PlotOrientation.HORIZONTAL↵ | |
69 | Line2D line = new Line2D.Double();↵ | 68 | Line2D line = new Line2D.Double();↵ | |
70 | double y0 = dataArea.getMinY();↵ | 69 | double x0 = dataArea.getMinX();↵ | |
71 | double y1 = dataArea.getMaxY();↵ | 70 | double x1 = dataArea.getMaxX();↵ | |
72 | g2.setPaint(im.getOutlinePaint());↵ | 71 | g2.setPaint(im.getOutlinePaint());↵ | |
73 | g2.setStroke(im.getOutlineStroke());↵ | 72 | g2.setStroke(im.getOutlineStroke());↵ | |
74 | if (range.contains(start)) {↵ | 73 | if (range.contains(start)) {↵ | |
75 | line.setLine(start2d, y0, start2d, y1);↵ | 74 | line.setLine(x0, start2d, x1, start2d);↵ | |
76 | g2.draw(line);↵ | 75 | g2.draw(line);↵ | |
77 | }↵ | 76 | }↵ | |
78 | if (range.contains(end)) {↵ | 77 | if (range.contains(end)) {↵ | |
79 | line.setLine(end2d, y0, end2d, y1);↵ | 78 | line.setLine(x0, end2d, x1, end2d);↵ | |
80 | g2.draw(line);↵ | 79 | g2.draw(line);↵ | |
81 | }↵ | 80 | }↵ | |
82 | }↵ | 81 | }↵ | |
83 | }↵ | 82 | }↵ | |
84 | String label = marker.getLabel();↵ | 83 | String label = marker.getLabel();↵ | |
85 | RectangleAnchor anchor = marker.getLabelAnchor();↵ | 84 | RectangleAnchor anchor = marker.getLabelAnchor();↵ | |
86 | if (label != null) {↵ | 85 | if (label != null) {↵ | |
87 | Font labelFont = marker.getLabelFont();↵ | 86 | Font labelFont = marker.getLabelFont();↵ | |
88 | g2.setFont(labelFont);↵ | 87 | g2.setFont(labelFont);↵ | |
89 | g2.setPaint(marker.getLabelPaint());↵ | 88 | g2.setPaint(marker.getLabelPaint());↵ | |
90 | Point2D coordinates = calculateRangeMarkerTextAnchorPoint(↵ | 89 | Point2D coordinates = calculateDomainMarkerTextAnchorPoint(↵ | |
91 | g2, orientation, dataArea, rect,↵ | 90 | g2, orientation, dataArea, rect,↵ | |
92 | marker.getLabelOffset(), marker.getLabelOffsetType(),↵ | 91 | marker.getLabelOffset(), marker.getLabelOffsetType(),↵ | |
93 | anchor);↵ | 92 | anchor);↵ | |
94 | TextUtilities.drawAlignedString(label, g2,↵ | 93 | TextUtilities.drawAlignedString(label, g2,↵ | |
95 | (float) coordinates.getX(), (float) coordinates.getY(),↵ | 94 | (float) coordinates.getX(), (float) coordinates.getY(),↵ | |
96 | marker.getLabelTextAnchor());↵ | 95 | marker.getLabelTextAnchor());↵ | |
97 | }↵ | 96 | }↵ | |
98 | g2.setComposite(savedComposite);↵ | 97 | g2.setComposite(originalComposite);↵ | |
99 | } | 98 |
| |
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) | 5.7 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 596 |
Number of mapped statements | 65 |
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) | 276.1 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
28 | else if (marker instanceof IntervalMarker) | 28 | else if (marker instanceof IntervalMarker) | ||||||||||||||||||||
29 | IntervalMarker im = (IntervalMarker)marker; | 29 | IntervalMarker im = (IntervalMarker)marker; | ||||||||||||||||||||
30 | double start = im.getStartValue(); | 30 | double start = im.getStartValue(); | ||||||||||||||||||||
31 | double end = im.getEndValue(); | 31 | double end = im.getEndValue(); | ||||||||||||||||||||
32 | Range range = axis.getRange(); |
| 32 | Range range = domainAxis.getRange(); | |||||||||||||||||||
33 | if (!(range.intersects(start, end))) | 33 | if (!(range.intersects(start, end))) | ||||||||||||||||||||
34 | return; |
| 34 | return; | |||||||||||||||||||
35 | final Composite savedComposite = g2.getComposite(); |
| 49 | final Composite originalComposite = g2.getComposite(); | |||||||||||||||||||
36 | g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha())); | 50 | g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha())); | ||||||||||||||||||||
37 | double start2d = axis.valueToJava2D(start, dataArea, plot.getRangeAxisEdge()); |
| 35 | double start2d = domainAxis.valueToJava2D(start, dataArea, plot.getDomainAxisEdge()); | |||||||||||||||||||
38 | double end2d = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); |
| 36 | double end2d = domainAxis.valueToJava2D(end, dataArea, plot.getDomainAxisEdge()); | |||||||||||||||||||
39 | double low = Math.min(start2d, end2d); | 37 | double low = Math.min(start2d, end2d); | ||||||||||||||||||||
40 | double high = Math.max(start2d, end2d); | 38 | double high = Math.max(start2d, end2d); | ||||||||||||||||||||
41 | PlotOrientation orientation = plot.getOrientation(); |
| 39 | PlotOrientation orientation = plot.getOrientation(); | |||||||||||||||||||
42 | Rectangle2D rect = null; | 40 | Rectangle2D rect = null; | ||||||||||||||||||||
43 | if (orientation == PlotOrientation.HORIZONTAL) |
| 45 | if (orientation == PlotOrientation.VERTICAL) | |||||||||||||||||||
44 | low = Math.max(low, dataArea.getMinX()); | 46 | low = Math.max(low, dataArea.getMinX()); | ||||||||||||||||||||
45 | high = Math.min(high, dataArea.getMaxX()); | 47 | high = Math.min(high, dataArea.getMaxX()); | ||||||||||||||||||||
46 | rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); | 48 | rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); | ||||||||||||||||||||
47 | else if (orientation == PlotOrientation.VERTICAL) |
| 41 | else if (orientation == PlotOrientation.HORIZONTAL) | |||||||||||||||||||
48 | low = Math.max(low, dataArea.getMinY()); | 42 | low = Math.max(low, dataArea.getMinY()); | ||||||||||||||||||||
49 | high = Math.min(high, dataArea.getMaxY()); | 43 | high = Math.min(high, dataArea.getMaxY()); | ||||||||||||||||||||
50 | rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); | 44 | rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); | ||||||||||||||||||||
51 | Paint p = marker.getPaint(); | 51 | Paint p = marker.getPaint(); | ||||||||||||||||||||
52 | if (p instanceof GradientPaint) | 52 | if (p instanceof GradientPaint) | ||||||||||||||||||||
53 | GradientPaint gp = (GradientPaint)p; | 53 | GradientPaint gp = (GradientPaint)p; | ||||||||||||||||||||
54 | GradientPaintTransformer t = im.getGradientPaintTransformer(); | 54 | GradientPaintTransformer t = im.getGradientPaintTransformer(); | ||||||||||||||||||||
55 | if (t != null) | 55 | if (t != null) | ||||||||||||||||||||
56 | gp = t.transform(gp, rect); | 56 | gp = t.transform(gp, rect); | ||||||||||||||||||||
57 | g2.setPaint(gp); | 57 | g2.setPaint(gp); | ||||||||||||||||||||
else | else | ||||||||||||||||||||||
58 | g2.setPaint(p); | 58 | g2.setPaint(p); | ||||||||||||||||||||
59 | g2.fill(rect); | 59 | g2.fill(rect); | ||||||||||||||||||||
60 | if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) | 60 | if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) | ||||||||||||||||||||
61 | if (orientation == PlotOrientation.VERTICAL) |
| 61 | if (orientation == PlotOrientation.VERTICAL) | |||||||||||||||||||
62 | Line2D line = new Line2D.Double(); | 73 | Line2D line = new Line2D.Double(); | ||||||||||||||||||||
63 | double x0 = dataArea.getMinX(); | 74 | double x0 = dataArea.getMinX(); | ||||||||||||||||||||
64 | double x1 = dataArea.getMaxX(); | 75 | double x1 = dataArea.getMaxX(); | ||||||||||||||||||||
65 | g2.setPaint(im.getOutlinePaint()); | 76 | g2.setPaint(im.getOutlinePaint()); | ||||||||||||||||||||
66 | g2.setStroke(im.getOutlineStroke()); | 77 | g2.setStroke(im.getOutlineStroke()); | ||||||||||||||||||||
67 | if (range.contains(start)) | 78 | if (range.contains(start)) | ||||||||||||||||||||
68 | line.setLine(x0, start2d, x1, start2d); | 79 | line.setLine(x0, start2d, x1, start2d); | ||||||||||||||||||||
69 | g2.draw(line); | 80 | g2.draw(line); | ||||||||||||||||||||
70 | if (range.contains(end)) | 81 | if (range.contains(end)) | ||||||||||||||||||||
71 | line.setLine(x0, end2d, x1, end2d); | 82 | line.setLine(x0, end2d, x1, end2d); | ||||||||||||||||||||
72 | g2.draw(line); | 83 | g2.draw(line); | ||||||||||||||||||||
else | else | ||||||||||||||||||||||
73 | Line2D line = new Line2D.Double(); | 62 | Line2D line = new Line2D.Double(); | ||||||||||||||||||||
74 | double y0 = dataArea.getMinY(); | 63 | double y0 = dataArea.getMinY(); | ||||||||||||||||||||
75 | double y1 = dataArea.getMaxY(); | 64 | double y1 = dataArea.getMaxY(); | ||||||||||||||||||||
76 | g2.setPaint(im.getOutlinePaint()); | 65 | g2.setPaint(im.getOutlinePaint()); | ||||||||||||||||||||
77 | g2.setStroke(im.getOutlineStroke()); | 66 | g2.setStroke(im.getOutlineStroke()); | ||||||||||||||||||||
78 | if (range.contains(start)) | 67 | if (range.contains(start)) | ||||||||||||||||||||
79 | line.setLine(start2d, y0, start2d, y1); | 68 | line.setLine(start2d, y0, start2d, y1); | ||||||||||||||||||||
80 | g2.draw(line); | 69 | g2.draw(line); | ||||||||||||||||||||
81 | if (range.contains(end)) | 70 | if (range.contains(end)) | ||||||||||||||||||||
82 | line.setLine(end2d, y0, end2d, y1); | 71 | line.setLine(end2d, y0, end2d, y1); | ||||||||||||||||||||
83 | g2.draw(line); | 72 | g2.draw(line); | ||||||||||||||||||||
84 | String label = marker.getLabel(); | 84 | String label = marker.getLabel(); | ||||||||||||||||||||
85 | RectangleAnchor anchor = marker.getLabelAnchor(); | 85 | RectangleAnchor anchor = marker.getLabelAnchor(); | ||||||||||||||||||||
86 | if (label != null) | 86 | if (label != null) | ||||||||||||||||||||
87 | Font labelFont = marker.getLabelFont(); | 87 | Font labelFont = marker.getLabelFont(); | ||||||||||||||||||||
88 | g2.setFont(labelFont); | 88 | g2.setFont(labelFont); | ||||||||||||||||||||
89 | g2.setPaint(marker.getLabelPaint()); | 89 | g2.setPaint(marker.getLabelPaint()); | ||||||||||||||||||||
90 | Point2D coordinates = calculateRangeMarkerTextAnchorPoint(g2, orientation, dataArea, rect, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor); |
| 90 | Point2D coordinates = calculateDomainMarkerTextAnchorPoint(g2, orientation, dataArea, rect, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor); | |||||||||||||||||||
91 | TextUtilities.drawAlignedString(label, g2, (float)coordinates.getX(), (float)coordinates.getY(), marker.getLabelTextAnchor()); | 91 | TextUtilities.drawAlignedString(label, g2, (float)coordinates.getX(), (float)coordinates.getY(), marker.getLabelTextAnchor()); | ||||||||||||||||||||
92 | g2.setComposite(savedComposite); |
| 92 | g2.setComposite(originalComposite); |
Row | Violation |
---|---|
1 | Conditional return; |
2 | Conditional return; |
3 | Expression plot.getRangeAxisEdge() is a method call throwing exception(s) that should be caught by a try block that will be extracted |
4 | Expression plot.getDomainAxisEdge() is a method call throwing exception(s) that should be caught by a try block 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 org.jfree.ui.RectangleEdge getRangeAxisEdge() , public org.jfree.ui.RectangleEdge getDomainAxisEdge() |
6 | Expression plot.getRangeAxisEdge() is a method call throwing exception(s) that should be caught by a try block that will be extracted |
7 | Expression plot.getDomainAxisEdge() is a method call throwing exception(s) that should be caught by a try block 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 org.jfree.ui.RectangleEdge getRangeAxisEdge() , public org.jfree.ui.RectangleEdge getDomainAxisEdge() |
9 | Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public org.jfree.chart.plot.PlotOrientation getOrientation() |
10 | Expression orientation == PlotOrientation.VERTICAL cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression orientation == PlotOrientation.VERTICAL cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression calculateRangeMarkerTextAnchorPoint(g2,orientation,dataArea,rect,marker.getLabelOffset(),marker.getLabelOffsetType(),anchor) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression calculateDomainMarkerTextAnchorPoint(g2,orientation,dataArea,rect,marker.getLabelOffset(),marker.getLabelOffsetType(),anchor) cannot be parameterized, because it has dependencies to/from statements that will be extracted |