File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java | File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java | |||
Method name: void drawDomainMarker(Graphics2D, XYPlot, 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 = domainAxis.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 | double start2d = domainAxis.valueToJava2D(start, dataArea,↵ | 9 | double start2d = rangeAxis.valueToJava2D(start, dataArea,↵ | |
10 | plot.getDomainAxisEdge());↵ | 10 | plot.getRangeAxisEdge());↵ | |
11 | double end2d = domainAxis.valueToJava2D(end, dataArea,↵ | 11 | double end2d = rangeAxis.valueToJava2D(end, dataArea,↵ | |
12 | plot.getDomainAxisEdge());↵ | 12 | plot.getRangeAxisEdge());↵ | |
13 | double low = Math.min(start2d, end2d);↵ | 13 | double low = Math.min(start2d, end2d);↵ | |
14 | double high = Math.max(start2d, end2d);↵ | 14 | double high = Math.max(start2d, end2d);↵ | |
15 | PlotOrientation orientation = plot.getOrientation();↵ | 15 | PlotOrientation orientation = plot.getOrientation();↵ | |
16 | Rectangle2D rect = null;↵ | 16 | Rectangle2D rect = null;↵ | |
17 | if (orientation == PlotOrientation.HORIZONTAL) {↵ | 17 | if (orientation == PlotOrientation.HORIZONTAL) {↵ | |
18 | // clip top and bottom bounds to data area↵ | 18 | // clip left and right bounds to data area↵ | |
19 | low = Math.max(low, dataArea.getMinY());↵ | 19 | low = Math.max(low, dataArea.getMinX());↵ | |
20 | high = Math.min(high, dataArea.getMaxY());↵ | 20 | high = Math.min(high, dataArea.getMaxX());↵ | |
21 | rect = new Rectangle2D.Double(dataArea.getMinX(),↵ | 21 | rect = new Rectangle2D.Double(low,↵ | |
22 | low, dataArea.getWidth(),↵ | 22 | dataArea.getMinY(), high - low,↵ | |
23 | high - low);↵ | 23 | dataArea.getHeight());↵ | |
24 | }↵ | 24 | }↵ | |
25 | else if (orientation == PlotOrientation.VERTICAL) {↵ | 25 | else if (orientation == PlotOrientation.VERTICAL) {↵ | |
26 | // clip left and right bounds to data area↵ | 26 | // clip top and bottom bounds to data area↵ | |
27 | low = Math.max(low, dataArea.getMinX());↵ | 27 | low = Math.max(low, dataArea.getMinY());↵ | |
28 | high = Math.min(high, dataArea.getMaxX());↵ | 28 | high = Math.min(high, dataArea.getMaxY());↵ | |
29 | rect = new Rectangle2D.Double(low,↵ | 29 | rect = new Rectangle2D.Double(dataArea.getMinX(),↵ | |
30 | dataArea.getMinY(), high - low,↵ | 30 | low, dataArea.getWidth(),↵ | |
31 | dataArea.getHeight());↵ | 31 | high - low);↵ | |
32 | }↵ | 32 | }↵ | |
33 | final Composite originalComposite = g2.getComposite();↵ | 33 | final Composite originalComposite = g2.getComposite();↵ | |
34 | g2.setComposite(AlphaComposite.getInstance(↵ | 34 | g2.setComposite(AlphaComposite.getInstance(↵ | |
35 | AlphaComposite.SRC_OVER, marker.getAlpha()));↵ | 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 y0 = dataArea.getMinY();↵ | 53 | double x0 = dataArea.getMinX();↵ | |
54 | double y1 = dataArea.getMaxY();↵ | 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(start2d, y0, start2d, y1);↵ | 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(end2d, y0, end2d, y1);↵ | 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 x0 = dataArea.getMinX();↵ | 68 | double y0 = dataArea.getMinY();↵ | |
69 | double x1 = dataArea.getMaxX();↵ | 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(x0, start2d, x1, start2d);↵ | 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(x0, end2d, x1, end2d);↵ | 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 = calculateDomainMarkerTextAnchorPoint(↵ | 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(originalComposite);↵ | 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) | 3.9 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 671 |
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) | 44.2 |
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 = domainAxis.getRange(); |
| 32 | Range range = rangeAxis.getRange(); | |||||||||||||
33 | if (!(range.intersects(start, end))) | 33 | if (!(range.intersects(start, end))) | ||||||||||||||
34 | return; |
| 34 | return; | |||||||||||||
35 | double start2d = domainAxis.valueToJava2D(start, dataArea, plot.getDomainAxisEdge()); |
| 35 | double start2d = rangeAxis.valueToJava2D(start, dataArea, plot.getRangeAxisEdge()); | |||||||||||||
36 | double end2d = domainAxis.valueToJava2D(end, dataArea, plot.getDomainAxisEdge()); |
| 36 | double end2d = rangeAxis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); | |||||||||||||
37 | double low = Math.min(start2d, end2d); | 37 | double low = Math.min(start2d, end2d); | ||||||||||||||
38 | double high = Math.max(start2d, end2d); | 38 | double high = Math.max(start2d, end2d); | ||||||||||||||
39 | PlotOrientation orientation = plot.getOrientation(); | 39 | PlotOrientation orientation = plot.getOrientation(); | ||||||||||||||
40 | Rectangle2D rect = null; | 40 | Rectangle2D rect = null; | ||||||||||||||
41 | if (orientation == PlotOrientation.HORIZONTAL) |
| 45 | if (orientation == PlotOrientation.VERTICAL) | |||||||||||||
42 | low = Math.max(low, dataArea.getMinY()); | 46 | low = Math.max(low, dataArea.getMinY()); | ||||||||||||||
43 | high = Math.min(high, dataArea.getMaxY()); | 47 | high = Math.min(high, dataArea.getMaxY()); | ||||||||||||||
44 | rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); | 48 | rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); | ||||||||||||||
45 | else if (orientation == PlotOrientation.VERTICAL) |
| 41 | else if (orientation == PlotOrientation.HORIZONTAL) | |||||||||||||
46 | low = Math.max(low, dataArea.getMinX()); | 42 | low = Math.max(low, dataArea.getMinX()); | ||||||||||||||
47 | high = Math.min(high, dataArea.getMaxX()); | 43 | high = Math.min(high, dataArea.getMaxX()); | ||||||||||||||
48 | rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); | 44 | rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); | ||||||||||||||
49 | final Composite originalComposite = g2.getComposite(); | 49 | final Composite originalComposite = g2.getComposite(); | ||||||||||||||
50 | g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha())); | 50 | g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha())); | ||||||||||||||
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 y0 = dataArea.getMinY(); | 74 | double y0 = dataArea.getMinY(); | ||||||||||||||
64 | double y1 = dataArea.getMaxY(); | 75 | double y1 = dataArea.getMaxY(); | ||||||||||||||
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(start2d, y0, start2d, y1); | 79 | line.setLine(start2d, y0, start2d, y1); | ||||||||||||||
69 | g2.draw(line); | 80 | g2.draw(line); | ||||||||||||||
70 | if (range.contains(end)) | 81 | if (range.contains(end)) | ||||||||||||||
71 | line.setLine(end2d, y0, end2d, y1); | 82 | line.setLine(end2d, y0, end2d, y1); | ||||||||||||||
72 | g2.draw(line); | 83 | g2.draw(line); | ||||||||||||||
else | else | ||||||||||||||||
73 | Line2D line = new Line2D.Double(); | 62 | Line2D line = new Line2D.Double(); | ||||||||||||||
74 | double x0 = dataArea.getMinX(); | 63 | double x0 = dataArea.getMinX(); | ||||||||||||||
75 | double x1 = dataArea.getMaxX(); | 64 | double x1 = dataArea.getMaxX(); | ||||||||||||||
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(x0, start2d, x1, start2d); | 68 | line.setLine(x0, start2d, x1, start2d); | ||||||||||||||
80 | g2.draw(line); | 69 | g2.draw(line); | ||||||||||||||
81 | if (range.contains(end)) | 70 | if (range.contains(end)) | ||||||||||||||
82 | line.setLine(x0, end2d, x1, end2d); | 71 | line.setLine(x0, end2d, x1, end2d); | ||||||||||||||
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 = calculateDomainMarkerTextAnchorPoint(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(originalComposite); | 92 | g2.setComposite(originalComposite); |
Row | Violation |
---|---|
1 | Conditional return; |
2 | Conditional return; |
3 | Expression orientation == PlotOrientation.VERTICAL cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression orientation == PlotOrientation.VERTICAL cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | 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 |
6 | 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 |