annotate gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/PolygonRenderer.java @ 814:9d427dd2a96a

Added Javadoc in statistic package. gnv-artifacts/trunk@898 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 09 Apr 2010 14:34:45 +0000
parents feae2f9d6c6f
children 22c18083225e
rev   line source
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.jfreechart;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
3 import java.awt.BasicStroke;
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 import java.awt.Color;
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
5 import java.awt.Font;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
6 import java.awt.FontMetrics;
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import java.awt.Graphics2D;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 import java.awt.Paint;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 import java.awt.Shape;
447
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
10
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import java.awt.geom.GeneralPath;
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
12
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
13 import java.awt.geom.Rectangle2D.Double;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
14
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 import java.awt.geom.Rectangle2D;
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
16
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
17 import java.util.ArrayList;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
18
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
19 import org.apache.log4j.Logger;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
20
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
21 import org.jfree.chart.axis.ValueAxis;
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 import org.jfree.data.Range;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
25 import org.jfree.text.TextUtilities;
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
26
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
27 import org.jfree.ui.RectangleEdge;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
28
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 /**
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
30 * This renderer is used to draw polygons into a Graphics object.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 795
diff changeset
31 *
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
32 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
33 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 */
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 public class PolygonRenderer
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 {
447
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
37 private static Logger log = Logger.getLogger(
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
38 PolygonRenderer.class);
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
39
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
40 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
41 * This interfaces describes a single method to retrieve a Paint object
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
42 * for a given index.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
43 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
44 public interface PaintLookup {
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
46 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
47 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
48 * @param index Index.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
49 * @return Paint
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
50 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
51 Paint getPaint(int index);
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 } // interface PaintLookup
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
55 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
56 * This class is used to generate labels for a given series.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
57 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
58 public static class DefaultLabelGenerator
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
59 implements PolygonSeriesLabelGenerator
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
60 {
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
61 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
62 * Construts an empty DefaultLabelGenerator.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
63 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
64 public DefaultLabelGenerator() {
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
65 }
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
67 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
68 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
69 * @param series A PolygonSeries.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
70 * @return The label of series.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
71 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
72 public String generateLabel(PolygonSeries series) {
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
73 Object label = series.getAttribute("label");
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
74 return label != null
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
75 ? toString(label)
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
76 : null;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
77 }
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
79 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
80 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
81 * @param label Object
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
82 * @return String representaton of label.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
83 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
84 protected String toString(Object label) {
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
85 return label.toString();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
86 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
87 } // class DefaultLabelGenerator
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
89 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
90 * Constructor.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
91 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
92 public static final PolygonSeriesLabelGenerator
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
93 DEFAULT_LABEL_GENERATOR_INSTANCE = new DefaultLabelGenerator();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
94
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
95 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
96 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
97 */
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
98 protected PaintLookup lookup;
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
99 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
100 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
101 */
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
102 protected PolygonSeriesLabelGenerator labelGenerator;
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
104 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
105 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
106 * @param lookup
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
107 */
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 public PolygonRenderer(PaintLookup lookup) {
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
109 this(lookup, null);
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
112 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
113 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
114 * @param lookup
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
115 * @param labelGenerator
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
116 */
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
117 public PolygonRenderer(
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
118 PaintLookup lookup,
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
119 PolygonSeriesLabelGenerator labelGenerator
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
120 ) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
121 this.lookup = lookup;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
122 this.labelGenerator = labelGenerator;
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
125 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
126 * This method draws polygons of each series in <code>dataset</code> into
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
127 * the given graphics object. If a polygon has no attribute 'fill', we
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
128 * expect that it is a line, otherwise the polygon is filled.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
129 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
130 * @param graphics
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
131 * @param plot
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
132 * @param area
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
133 * @param dataset
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
134 */
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
135 public void drawPolygons(
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 Graphics2D graphics,
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
137 PolygonPlot plot,
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
138 Rectangle2D area,
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 PolygonDataset dataset
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 ) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 int seriesCount = dataset.getSeriesCount();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 for (int i = 0; i < seriesCount; i++) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 PolygonSeries series = dataset.getSeries(i);
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 Integer colorIdx = (Integer)series.getAttribute("fill");
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 if (colorIdx != null) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 Paint paint = lookup.getPaint(colorIdx.intValue());
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 graphics.setPaint(paint != null ? paint : Color.black);
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
149 graphics.fill(constructShape(plot, area, series, true));
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151 else {
447
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
152 Number lineWidth = (Number)series.getAttribute("line.width");
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
153 BasicStroke stroke = new BasicStroke(
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
154 lineWidth != null ? lineWidth.floatValue() : 1f);
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
155 graphics.setStroke(stroke);
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 graphics.setPaint(Color.black);
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
157 graphics.draw(constructShape(plot, area, series, false));
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 }
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
160 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
161
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
162 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
163 * Draw labels at each item of a series in the given dataset. If the series
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
164 * has no label attritue, no label is drawn.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 795
diff changeset
165 *
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
166 * @param graphics
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
167 * @param plot
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
168 * @param area
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
169 * @param dataset
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
170 */
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
171 public void drawLabels(
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
172 final Graphics2D graphics,
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
173 final PolygonPlot plot,
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
174 final Rectangle2D area,
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
175 PolygonDataset dataset
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
176 ) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
177 if (labelGenerator == null) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
178 return;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
179 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
180
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
181 final ArrayList<Rectangle2D> bboxes = new ArrayList<Rectangle2D>();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
182
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
183 Font font = graphics.getFont();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
184 font = font.deriveFont(Font.PLAIN, Math.max(8, font.getSize()-3));
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
185 graphics.setFont(font);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
186 FontMetrics metrics = graphics.getFontMetrics(font);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
187
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
188 for (int i = dataset.getSeriesCount()-1; i >= 0; --i) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
189 PolygonSeries series = dataset.getSeries(i);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
190
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
191 String label = labelGenerator.generateLabel(series);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
192 if (label == null) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
193 continue;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
194 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
195
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
196 final Rectangle2D box = TextUtilities.getTextBounds(
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
197 label, graphics, metrics);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
198
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
199 for (int j = series.getItemCount()-1; j >= 0; --j) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
200 final CompactXYItems ring = series.getItem(j);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
201 LevelOrderIndices loi = new LevelOrderIndices(ring.size()-1);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
202 Rectangle2D r = (Rectangle2D)loi.visit(
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
203 new LevelOrderIndices.Visitor()
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
204 {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
205 ValueAxis da = plot.getDomainAxis();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
206 ValueAxis ra = plot.getRangeAxis();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
207 RectangleEdge de = plot.getDomainAxisEdge();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
208 RectangleEdge re = plot.getRangeAxisEdge();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
209 Rectangle2D.Double r = new Rectangle2D.Double(
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
210 0d, 0d, box.getWidth(), box.getHeight());
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
211
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
212 public Object visit(int index) {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
213 r.x = da.valueToJava2D(ring.getX(index), area, de)
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
214 - 0.5*box.getWidth();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
215 r.y = ra.valueToJava2D(ring.getY(index), area, re)
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
216 + 0.5*box.getHeight();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
217
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
218 for (Rectangle2D b: bboxes) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
219 if (b.intersects(r)) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
220 return null;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
221 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
222 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
223 return r;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
224 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
225 });
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
226
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
227 if (r != null) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
228 bboxes.add(r);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
229 graphics.drawString(
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
230 label, (float)r.getX(), (float)r.getY());
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
231 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
232 } // for all items in series
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
233 } // for all series
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
236 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
237 * Creates a shape made up of the CompactXYItems object stored in the given
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
238 * series.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
239 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
240 * @param plot The plot.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
241 * @param area The boundary.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
242 * @param series The series storing the items.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
243 * @param close Specifies if the polygon should be closed or not.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
244 * @return
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
245 */
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
246 protected Shape constructShape(
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
247 PolygonPlot plot,
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
248 Rectangle2D area,
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
249 PolygonSeries series,
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
250 boolean close
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
251 ) {
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
252 ValueAxis da = plot.getDomainAxis();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
253 ValueAxis ra = plot.getRangeAxis();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
254 RectangleEdge de = plot.getDomainAxisEdge();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
255 RectangleEdge re = plot.getRangeAxisEdge();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
256
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
257 CompactXYItems [] rings = series.getRings();
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
258 GeneralPath path = new GeneralPath();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
259
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
260 for (int i = 0; i < rings.length; ++i) {
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
261
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 CompactXYItems ring = rings[i];
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
263
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
264 double [] data = ring.getData();
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
265
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266 if (data.length >= 2) {
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
267 path.moveTo(
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
268 (float)da.valueToJava2D(data[0], area, de),
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
269 (float)ra.valueToJava2D(data[1], area, re));
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
270 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
271 for (int j = 2; j < data.length;) {
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
272 path.lineTo(
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
273 (float)da.valueToJava2D(data[j++], area, de),
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
274 (float)ra.valueToJava2D(data[j++], area, re));
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275 }
437
b624879d2902 Added vectorizer rings callback to generate iso lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 422
diff changeset
276 if (close) {
b624879d2902 Added vectorizer rings callback to generate iso lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 422
diff changeset
277 path.closePath();
b624879d2902 Added vectorizer rings callback to generate iso lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 422
diff changeset
278 }
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
279 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
280 return path;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
281 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
282
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
283 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
284 * Retrieves the bounding box of a dataset.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
285 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
286 * @param dataset
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
287 * @return
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
288 */
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
289 public Rectangle2D getBoundingBox(PolygonDataset dataset) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
290 Rectangle2D bbox = null;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
291
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
292 for (int i = 0, N = dataset.getSeriesCount(); i < N; i++) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
293 Range domain = dataset.getSeries(i).getDomainBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
294 Range range = dataset.getSeries(i).getRangeBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
295
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
296 double x = domain.getLowerBound();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
297 double y = range.getLowerBound();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
298 double w = Math.abs(domain.getUpperBound() - x);
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
299 double h = Math.abs(range.getUpperBound() - y);
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
300
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
301 if (bbox == null) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
302 bbox = new Rectangle2D.Double(x, y, w, h);
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
303 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
304 else {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
305 bbox.add(new Rectangle2D.Double(x, y, w, h));
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
306 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
307 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
308
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
309 return bbox;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
310 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
311
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
312 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
313 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
314 * @param series
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
315 * @return the bounds of a series.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
316 */
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
317 public Rectangle2D getBounds(PolygonSeries series) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
318
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
319 Range domain = series.getDomainBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
320 Range range = series.getRangeBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
321
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
322 return new Rectangle2D.Double(
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
323 domain.getLowerBound(), range.getLowerBound(),
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
324 domain.getUpperBound(), range.getUpperBound()
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
325 );
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
326 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
327 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
328 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org