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 drawRangeMarker(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 = rangeAxis.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 = rangeAxis.valueToJava2D(start, dataArea,↵ | |
13 | plot.getRangeAxisEdge());↵ | 10 | plot.getRangeAxisEdge());↵ | |
14 | double end2d = axis.valueToJava2D(end, dataArea,↵ | 11 | double end2d = rangeAxis.valueToJava2D(end, dataArea,↵ | |
15 | plot.getRangeAxisEdge());↵ | 12 | plot.getRangeAxisEdge());↵ | |
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 left and right bounds to data area↵ | |
22 | low = Math.max(low, dataArea.getMinX());↵ | 19 | low = Math.max(low, dataArea.getMinX());↵ | |
23 | high = Math.min(high, dataArea.getMaxX());↵ | 20 | high = Math.min(high, dataArea.getMaxX());↵ | |
24 | rect = new Rectangle2D.Double(low,↵ | 21 | rect = new Rectangle2D.Double(low,↵ | |
25 | dataArea.getMinY(), high - low,↵ | 22 | dataArea.getMinY(), high - low,↵ | |
26 | dataArea.getHeight());↵ | 23 | dataArea.getHeight());↵ | |
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 top and bottom bounds to data area↵ | |
30 | low = Math.max(low, dataArea.getMinY());↵ | 27 | low = Math.max(low, dataArea.getMinY());↵ | |
31 | high = Math.min(high, dataArea.getMaxY());↵ | 28 | high = Math.min(high, dataArea.getMaxY());↵ | |
32 | rect = new Rectangle2D.Double(dataArea.getMinX(),↵ | 29 | rect = new Rectangle2D.Double(dataArea.getMinX(),↵ | |
33 | low, dataArea.getWidth(),↵ | 30 | low, dataArea.getWidth(),↵ | |
34 | high - low);↵ | 31 | high - low);↵ | |
35 | } ↵ | 32 | } ↵ | |
33 | final Composite originalComposite = g2.getComposite();↵ | |||
34 | g2.setComposite(AlphaComposite.getInstance(↵ | |||
35 | AlphaComposite.SRC_OVER, marker.getAlpha())); ↵ | |||
36 | Paint p = marker.getPaint();↵ | 36 | Paint p = marker.getPaint();↵ | |
37 | if (p instanceof GradientPaint) {↵ | 37 | if (p instanceof GradientPaint) {↵ | |
38 | GradientPaint gp = (GradientPaint) p;↵ | 38 | GradientPaint gp = (GradientPaint) p;↵ | |
39 | GradientPaintTransformer t = im.getGradientPaintTransformer();↵ | 39 | GradientPaintTransformer t = im.getGradientPaintTransformer();↵ | |
40 | if (t != null) {↵ | 40 | if (t != null) {↵ | |
41 | gp = t.transform(gp, rect);↵ | 41 | gp = t.transform(gp, rect);↵ | |
42 | }↵ | 42 | }↵ | |
43 | g2.setPaint(gp);↵ | 43 | g2.setPaint(gp);↵ | |
44 | }↵ | 44 | }↵ | |
45 | else {↵ | 45 | else {↵ | |
46 | g2.setPaint(p);↵ | 46 | g2.setPaint(p);↵ | |
47 | }↵ | 47 | }↵ | |
48 | g2.fill(rect);↵ | 48 | g2.fill(rect);↵ | |
49 | // now draw the outlines, if visible...↵ | 49 | // now draw the outlines, if visible...↵ | |
50 | if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) {↵ | 50 | if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) {↵ | |
51 | if (orientation == PlotOrientation.VERTICAL) {↵ | 51 | if (orientation == PlotOrientation.VERTICAL) {↵ | |
52 | Line2D line = new Line2D.Double();↵ | 52 | Line2D line = new Line2D.Double();↵ | |
53 | double x0 = dataArea.getMinX();↵ | 53 | double x0 = dataArea.getMinX();↵ | |
54 | double x1 = dataArea.getMaxX();↵ | 54 | double x1 = dataArea.getMaxX();↵ | |
55 | g2.setPaint(im.getOutlinePaint());↵ | 55 | g2.setPaint(im.getOutlinePaint());↵ | |
56 | g2.setStroke(im.getOutlineStroke());↵ | 56 | g2.setStroke(im.getOutlineStroke());↵ | |
57 | if (range.contains(start)) {↵ | 57 | if (range.contains(start)) {↵ | |
58 | line.setLine(x0, start2d, x1, start2d);↵ | 58 | line.setLine(x0, start2d, x1, start2d);↵ | |
59 | g2.draw(line);↵ | 59 | g2.draw(line);↵ | |
60 | }↵ | 60 | }↵ | |
61 | if (range.contains(end)) {↵ | 61 | if (range.contains(end)) {↵ | |
62 | line.setLine(x0, end2d, x1, end2d);↵ | 62 | line.setLine(x0, end2d, x1, end2d);↵ | |
63 | g2.draw(line);↵ | 63 | g2.draw(line);↵ | |
64 | }↵ | 64 | }↵ | |
65 | }↵ | 65 | }↵ | |
66 | else { // PlotOrientation.HORIZONTAL↵ | 66 | else { // PlotOrientation.HORIZONTAL↵ | |
67 | Line2D line = new Line2D.Double();↵ | 67 | Line2D line = new Line2D.Double();↵ | |
68 | double y0 = dataArea.getMinY();↵ | 68 | double y0 = dataArea.getMinY();↵ | |
69 | double y1 = dataArea.getMaxY();↵ | 69 | double y1 = dataArea.getMaxY();↵ | |
70 | g2.setPaint(im.getOutlinePaint());↵ | 70 | g2.setPaint(im.getOutlinePaint());↵ | |
71 | g2.setStroke(im.getOutlineStroke());↵ | 71 | g2.setStroke(im.getOutlineStroke());↵ | |
72 | if (range.contains(start)) {↵ | 72 | if (range.contains(start)) {↵ | |
73 | line.setLine(start2d, y0, start2d, y1);↵ | 73 | line.setLine(start2d, y0, start2d, y1);↵ | |
74 | g2.draw(line);↵ | 74 | g2.draw(line);↵ | |
75 | }↵ | 75 | }↵ | |
76 | if (range.contains(end)) {↵ | 76 | if (range.contains(end)) {↵ | |
77 | line.setLine(end2d, y0, end2d, y1);↵ | 77 | line.setLine(end2d, y0, end2d, y1);↵ | |
78 | g2.draw(line);↵ | 78 | g2.draw(line);↵ | |
79 | }↵ | 79 | }↵ | |
80 | }↵ | 80 | }↵ | |
81 | }↵ | 81 | }↵ | |
82 | String label = marker.getLabel();↵ | 82 | String label = marker.getLabel();↵ | |
83 | RectangleAnchor anchor = marker.getLabelAnchor();↵ | 83 | RectangleAnchor anchor = marker.getLabelAnchor();↵ | |
84 | if (label != null) {↵ | 84 | if (label != null) {↵ | |
85 | Font labelFont = marker.getLabelFont();↵ | 85 | Font labelFont = marker.getLabelFont();↵ | |
86 | g2.setFont(labelFont);↵ | 86 | g2.setFont(labelFont);↵ | |
87 | g2.setPaint(marker.getLabelPaint());↵ | 87 | g2.setPaint(marker.getLabelPaint());↵ | |
88 | Point2D coordinates = calculateRangeMarkerTextAnchorPoint(↵ | 88 | Point2D coordinates = calculateRangeMarkerTextAnchorPoint(↵ | |
89 | g2, orientation, dataArea, rect,↵ | 89 | g2, orientation, dataArea, rect,↵ | |
90 | marker.getLabelOffset(), marker.getLabelOffsetType(),↵ | 90 | marker.getLabelOffset(), marker.getLabelOffsetType(),↵ | |
91 | anchor);↵ | 91 | anchor);↵ | |
92 | TextUtilities.drawAlignedString(label, g2,↵ | 92 | TextUtilities.drawAlignedString(label, g2,↵ | |
93 | (float) coordinates.getX(), (float) coordinates.getY(),↵ | 93 | (float) coordinates.getX(), (float) coordinates.getY(),↵ | |
94 | marker.getLabelTextAnchor());↵ | 94 | marker.getLabelTextAnchor());↵ | |
95 | }↵ | 95 | }↵ | |
96 | g2.setComposite(savedComposite);↵ | 96 | g2.setComposite(originalComposite);↵ | |
97 | } | 97 |
| |
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) | 6.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 666 |
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) | 140.4 |
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 = rangeAxis.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 = rangeAxis.valueToJava2D(start, dataArea, plot.getRangeAxisEdge()); | ||||||||||||||
38 | double end2d = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); |
| 36 | double end2d = rangeAxis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); | ||||||||||||||
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) | 41 | if (orientation == PlotOrientation.HORIZONTAL) | |||||||||||||||
44 | low = Math.max(low, dataArea.getMinX()); | 42 | low = Math.max(low, dataArea.getMinX()); | |||||||||||||||
45 | high = Math.min(high, dataArea.getMaxX()); | 43 | high = Math.min(high, dataArea.getMaxX()); | |||||||||||||||
46 | rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); | 44 | rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); | |||||||||||||||
47 | else if (orientation == PlotOrientation.VERTICAL) | 45 | else if (orientation == PlotOrientation.VERTICAL) | |||||||||||||||
48 | low = Math.max(low, dataArea.getMinY()); | 46 | low = Math.max(low, dataArea.getMinY()); | |||||||||||||||
49 | high = Math.min(high, dataArea.getMaxY()); | 47 | high = Math.min(high, dataArea.getMaxY()); | |||||||||||||||
50 | rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); | 48 | 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(); | 62 | Line2D line = new Line2D.Double(); | |||||||||||||||
63 | double x0 = dataArea.getMinX(); | 63 | double x0 = dataArea.getMinX(); | |||||||||||||||
64 | double x1 = dataArea.getMaxX(); | 64 | double x1 = dataArea.getMaxX(); | |||||||||||||||
65 | g2.setPaint(im.getOutlinePaint()); | 65 | g2.setPaint(im.getOutlinePaint()); | |||||||||||||||
66 | g2.setStroke(im.getOutlineStroke()); | 66 | g2.setStroke(im.getOutlineStroke()); | |||||||||||||||
67 | if (range.contains(start)) | 67 | if (range.contains(start)) | |||||||||||||||
68 | line.setLine(x0, start2d, x1, start2d); | 68 | line.setLine(x0, start2d, x1, start2d); | |||||||||||||||
69 | g2.draw(line); | 69 | g2.draw(line); | |||||||||||||||
70 | if (range.contains(end)) | 70 | if (range.contains(end)) | |||||||||||||||
71 | line.setLine(x0, end2d, x1, end2d); | 71 | line.setLine(x0, end2d, x1, end2d); | |||||||||||||||
72 | g2.draw(line); | 72 | g2.draw(line); | |||||||||||||||
else | else | |||||||||||||||||
73 | Line2D line = new Line2D.Double(); | 73 | Line2D line = new Line2D.Double(); | |||||||||||||||
74 | double y0 = dataArea.getMinY(); | 74 | double y0 = dataArea.getMinY(); | |||||||||||||||
75 | double y1 = dataArea.getMaxY(); | 75 | double y1 = dataArea.getMaxY(); | |||||||||||||||
76 | g2.setPaint(im.getOutlinePaint()); | 76 | g2.setPaint(im.getOutlinePaint()); | |||||||||||||||
77 | g2.setStroke(im.getOutlineStroke()); | 77 | g2.setStroke(im.getOutlineStroke()); | |||||||||||||||
78 | if (range.contains(start)) | 78 | if (range.contains(start)) | |||||||||||||||
79 | line.setLine(start2d, y0, start2d, y1); | 79 | line.setLine(start2d, y0, start2d, y1); | |||||||||||||||
80 | g2.draw(line); | 80 | g2.draw(line); | |||||||||||||||
81 | if (range.contains(end)) | 81 | if (range.contains(end)) | |||||||||||||||
82 | line.setLine(end2d, y0, end2d, y1); | 82 | line.setLine(end2d, y0, end2d, y1); | |||||||||||||||
83 | g2.draw(line); | 83 | 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 = calculateRangeMarkerTextAnchorPoint(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 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() |
4 | 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() |
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.chart.plot.PlotOrientation getOrientation() |