Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/jfree/EnhancedLineAndShapeRenderer.java @ 9186:eec4df8165a1
Implemented 'ShowLineLabel' for area themes.
author | gernotbelger |
---|---|
date | Thu, 28 Jun 2018 10:47:04 +0200 |
parents | 5e38e2924c07 |
children |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3625
diff
changeset
|
9 package org.dive4elements.river.jfree; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
11 import java.awt.Color; |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3395
diff
changeset
|
12 import java.awt.Font; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import java.awt.Graphics2D; |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
14 import java.awt.Paint; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import java.awt.Shape; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import java.awt.geom.Rectangle2D; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import java.util.HashMap; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import java.util.Map; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import org.apache.log4j.Logger; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import org.jfree.chart.axis.ValueAxis; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import org.jfree.chart.entity.EntityCollection; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import org.jfree.chart.plot.CrosshairState; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 import org.jfree.chart.plot.PlotOrientation; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import org.jfree.chart.plot.XYPlot; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 import org.jfree.data.xy.XYDataset; |
2653
fa363aac788b
Added accidentally ommitted File in last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2649
diff
changeset
|
28 import org.jfree.data.xy.XYSeries; |
2649
6f5fc3de0d48
Most of issue454: Label waterlines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2648
diff
changeset
|
29 import org.jfree.data.xy.XYSeriesCollection; |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3395
diff
changeset
|
30 import org.jfree.text.TextUtilities; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 import org.jfree.ui.RectangleEdge; |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
32 import org.jfree.ui.TextAnchor; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 import org.jfree.util.BooleanList; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 import org.jfree.util.ShapeUtilities; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
2642
42b05a4bed25
Cosmetics, added doc, TODO and OPTIMIZE to Enhanced*Renderer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2591
diff
changeset
|
36 /** |
2647
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
37 * Renderer with additional the additional functionality of renderering minima |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
38 * and/or maxima of dataseries contained in datasets. |
2642
42b05a4bed25
Cosmetics, added doc, TODO and OPTIMIZE to Enhanced*Renderer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2591
diff
changeset
|
39 */ |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public class EnhancedLineAndShapeRenderer extends XYLineAndShapeRenderer { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3395
diff
changeset
|
42 /** |
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3395
diff
changeset
|
43 * |
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3395
diff
changeset
|
44 */ |
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3395
diff
changeset
|
45 private static final long serialVersionUID = 1L; |
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3395
diff
changeset
|
46 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
47 /** Own log. */ |
9186 | 48 private static final Logger log = Logger.getLogger(EnhancedLineAndShapeRenderer.class); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 protected BooleanList isMinimumShapeVisible; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 protected BooleanList isMaximumShapeVisible; |
2648
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
52 protected BooleanList showLineLabel; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 protected Map<Integer, Double> seriesMinimum; |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
55 protected Map<Integer, Double> seriesMinimumX; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 protected Map<Integer, Double> seriesMaximum; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
2656
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
58 protected Map<Integer, Font> lineLabelFonts; |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
59 protected Map<Integer, Color> lineLabelTextColors; |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
60 protected BooleanList showLineLabelBG; |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
61 protected Map<Integer, Color> lineLabelBGColors; |
2656
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
62 |
9186 | 63 public EnhancedLineAndShapeRenderer(final boolean lines, final boolean shapes) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 super(lines, shapes); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 this.isMinimumShapeVisible = new BooleanList(); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 this.isMaximumShapeVisible = new BooleanList(); |
9186 | 67 this.showLineLabel = new BooleanList(); |
68 this.showLineLabelBG = new BooleanList(); | |
69 this.seriesMinimum = new HashMap<>(); | |
70 this.seriesMaximum = new HashMap<>(); | |
71 this.seriesMinimumX = new HashMap<>(); | |
72 this.lineLabelFonts = new HashMap<>(); | |
73 this.lineLabelTextColors = new HashMap<>(); | |
74 this.lineLabelBGColors = new HashMap<>(); | |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
75 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
76 |
3015
9cea02b51241
Added better doc and todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2662
diff
changeset
|
77 /** |
9cea02b51241
Added better doc and todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2662
diff
changeset
|
78 * Draw a background-box of a text to render. |
9186 | 79 * |
80 * @param g2 | |
81 * graphics device to use | |
82 * @param text | |
83 * text to draw | |
84 * @param textX | |
85 * x-position for text | |
86 * @param textY | |
87 * y-position for text | |
88 * @param bgColor | |
89 * color to fill box with. | |
3015
9cea02b51241
Added better doc and todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2662
diff
changeset
|
90 */ |
9186 | 91 public static void drawTextBox(final Graphics2D g2, final String text, final float textX, final float textY, final Color bgColor) { |
92 final Rectangle2D hotspotBox = g2.getFontMetrics().getStringBounds(text, g2); | |
93 final float w = (float) hotspotBox.getWidth(); | |
94 final float h = (float) hotspotBox.getHeight(); | |
95 hotspotBox.setRect(textX, textY - h, w, h); | |
96 final Color oldColor = g2.getColor(); | |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
97 g2.setColor(bgColor); |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
98 g2.fill(hotspotBox); |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
99 g2.setColor(oldColor); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
102 /** |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
103 * Whether or not a specific item in a series (maybe the maxima) should |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
104 * be rendered with shape. |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
105 */ |
9186 | 106 private boolean getItemShapeVisible(final XYDataset dataset, final int series, final int item) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 if (super.getItemShapeVisible(series, item)) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 return true; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 |
9186 | 111 if (isMinimumShapeVisible(series) && isMinimum(dataset, series, item)) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 return true; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 |
9186 | 115 if (isMaximumShapeVisible(series) && isMaximum(dataset, series, item)) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 return true; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 return false; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
122 /** |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
123 * Rectangle used to draw maximums shape. |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
124 */ |
9186 | 125 private Shape getMaximumShape(final int series, final int column) { |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
126 return new Rectangle2D.Double(-5d, -5d, 10d, 10d); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
127 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
128 |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
129 /** |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
130 * Rectangle used to draw minimums shape. |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
131 */ |
9186 | 132 private Shape getMinimumShape(final int series, final int column) { |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
133 return new Rectangle2D.Double(-5d, -5d, 10d, 10d); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
134 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
135 |
3395
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
136 /** Get fill paint for the maximum indicators. */ |
9186 | 137 private Paint getMaximumFillPaint(final int series, final int column) { |
138 final Paint p = getItemPaint(series, column); | |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
139 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
140 if (p instanceof Color) { |
9186 | 141 final Color c = (Color) p; |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
142 Color b = c; |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
143 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
144 for (int i = 0; i < 2; i++) { |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
145 b = b.darker(); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
146 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
147 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
148 return b; |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
149 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
150 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
151 log.warn("Item paint is no instance of Color!"); |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
152 return p; |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
153 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
154 |
3395
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
155 /** Get fill paint for the minimum indicators. */ |
9186 | 156 private Paint getMinimumFillPaint(final int series, final int column) { |
157 final Paint p = getItemPaint(series, column); | |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
158 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
159 if (p instanceof Color) { |
9186 | 160 final Color c = (Color) p; |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
161 Color b = c; |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
162 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
163 for (int i = 0; i < 2; i++) { |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
164 b = b.darker(); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
165 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
166 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
167 return b; |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
168 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
169 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
170 log.warn("Item paint is no instance of Color!"); |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
171 return p; |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
172 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
173 |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 /** |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 * Overrides XYLineAndShapeRenderer.drawSecondaryPass() to call an adapted |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 * method getItemShapeVisible() which now takes an XYDataset. So, 99% of |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 * code equal the code in XYLineAndShapeRenderer. |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 */ |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 @Override |
9186 | 180 protected void drawSecondaryPass(final Graphics2D g2, final XYPlot plot, final XYDataset dataset, final int pass, final int series, final int item, |
181 final ValueAxis domainAxis, final Rectangle2D dataArea, final ValueAxis rangeAxis, final CrosshairState crosshairState, | |
182 final EntityCollection entities) { | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 Shape entityArea = null; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 // get the data point... |
9186 | 186 final double x1 = dataset.getXValue(series, item); |
187 final double y1 = dataset.getYValue(series, item); | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 if (Double.isNaN(y1) || Double.isNaN(x1)) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 return; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 |
9186 | 192 final PlotOrientation orientation = plot.getOrientation(); |
193 final RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); | |
194 final RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); | |
195 final double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); | |
196 final double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 if (getItemShapeVisible(dataset, series, item)) { |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
199 Shape shape = null; |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
200 |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
201 // OPTIMIZE: instead of calculating minimum and maximum for every |
9186 | 202 // point, calculate it just once (assume that dataset |
203 // content does not change during rendering). | |
204 // NOTE: Above OPTIMIZE might already be fulfilled to | |
205 // most extend. | |
206 final boolean isMinimum = isMinimumShapeVisible(series) && isMinimum(dataset, series, item); | |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
207 |
9186 | 208 final boolean isMaximum = isMaximumShapeVisible(series) && isMaximum(dataset, series, item); |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
209 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
210 if (isMinimum) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
211 log.debug("Create a Minimum shape."); |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
212 shape = getMinimumShape(series, item); |
9186 | 213 } else if (isMaximum) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
214 log.debug("Create a Maximum shape."); |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
215 shape = getMaximumShape(series, item); |
9186 | 216 } else { |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
217 shape = getItemShape(series, item); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
218 } |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
219 |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 if (orientation == PlotOrientation.HORIZONTAL) { |
9186 | 221 shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); |
222 } else if (orientation == PlotOrientation.VERTICAL) { | |
223 shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
224 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 entityArea = shape; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
226 if (shape.intersects(dataArea)) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
227 if (getItemShapeFilled(series, item)) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 if (getUseFillPaint()) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
229 g2.setPaint(getItemFillPaint(series, item)); |
9186 | 230 } else { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
231 g2.setPaint(getItemPaint(series, item)); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
232 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
233 g2.fill(shape); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
234 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
235 if (getDrawOutlines()) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
236 if (getUseOutlinePaint()) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
237 g2.setPaint(getItemOutlinePaint(series, item)); |
9186 | 238 } else { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
239 g2.setPaint(getItemPaint(series, item)); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
240 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
241 g2.setStroke(getItemOutlineStroke(series, item)); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
242 g2.draw(shape); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
243 } |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
244 |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
245 if (isMinimum) { |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
246 g2.setPaint(getMinimumFillPaint(series, item)); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
247 g2.fill(shape); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
248 g2.setPaint(getItemOutlinePaint(series, item)); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
249 g2.setStroke(getItemOutlineStroke(series, item)); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
250 g2.draw(shape); |
9186 | 251 } else if (isMaximum) { |
2591
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
252 g2.setPaint(getMaximumFillPaint(series, item)); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
253 g2.fill(shape); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
254 g2.setPaint(getItemOutlinePaint(series, item)); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
255 g2.setStroke(getItemOutlineStroke(series, item)); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
256 g2.draw(shape); |
74c02dbf17ca
#523 Improved the look of minimum and maximum shapes in chart series.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2241
diff
changeset
|
257 } |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
258 } |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
259 } // if (getItemShapeVisible(dataset, series, item)) |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
260 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
261 double xx = transX1; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
262 double yy = transY1; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
263 if (orientation == PlotOrientation.HORIZONTAL) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
264 xx = transY1; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
265 yy = transX1; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
266 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
267 |
3395
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
268 // Draw the item label if there is one... |
9186 | 269 if (isItemLabelVisible(series, item)) |
270 drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0)); | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
271 |
2649
6f5fc3de0d48
Most of issue454: Label waterlines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2648
diff
changeset
|
272 // Draw label of line. |
9186 | 273 if (dataset instanceof XYSeriesCollection && isShowLineLabel(series) && isMinimumX(dataset, series, item)) { |
274 final XYSeries xYSeries = ((XYSeriesCollection) dataset).getSeries(series); | |
275 final String waterlevelLabel = (xYSeries instanceof HasLabel) ? ((HasLabel) xYSeries).getLabel() : xYSeries.getKey().toString(); | |
8856 | 276 // TODO Force water of some German rivers to flow |
277 // direction mountains. | |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
278 |
9186 | 279 final Font labelFont = this.getLineLabelFont(series); |
280 final Color labelColor = this.getLineLabelTextColor(series); | |
281 final boolean showBG = isShowLineLabelBG(series); | |
282 final Color bgColor = getLineLabelBGColor(series); | |
3625
f2a5fe968b98
issue814 line labels always visible.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3464
diff
changeset
|
283 |
9186 | 284 drawLineLabel(g2, dataArea, entities, xx, yy, labelFont, labelColor, showBG, bgColor, waterlevelLabel); |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
285 } |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
286 |
9186 | 287 final int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); |
288 final int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); | |
289 updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
290 |
3395
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
291 // Add an entity for the item, but only if it falls within the data |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
292 // area... |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
293 if (entities != null && isPointInRect(dataArea, xx, yy)) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
294 addEntity(entities, entityArea, dataset, series, item, xx, yy); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
295 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
296 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
297 |
9186 | 298 public static void drawLineLabel(final Graphics2D g2, final Rectangle2D dataArea, final EntityCollection entities, final double labelX, final double labelY, |
299 final Font font, | |
300 final Color fgColor, | |
301 final boolean showBG, final Color bgColor, final String label) { | |
302 | |
303 final Font oldFont = g2.getFont(); | |
304 final Color oldColor = g2.getColor(); | |
305 | |
306 g2.setFont(font); | |
307 g2.setColor(fgColor); | |
308 g2.setBackground(Color.black); | |
309 | |
310 // Try to always display label if the data is visible. | |
311 double posX = labelX; | |
312 double posY = labelY; | |
313 if (!isPointInRect(dataArea, posX, posY)) { | |
314 // Move into the data area. | |
315 posX = Math.max(posX, dataArea.getMinX()); | |
316 posX = Math.min(posX, dataArea.getMaxX()); | |
317 posY = Math.max(posY, dataArea.getMinY()); | |
318 posY = Math.min(posY, dataArea.getMaxY()); | |
319 } | |
320 | |
321 // Move to right until no collisions exist anymore | |
322 Shape hotspot = TextUtilities.calculateRotatedStringBounds(label, g2, (float) posX, (float) posY - 3f, TextAnchor.CENTER_LEFT, 0f, | |
323 TextAnchor.CENTER_LEFT); | |
324 while (JFreeUtil.collides(hotspot, entities, CollisionFreeLineLabelEntity.class)) { | |
325 posX += 5f; | |
326 hotspot = TextUtilities.calculateRotatedStringBounds(label, g2, (float) posX, (float) posY - 3f, TextAnchor.CENTER_LEFT, 0f, | |
327 TextAnchor.CENTER_LEFT); | |
328 } | |
329 | |
330 // Register to avoid collissions. | |
331 entities.add(new CollisionFreeLineLabelEntity(hotspot, 1, "", "")); | |
332 | |
333 // Fill background. | |
334 if (showBG) | |
335 drawTextBox(g2, label, (float) posX, (float) posY - 3f, bgColor); | |
336 | |
337 g2.drawString(label, (float) posX, (float) posY - 3f); | |
338 | |
339 g2.setFont(oldFont); | |
340 g2.setColor(oldColor); | |
341 } | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
342 |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
343 /** |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
344 * Sets whether or not the minimum should be rendered with shape. |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3015
diff
changeset
|
345 */ |
9186 | 346 public void setIsMinimumShapeVisisble(final int series, final boolean isVisible) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
347 this.isMinimumShapeVisible.setBoolean(series, isVisible); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
348 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
349 |
3395
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
350 /** |
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
351 * Whether or not the minimum should be rendered with shape. |
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
352 */ |
9186 | 353 private boolean isMinimumShapeVisible(final int series) { |
2241
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
354 if (this.isMinimumShapeVisible.size() <= series) { |
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
355 return false; |
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
356 } |
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
357 |
9186 | 358 return this.isMinimumShapeVisible.getBoolean(series); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
359 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
360 |
3395
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
361 /** |
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
362 * Sets whether or not the maximum should be rendered with shape. |
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
363 */ |
9186 | 364 public void setIsMaximumShapeVisible(final int series, final boolean isVisible) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
365 this.isMaximumShapeVisible.setBoolean(series, isVisible); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
366 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
367 |
3395
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
368 /** |
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
369 * Whether or not the maximum should be rendered with shape. |
2a8919e0ed28
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
370 */ |
9186 | 371 private boolean isMaximumShapeVisible(final int series) { |
2241
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
372 if (this.isMaximumShapeVisible.size() <= series) { |
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
373 return false; |
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
374 } |
2b232871ba28
New helper functions in ChartHelper and improvements in EnhancedLineAndShapeRenderer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2075
diff
changeset
|
375 |
9186 | 376 return this.isMaximumShapeVisible.getBoolean(series); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
377 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
378 |
2648
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
379 /** Whether or not a label should be shown for series. */ |
9186 | 380 private boolean isShowLineLabel(final int series) { |
2648
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
381 if (this.showLineLabel.size() <= series) { |
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
382 return false; |
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
383 } |
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
384 |
9186 | 385 return this.showLineLabel.getBoolean(series); |
2648
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
386 } |
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
387 |
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
388 /** Sets whether or not a label should be shown for series. */ |
9186 | 389 public void setShowLineLabel(final boolean showLineLabel, final int series) { |
2648
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
390 this.showLineLabel.setBoolean(series, showLineLabel); |
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
391 } |
8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2647
diff
changeset
|
392 |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
393 /** Whether or not a label should be shown for series. */ |
9186 | 394 private boolean isShowLineLabelBG(final int series) { |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
395 if (this.showLineLabelBG.size() <= series) { |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
396 return false; |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
397 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
398 |
9186 | 399 return this.showLineLabelBG.getBoolean(series); |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
400 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
401 |
9186 | 402 public void setShowLineLabelBG(final int series, final boolean doShow) { |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
403 this.showLineLabelBG.setBoolean(series, doShow); |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
404 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
405 |
9186 | 406 private Color getLineLabelBGColor(final int series) { |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
407 if (this.lineLabelBGColors.size() <= series) { |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
408 return null; |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
409 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
410 |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
411 return this.lineLabelBGColors.get(series); |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
412 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
413 |
9186 | 414 public void setLineLabelBGColor(final int series, final Color color) { |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
415 this.lineLabelBGColors.put(series, color); |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
416 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
417 |
9186 | 418 private Color getLineLabelTextColor(final int series) { |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
419 if (this.lineLabelTextColors.size() <= series) { |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
420 return null; |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
421 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
422 |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
423 return this.lineLabelTextColors.get(series); |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
424 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
425 |
9186 | 426 public void setLineLabelTextColor(final int series, final Color color) { |
2660
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
427 this.lineLabelTextColors.put(series, color); |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
428 } |
1a044c51abe4
Respect colors of theme for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2659
diff
changeset
|
429 |
9186 | 430 public void setLineLabelFont(final Font font, final int series) { |
2656
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
431 this.lineLabelFonts.put(series, font); |
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
432 } |
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
433 |
9186 | 434 private Font getLineLabelFont(final int series) { |
2656
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
435 return this.lineLabelFonts.get(series); |
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
436 } |
f1dcd5f94ffa
Parse more theme properties for linelabels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2653
diff
changeset
|
437 |
2647
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
438 /** |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
439 * True if the given item of given dataset has the smallest |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
440 * X value within this set. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
441 */ |
9186 | 442 private boolean isMinimumX(final XYDataset dataset, final int series, final int item) { |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
443 return dataset.getXValue(series, item) == getMinimumX(dataset, series); |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
444 } |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
445 |
2647
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
446 /** |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
447 * Get Minimum X Value of a given series in a dataset. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
448 * The value is stored for later use if queried the first time. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
449 */ |
9186 | 450 private double getMinimumX(final XYDataset dataset, final int series) { |
451 final Integer key = Integer.valueOf(series); | |
452 final Double old = this.seriesMinimumX.get(key); | |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
453 |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
454 if (old != null) { |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
455 return old.doubleValue(); |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
456 } |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
457 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
458 log.debug("Compute minimum of Series: " + series); |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
459 |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
460 double min = Double.MAX_VALUE; |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
461 |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
462 for (int i = 0, n = dataset.getItemCount(series); i < n; i++) { |
9186 | 463 final double tmpValue = dataset.getXValue(series, i); |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
464 |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
465 if (tmpValue < min) { |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
466 min = tmpValue; |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
467 } |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
468 } |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
469 |
9186 | 470 this.seriesMinimumX.put(key, Double.valueOf(min)); |
2644
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
471 |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
472 return min; |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
473 } |
0a84313efe60
Stub for labeling dataseries in EnhancedLineAndShapeRenerer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2642
diff
changeset
|
474 |
2647
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
475 /** |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
476 * True if the given item of given dataset has the smallest |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
477 * Y value within this set. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
478 */ |
9186 | 479 private boolean isMinimum(final XYDataset dataset, final int series, final int item) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
480 return dataset.getYValue(series, item) == getMinimum(dataset, series); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
481 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
482 |
2647
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
483 /** |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
484 * Get Minimum Y Value of a given series in a dataset. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
485 * The value is stored for later use if queried the first time. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
486 */ |
9186 | 487 private double getMinimum(final XYDataset dataset, final int series) { |
488 final Integer key = Integer.valueOf(series); | |
489 final Double old = this.seriesMinimum.get(key); | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
490 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
491 if (old != null) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
492 return old.doubleValue(); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
493 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
494 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
495 log.debug("Compute minimum of Series: " + series); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
496 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
497 double min = Double.MAX_VALUE; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
498 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
499 for (int i = 0, n = dataset.getItemCount(series); i < n; i++) { |
9186 | 500 final double tmpValue = dataset.getYValue(series, i); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
501 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
502 if (tmpValue < min) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
503 min = tmpValue; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
504 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
505 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
506 |
9186 | 507 this.seriesMinimum.put(key, Double.valueOf(min)); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
508 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
509 return min; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
510 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
511 |
2647
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
512 /** |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
513 * True if the given item of given dataset has the biggest |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
514 * Y value within this set. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
515 */ |
9186 | 516 private boolean isMaximum(final XYDataset dataset, final int series, final int item) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
517 return dataset.getYValue(series, item) == getMaximum(dataset, series); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
518 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
519 |
2647
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
520 /** |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
521 * Get maximum Y Value of a given series in a dataset. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
522 * The value is stored for later use if queried the first time. |
4b7a28e81643
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2644
diff
changeset
|
523 */ |
9186 | 524 private double getMaximum(final XYDataset dataset, final int series) { |
525 final Integer key = Integer.valueOf(series); | |
526 final Double old = this.seriesMaximum.get(key); | |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
527 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
528 if (old != null) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
529 return old.doubleValue(); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
530 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
531 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
532 log.debug("Compute maximum of Series: " + series); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
533 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
534 double max = -Double.MAX_VALUE; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
535 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
536 for (int i = 0, n = dataset.getItemCount(series); i < n; i++) { |
9186 | 537 final double tmpValue = dataset.getYValue(series, i); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
538 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
539 if (tmpValue > max) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
540 max = tmpValue; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
541 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
542 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
543 |
9186 | 544 this.seriesMaximum.put(key, Double.valueOf(max)); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
545 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
546 return max; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
547 } |
9186 | 548 } |