annotate gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/PolygonRenderer.java @ 1092:a45908c89997

Added missing configuration for 'Achsenparallele Vertikalprofile. gnv-artifacts/trunk@1207 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 14 Jun 2010 06:07:13 +0000
parents 22c18083225e
children f953c9a559d8
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 protected PaintLookup lookup;
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
96
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
97 protected PolygonSeriesLabelGenerator labelGenerator;
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
99
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 public PolygonRenderer(PaintLookup lookup) {
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
101 this(lookup, null);
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
104
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
105 public PolygonRenderer(
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
106 PaintLookup lookup,
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
107 PolygonSeriesLabelGenerator labelGenerator
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
108 ) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
109 this.lookup = lookup;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
110 this.labelGenerator = labelGenerator;
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112
795
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 * 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
115 * 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
116 * 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
117 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
118 */
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
119 public void drawPolygons(
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 Graphics2D graphics,
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
121 PolygonPlot plot,
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
122 Rectangle2D area,
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 PolygonDataset dataset
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 ) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 int seriesCount = dataset.getSeriesCount();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 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
127 PolygonSeries series = dataset.getSeries(i);
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 Integer colorIdx = (Integer)series.getAttribute("fill");
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 if (colorIdx != null) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 Paint paint = lookup.getPaint(colorIdx.intValue());
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132 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
133 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
134 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 else {
447
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
136 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
137 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
138 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
139 graphics.setStroke(stroke);
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 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
141 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
142 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 }
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
144 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
145
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
146 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
147 * 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
148 * has no label attritue, no label is drawn.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 795
diff changeset
149 *
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
150 */
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
151 public void drawLabels(
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
152 final Graphics2D graphics,
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
153 final PolygonPlot plot,
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
154 final Rectangle2D area,
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
155 PolygonDataset dataset
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
156 ) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
157 if (labelGenerator == null) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
158 return;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
159 }
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 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
162
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
163 Font font = graphics.getFont();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
164 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
165 graphics.setFont(font);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
166 FontMetrics metrics = graphics.getFontMetrics(font);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
167
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
168 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
169 PolygonSeries series = dataset.getSeries(i);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
170
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
171 String label = labelGenerator.generateLabel(series);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
172 if (label == null) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
173 continue;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
174 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
175
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
176 final Rectangle2D box = TextUtilities.getTextBounds(
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
177 label, graphics, metrics);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
178
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
179 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
180 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
181 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
182 Rectangle2D r = (Rectangle2D)loi.visit(
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
183 new LevelOrderIndices.Visitor()
450
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
184 {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
185 ValueAxis da = plot.getDomainAxis();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
186 ValueAxis ra = plot.getRangeAxis();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
187 RectangleEdge de = plot.getDomainAxisEdge();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
188 RectangleEdge re = plot.getRangeAxisEdge();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
189 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
190 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
191
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
192 public Object visit(int index) {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
193 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
194 - 0.5*box.getWidth();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
195 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
196 + 0.5*box.getHeight();
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
197
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
198 for (Rectangle2D b: bboxes) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
199 if (b.intersects(r)) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
200 return null;
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
201 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
202 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
203 return r;
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 });
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
206
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
207 if (r != null) {
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
208 bboxes.add(r);
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
209 graphics.drawString(
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
210 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
211 }
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
212 } // for all items in series
20a480753ff9 Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
213 } // for all series
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
214 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
216 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
217 * 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
218 * series.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
219 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
220 * @param plot The plot.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
221 * @param area The boundary.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
222 * @param series The series storing the items.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
223 * @param close Specifies if the polygon should be closed or not.
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
224 * @return the constructed shape.
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
225 */
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
226 protected Shape constructShape(
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
227 PolygonPlot plot,
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
228 Rectangle2D area,
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
229 PolygonSeries series,
451
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
230 boolean close
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
231 ) {
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
232 ValueAxis da = plot.getDomainAxis();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
233 ValueAxis ra = plot.getRangeAxis();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
234 RectangleEdge de = plot.getDomainAxisEdge();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
235 RectangleEdge re = plot.getRangeAxisEdge();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
236
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
237 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
238 GeneralPath path = new GeneralPath();
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
239
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 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
241
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
242 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
243
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
244 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
245
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246 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
247 path.moveTo(
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
248 (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
249 (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
250 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251 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
252 path.lineTo(
bc5901bb4525 Use JFreeCharts ValueAxis.valueToJava2D() to transform data values
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
253 (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
254 (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
255 }
437
b624879d2902 Added vectorizer rings callback to generate iso lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 422
diff changeset
256 if (close) {
b624879d2902 Added vectorizer rings callback to generate iso lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 422
diff changeset
257 path.closePath();
b624879d2902 Added vectorizer rings callback to generate iso lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 422
diff changeset
258 }
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
259 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
260 return path;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
261 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
263 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
264 * Retrieves the bounding box of a dataset.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
265 */
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266 public Rectangle2D getBoundingBox(PolygonDataset dataset) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
267 Rectangle2D bbox = null;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
268
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
269 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
270 Range domain = dataset.getSeries(i).getDomainBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
271 Range range = dataset.getSeries(i).getRangeBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
272
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
273 double x = domain.getLowerBound();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
274 double y = range.getLowerBound();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275 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
276 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
277
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
278 if (bbox == null) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
279 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
280 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
281 else {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
282 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
283 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
284 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
285
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
286 return bbox;
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
287 }
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
288
795
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
289 /**
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
290 *
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
291 * @return the bounds of a series.
cdade5005cba Added javadoc in jfreechart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
292 */
422
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
293 public Rectangle2D getBounds(PolygonSeries series) {
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
294
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
295 Range domain = series.getDomainBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
296 Range range = series.getRangeBounds();
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
297
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
298 return new Rectangle2D.Double(
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
299 domain.getLowerBound(), range.getLowerBound(),
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
300 domain.getUpperBound(), range.getUpperBound()
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
301 );
f426f55d4f7a Added Ingo Weinzierl's special JFreeChart classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
302 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org