Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java @ 3166:591be3486087
FixA: Prevent that the plot becomes to small if only one point is drawn.
flys-artifacts/trunk@4779 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 25 Jun 2012 15:03:57 +0000 |
parents | 6d0567a8387d |
children | 0cf647fe2a96 |
rev | line source |
---|---|
3162
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.jfree; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 /** |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 * Copyright (c) 2006, 2012 by Intevation GmbH |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 * |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 * @author Sascha L. Teichmann (teichmann@intevation.de) |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 * |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 * This program is free software under the LGPL (>=v2.1) |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 * Read the file LGPL coming with FLYS for details. |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 */ |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import java.awt.Font; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import java.awt.Graphics2D; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import java.awt.Paint; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import java.awt.Shape; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import java.awt.geom.Point2D; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import java.awt.geom.Rectangle2D; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import java.util.ArrayList; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import java.util.List; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 import java.util.Map; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 import org.jfree.chart.axis.ValueAxis; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 import org.jfree.chart.labels.ItemLabelPosition; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 import org.jfree.chart.labels.XYItemLabelGenerator; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 import org.jfree.chart.plot.CrosshairState; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 import org.jfree.chart.plot.PlotOrientation; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 import org.jfree.chart.plot.PlotRenderingInfo; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 import org.jfree.chart.plot.XYPlot; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 import org.jfree.chart.renderer.xy.StandardXYItemRenderer; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 import org.jfree.chart.renderer.xy.XYItemRendererState; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 import org.jfree.data.xy.XYDataset; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 import org.jfree.text.TextUtilities; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 import org.jfree.ui.RectangleEdge; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public class ShapeRenderer |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 extends StandardXYItemRenderer { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 public static class Entry { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 protected Shape shape; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 protected Shape frame; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 protected Paint paint; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 protected boolean filled; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 public Entry( |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 Shape shape, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 Paint paint, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 boolean filled |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 ) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 this.shape = shape; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 this.paint = paint; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 this.filled = filled; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 public Entry( |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 Shape shape, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 Shape frame, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 Paint paint, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 boolean filled |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 ) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 this.shape = shape; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 this.frame = frame; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 this.paint = paint; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 this.filled = filled; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 public Shape getShape() { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 return shape; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 public void setShape(Shape shape) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 this.shape = shape; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 public Paint getPaint() { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 return paint; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 public void setPaint(Paint paint) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 this.paint = paint; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 public boolean getFilled() { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 return filled; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 public void setFilled(boolean filled) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 this.filled = filled; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 public boolean equals(Object other) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 Entry entry = (Entry)other; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 return filled == entry.filled |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 && paint.equals(entry.paint) |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 && shape.equals(entry.shape); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 public int hashCode() { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 return |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 shape.hashCode() ^ |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 paint.hashCode() ^ |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 (filled ? 1231 : 1237); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 } // class Entry |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 protected Entry [] entries; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 protected List<Rectangle2D> labelBoundingBoxes; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 protected Rectangle2D area; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 public ShapeRenderer() { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 this(SHAPES); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 public ShapeRenderer(int type) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 super(type); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 public ShapeRenderer(Map<Entry, Integer> map) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 super(SHAPES); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 setEntries(map); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 public void setEntries(Entry [] entries) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 this.entries = entries; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 public void setEntries(Map<Entry, Integer> map) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 Entry [] entries = new Entry[map.size()]; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 for (Map.Entry<Entry, Integer> entry: map.entrySet()) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 entries[entry.getValue()] = entry.getKey(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 setEntries(entries); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 @Override |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 public Shape getSeriesShape(int series) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 return entries[series].shape; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 public Shape getSeriesFrame(int series) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 return entries[series].frame; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 @Override |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 public Paint getSeriesPaint(int series) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 return entries[series].paint; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 @Override |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 public boolean getItemShapeFilled(int series, int item) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 return entries[series].filled; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 @Override |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 public XYItemRendererState initialise( |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 Graphics2D g2, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 Rectangle2D dataArea, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 XYPlot plot, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 XYDataset data, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 PlotRenderingInfo info |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 ) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 if (labelBoundingBoxes == null) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 labelBoundingBoxes = new ArrayList<Rectangle2D>(32); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 else { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 labelBoundingBoxes.clear(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 area = dataArea; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 return super.initialise(g2, dataArea, plot, data, info); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 @Override |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 public void drawItem( |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 Graphics2D g2, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 XYItemRendererState state, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 Rectangle2D dataArea, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 PlotRenderingInfo info, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 XYPlot plot, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 ValueAxis domainAxis, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 ValueAxis rangeAxis, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 XYDataset dataset, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 int series, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 int item, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 CrosshairState crosshairState, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 int pass |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 ) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 if (!getItemVisible(series, item)) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
202 return; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 // get the data point... |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 double x1 = dataset.getXValue(series, item); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 double y1 = dataset.getYValue(series, item); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 if (Double.isNaN(x1) || Double.isNaN(y1)) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
209 return; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 double x = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 double y = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
217 if (dataArea.contains(x, y)) |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
218 super.drawItem( |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 g2, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 state, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
221 dataArea, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
222 info, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 plot, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 domainAxis, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 rangeAxis, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
226 dataset, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 series, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 item, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
229 crosshairState, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
230 pass); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
231 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
232 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
233 protected Point2D shiftBox(Rectangle2D box) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
234 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
235 double cx1 = area.getX(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
236 double cy1 = area.getY(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
237 double cx2 = cx1 + area.getWidth(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 double cy2 = cy1 + area.getHeight(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
239 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
240 double bx1 = box.getX(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 double by1 = box.getY(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 double bx2 = bx1 + box.getWidth(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
243 double by2 = by1 + box.getHeight(); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 double dx; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 double dy; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
248 if (bx1 < cx1) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
249 dx = cx1 - bx1; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 else if (bx2 > cx2) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 dx = cx2 - bx2; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
253 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 else { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 dx = 0d; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 if (by1 < cy1) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 dy = cy1 - by1; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 else if (by2 > cy2) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 dy = cy2 - by2; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
264 else { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
265 dy = 0d; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
266 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
267 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
268 return new Point2D.Double(dx, dy); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
269 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
270 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
271 @Override |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
272 protected void drawItemLabel( |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
273 Graphics2D g2, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
274 PlotOrientation orientation, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
275 XYDataset dataset, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
276 int series, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
277 int item, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
278 double x, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
279 double y, |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
280 boolean negative |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
281 ) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
282 XYItemLabelGenerator generator = getItemLabelGenerator(series, item); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
283 if (generator == null) { |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
284 return; |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
285 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
286 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
287 Font labelFont = getItemLabelFont(series, item); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
288 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
289 Paint paint = getItemLabelPaint(series, item); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
290 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
291 g2.setFont(labelFont); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
292 g2.setPaint(paint); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
293 |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
294 String label = generator.generateLabel(dataset, series, item); |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
295 |
3164
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
296 ATTEMPS: for (int attempt = 0; attempt < 2; ++attempt) { |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
297 // get the label position.. |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
298 ItemLabelPosition position = null; |
3162
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
299 |
3164
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
300 boolean pos; |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
301 switch (attempt) { |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
302 case 0: pos = negative; break; |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
303 case 1: pos = !negative; break; |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
304 default: break ATTEMPS; |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
305 } |
3162
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
306 |
3164
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
307 if (pos) { |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
308 position = getNegativeItemLabelPosition(series, item); |
3162
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
309 } |
3164
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
310 else { |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
311 position = getPositiveItemLabelPosition(series, item); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
312 } |
3162
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
313 |
3164
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
314 // work out the label anchor point... |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
315 Point2D anchorPoint = calculateLabelAnchorPoint( |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
316 position.getItemLabelAnchor(), x, y, orientation); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
317 |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
318 Shape labelShape = TextUtilities.calculateRotatedStringBounds( |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
319 label, g2, |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
320 (float)anchorPoint.getX(), (float)anchorPoint.getY(), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
321 position.getTextAnchor(), position.getAngle(), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
322 position.getRotationAnchor()); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
323 |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
324 Rectangle2D bbox = labelShape.getBounds2D(); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
325 |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
326 Point2D shift = shiftBox(bbox); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
327 |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
328 bbox = new Rectangle2D.Double( |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
329 bbox.getX() + shift.getX(), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
330 bbox.getY() + shift.getY(), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
331 bbox.getWidth(), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
332 bbox.getHeight()); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
333 |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
334 if (labelBoundingBoxes != null) { |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
335 for (Rectangle2D old: labelBoundingBoxes) { |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
336 if (old.intersects(bbox)) { |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
337 continue ATTEMPS; |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
338 } |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
339 } |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
340 labelBoundingBoxes.add(bbox); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
341 } |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
342 |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
343 TextUtilities.drawRotatedString( |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
344 label, g2, |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
345 (float)(anchorPoint.getX() + shift.getX()), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
346 (float)(anchorPoint.getY() + shift.getY()), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
347 position.getTextAnchor(), position.getAngle(), |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
348 position.getRotationAnchor()); |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
349 break; |
6d0567a8387d
Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3162
diff
changeset
|
350 } |
3162
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
351 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
352 } |
0d8146989012
Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
353 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |