annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java @ 1882:d67a9ca116c3

Last commit broke due to network error. flys-artifacts/trunk@3241 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 12 Nov 2011 12:07:39 +0000
parents 0e9c0b49b4ef
children eb671699fbc2
rev   line source
1823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 /* ===========================================================
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2 * JFreeChart : a free chart library for the Java(tm) platform
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 * ===========================================================
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 * Project Info: http://www.jfree.org/jfreechart/index.html
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 * under the terms of the GNU Lesser General Public License as published by
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 * the Free Software Foundation; either version 2.1 of the License, or
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 * (at your option) any later version.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 * This library is distributed in the hope that it will be useful, but
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 * License for more details.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 * You should have received a copy of the GNU Lesser General Public
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 * License along with this library; if not, write to the Free Software
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 * USA.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 * in the United States and other countries.]
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 * -------------------------
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 * StableXYDifferenceRenderer.java
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 * -------------------------
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 * Original Author: David Gilbert (for Object Refinery Limited);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 * Contributor(s): Richard West, Advanced Micro Devices, Inc. (major rewrite
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 * of difference drawing algorithm);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 * Changes:
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 * --------
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 * 30-Apr-2003 : Version 1 (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 * 30-Jul-2003 : Modified entity constructor (CZ);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 * 09-Feb-2004 : Updated to support horizontal plot orientation (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 * 10-Feb-2004 : Added default constructor, setter methods and updated
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 * Javadocs (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 * 30-Mar-2004 : Fixed bug in getNegativePaint() method (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 * 15-Jul-2004 : Switched getX() with getXValue() and getY() with
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 * getYValue() (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 * 25-Aug-2004 : Fixed a bug preventing the use of crosshairs (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 * 19-Jan-2005 : Now accesses only primitive values from dataset (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 * 22-Feb-2005 : Override getLegendItem(int, int) to return "line" items (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 * 13-Apr-2005 : Fixed shape positioning bug (id = 1182062) (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 * 04-May-2005 : Override equals() method, renamed get/setPlotShapes() -->
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 * get/setShapesVisible (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 * 09-Jun-2005 : Updated equals() to handle GradientPaint (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 * 16-Jun-2005 : Fix bug (1221021) affecting stroke used for each series (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 * ------------- JFREECHART 1.0.x ---------------------------------------------
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 * 24-Jan-2007 : Added flag to allow rounding of x-coordinates, and fixed
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 * bug in clone() (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 * 05-Feb-2007 : Added an extra call to updateCrosshairValues() in
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 * drawItemPass1(), to fix bug 1564967 (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 * 08-Mar-2007 : Fixed entity generation (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 * 23-Apr-2007 : Rewrite of difference drawing algorithm to allow use of
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 * series with disjoint x-values (RW);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 * 05-Nov-2007 : Draw item labels if visible (RW);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 */
1824
982956bde69e Added a dataset to zero mapper to circumvent shortcommings in XYDifferenceRenderer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1823
diff changeset
76 package de.intevation.flys.jfree;
1823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 import java.awt.Color;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 import java.awt.Graphics2D;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 import java.awt.Paint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 import java.awt.Shape;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 import java.awt.Stroke;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 import java.awt.geom.GeneralPath;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 import java.awt.geom.Line2D;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 import java.awt.geom.Rectangle2D;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 import java.io.IOException;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 import java.io.ObjectInputStream;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 import java.io.ObjectOutputStream;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 import java.util.Collections;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 import java.util.LinkedList;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 import org.jfree.chart.LegendItem;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 import org.jfree.chart.axis.ValueAxis;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 import org.jfree.chart.entity.EntityCollection;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 import org.jfree.chart.entity.XYItemEntity;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 import org.jfree.chart.event.RendererChangeEvent;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 import org.jfree.chart.labels.XYToolTipGenerator;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 import org.jfree.chart.plot.CrosshairState;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 import org.jfree.chart.plot.PlotOrientation;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 import org.jfree.chart.plot.PlotRenderingInfo;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 import org.jfree.chart.plot.XYPlot;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 import org.jfree.chart.urls.XYURLGenerator;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 import org.jfree.data.xy.XYDataset;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 import org.jfree.io.SerialUtilities;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 import org.jfree.ui.RectangleEdge;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 import org.jfree.util.PaintUtilities;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 import org.jfree.util.PublicCloneable;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 import org.jfree.util.ShapeUtilities;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109
1824
982956bde69e Added a dataset to zero mapper to circumvent shortcommings in XYDifferenceRenderer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1823
diff changeset
110 import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;
982956bde69e Added a dataset to zero mapper to circumvent shortcommings in XYDifferenceRenderer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1823
diff changeset
111 import org.jfree.chart.renderer.xy.XYItemRenderer;
982956bde69e Added a dataset to zero mapper to circumvent shortcommings in XYDifferenceRenderer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1823
diff changeset
112 import org.jfree.chart.renderer.xy.XYItemRendererState;
982956bde69e Added a dataset to zero mapper to circumvent shortcommings in XYDifferenceRenderer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1823
diff changeset
113
1823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 * A renderer for an {@link XYPlot} that highlights the differences between two
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 * series. The example shown here is generated by the
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 * <code>DifferenceChartDemo1.java</code> program included in the JFreeChart
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 * demo collection:
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 * <br><br>
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 * <img src="../../../../../images/StableXYDifferenceRendererSample.png"
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 * alt="StableXYDifferenceRendererSample.png" />
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 public class StableXYDifferenceRenderer extends AbstractXYItemRenderer
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 implements XYItemRenderer, PublicCloneable {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 /** For serialization. */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 private static final long serialVersionUID = -8447915602375584857L;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 /** The paint used to highlight positive differences (y(0) > y(1)). */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 private transient Paint positivePaint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132 /** The paint used to highlight negative differences (y(0) < y(1)). */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 private transient Paint negativePaint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 /** Display shapes at each point? */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 private boolean shapesVisible;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 /** The shape to display in the legend item. */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 private transient Shape legendLine;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140
1881
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
141 //private XYDatasetToZeroMapper mapper;
1824
982956bde69e Added a dataset to zero mapper to circumvent shortcommings in XYDifferenceRenderer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1823
diff changeset
142
1823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 * This flag controls whether or not the x-coordinates (in Java2D space)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 * are rounded to integers. When set to true, this can avoid the vertical
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 * striping that anti-aliasing can generate. However, the rounding may not
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 * be appropriate for output in high resolution formats (for example,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 * vector graphics formats such as SVG and PDF).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 * @since 1.0.4
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 private boolean roundXCoordinates;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 * Creates a new renderer with default attributes.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 public StableXYDifferenceRenderer() {
1881
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
158 this(Color.green, Color.red, false /*, null */);
1823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 * Creates a new renderer.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 * @param positivePaint the highlight color for positive differences
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 * (<code>null</code> not permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 * @param negativePaint the highlight color for negative differences
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167 * (<code>null</code> not permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 * @param shapes draw shapes?
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
170 public StableXYDifferenceRenderer(Paint positivePaint, Paint negativePaint,
1881
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
171 boolean shapes) {
1823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
172 if (positivePaint == null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
173 throw new IllegalArgumentException(
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
174 "Null 'positivePaint' argument.");
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
175 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
176 if (negativePaint == null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 throw new IllegalArgumentException(
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178 "Null 'negativePaint' argument.");
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180 this.positivePaint = positivePaint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 this.negativePaint = negativePaint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 this.shapesVisible = shapes;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 this.roundXCoordinates = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
188 * Returns the paint used to highlight positive differences.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
190 * @return The paint (never <code>null</code>).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
191 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
192 * @see #setPositivePaint(Paint)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
193 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 public Paint getPositivePaint() {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 return this.positivePaint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
199 * Sets the paint used to highlight positive differences and sends a
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
200 * {@link RendererChangeEvent} to all registered listeners.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 * @param paint the paint (<code>null</code> not permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
204 * @see #getPositivePaint()
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
205 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206 public void setPositivePaint(Paint paint) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 if (paint == null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 throw new IllegalArgumentException("Null 'paint' argument.");
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 this.positivePaint = paint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 fireChangeEvent();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
214 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 * Returns the paint used to highlight negative differences.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217 * @return The paint (never <code>null</code>).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
218 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
219 * @see #setNegativePaint(Paint)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221 public Paint getNegativePaint() {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222 return this.negativePaint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
226 * Sets the paint used to highlight negative differences.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 * @param paint the paint (<code>null</code> not permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 * @see #getNegativePaint()
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
232 public void setNegativePaint(Paint paint) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
233 if (paint == null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234 throw new IllegalArgumentException("Null 'paint' argument.");
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 this.negativePaint = paint;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
237 notifyListeners(new RendererChangeEvent(this));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
238 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
241 * Returns a flag that controls whether or not shapes are drawn for each
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
242 * data value.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
243 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
244 * @return A boolean.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
245 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246 * @see #setShapesVisible(boolean)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
248 public boolean getShapesVisible() {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 return this.shapesVisible;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
252 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
253 * Sets a flag that controls whether or not shapes are drawn for each
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
254 * data value, and sends a {@link RendererChangeEvent} to all registered
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
255 * listeners.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
256 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
257 * @param flag the flag.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
258 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
259 * @see #getShapesVisible()
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
260 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
261 public void setShapesVisible(boolean flag) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 this.shapesVisible = flag;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
263 fireChangeEvent();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
264 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
265
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
267 * Returns the shape used to represent a line in the legend.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
268 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
269 * @return The legend line (never <code>null</code>).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
270 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
271 * @see #setLegendLine(Shape)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
272 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
273 public Shape getLegendLine() {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
274 return this.legendLine;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
276
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
277 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
278 * Sets the shape used as a line in each legend item and sends a
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
279 * {@link RendererChangeEvent} to all registered listeners.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
280 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
281 * @param line the line (<code>null</code> not permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
282 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
283 * @see #getLegendLine()
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
284 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
285 public void setLegendLine(Shape line) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
286 if (line == null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
287 throw new IllegalArgumentException("Null 'line' argument.");
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
288 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
289 this.legendLine = line;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
290 fireChangeEvent();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
291 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
292
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
293 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
294 * Returns the flag that controls whether or not the x-coordinates (in
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
295 * Java2D space) are rounded to integer values.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
296 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
297 * @return The flag.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
298 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
299 * @since 1.0.4
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
300 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
301 * @see #setRoundXCoordinates(boolean)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
302 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
303 public boolean getRoundXCoordinates() {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
304 return this.roundXCoordinates;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
305 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
306
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
307 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
308 * Sets the flag that controls whether or not the x-coordinates (in
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
309 * Java2D space) are rounded to integer values, and sends a
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
310 * {@link RendererChangeEvent} to all registered listeners.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
311 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
312 * @param round the new flag value.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
313 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
314 * @since 1.0.4
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
315 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
316 * @see #getRoundXCoordinates()
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
317 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
318 public void setRoundXCoordinates(boolean round) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
319 this.roundXCoordinates = round;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
320 fireChangeEvent();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
321 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
322
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
323 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
324 * Initialises the renderer and returns a state object that should be
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
325 * passed to subsequent calls to the drawItem() method. This method will
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
326 * be called before the first item is rendered, giving the renderer an
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
327 * opportunity to initialise any state information it wants to maintain.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
328 * The renderer can do nothing if it chooses.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
329 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
330 * @param g2 the graphics device.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
331 * @param dataArea the area inside the axes.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
332 * @param plot the plot.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
333 * @param data the data.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
334 * @param info an optional info collection object to return data back to
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
335 * the caller.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
336 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
337 * @return A state object.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
338 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
339 public XYItemRendererState initialise(Graphics2D g2,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340 Rectangle2D dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341 XYPlot plot,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
342 XYDataset data,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
343 PlotRenderingInfo info) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
344
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
345 XYItemRendererState state = super.initialise(g2, dataArea, plot, data,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
346 info);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
347 state.setProcessVisibleItemsOnly(false);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
348 return state;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
349
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
350 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
351
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
352 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
353 * Returns <code>2</code>, the number of passes required by the renderer.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
354 * The {@link XYPlot} will run through the dataset this number of times.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
355 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
356 * @return The number of passes required by the renderer.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
357 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
358 public int getPassCount() {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
359 return 2;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
360 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
361
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
362 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
363 * Draws the visual representation of a single data item.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
364 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
365 * @param g2 the graphics device.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
366 * @param state the renderer state.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
367 * @param dataArea the area within which the data is being drawn.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
368 * @param info collects information about the drawing.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
369 * @param plot the plot (can be used to obtain standard color
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
370 * information etc).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
371 * @param domainAxis the domain (horizontal) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
372 * @param rangeAxis the range (vertical) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
373 * @param dataset the dataset.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
374 * @param series the series index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
375 * @param item the item index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
376 * @param crosshairState crosshair information for the plot
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
377 * (<code>null</code> permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
378 * @param pass the pass index.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
379 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
380 public void drawItem(Graphics2D g2,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
381 XYItemRendererState state,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
382 Rectangle2D dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
383 PlotRenderingInfo info,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
384 XYPlot plot,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
385 ValueAxis domainAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
386 ValueAxis rangeAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
387 XYDataset dataset,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
388 int series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
389 int item,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
390 CrosshairState crosshairState,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
391 int pass) {
1881
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
392 switch (pass) {
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
393 case 0:
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
394 drawItemPass0(g2, dataArea, info,
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
395 plot, domainAxis, rangeAxis,
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
396 dataset, series, item, crosshairState);
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
397 break;
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
398 case 1:
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
399 drawItemPass1(g2, dataArea, info,
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
400 plot, domainAxis, rangeAxis,
0e9c0b49b4ef CrossSectionApp: draw ground with StableXYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1824
diff changeset
401 dataset, series, item, crosshairState);
1823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
402 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
403 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
404
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
405 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
406 * Draws the visual representation of a single data item, first pass.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
407 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
408 * @param x_graphics the graphics device.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
409 * @param x_dataArea the area within which the data is being drawn.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
410 * @param x_info collects information about the drawing.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
411 * @param x_plot the plot (can be used to obtain standard color
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
412 * information etc).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
413 * @param x_domainAxis the domain (horizontal) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
414 * @param x_rangeAxis the range (vertical) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
415 * @param x_dataset the dataset.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
416 * @param x_series the series index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
417 * @param x_item the item index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
418 * @param x_crosshairState crosshair information for the plot
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
419 * (<code>null</code> permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
420 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
421 protected void drawItemPass0(Graphics2D x_graphics,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
422 Rectangle2D x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
423 PlotRenderingInfo x_info,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
424 XYPlot x_plot,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
425 ValueAxis x_domainAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
426 ValueAxis x_rangeAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
427 XYDataset x_dataset,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
428 int x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
429 int x_item,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
430 CrosshairState x_crosshairState) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
431
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
432 if (!((0 == x_series) && (0 == x_item))) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
433 return;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
434 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
435
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
436 boolean b_impliedZeroSubtrahend = (1 == x_dataset.getSeriesCount());
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
437
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
438 // check if either series is a degenerate case (i.e. less than 2 points)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
439 if (isEitherSeriesDegenerate(x_dataset, b_impliedZeroSubtrahend)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
440 return;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
441 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
442
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
443 // check if series are disjoint (i.e. domain-spans do not overlap)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
444 if (!b_impliedZeroSubtrahend && areSeriesDisjoint(x_dataset)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
445 return;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
446 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
447
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
448 // polygon definitions
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
449 LinkedList l_minuendXs = new LinkedList();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
450 LinkedList l_minuendYs = new LinkedList();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
451 LinkedList l_subtrahendXs = new LinkedList();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
452 LinkedList l_subtrahendYs = new LinkedList();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
453 LinkedList l_polygonXs = new LinkedList();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
454 LinkedList l_polygonYs = new LinkedList();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
455
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
456 // state
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
457 int l_minuendItem = 0;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
458 int l_minuendItemCount = x_dataset.getItemCount(0);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
459 Double l_minuendCurX = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
460 Double l_minuendNextX = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
461 Double l_minuendCurY = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
462 Double l_minuendNextY = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
463 double l_minuendMaxY = Double.NEGATIVE_INFINITY;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
464 double l_minuendMinY = Double.POSITIVE_INFINITY;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
465
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
466 int l_subtrahendItem = 0;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
467 int l_subtrahendItemCount = 0; // actual value set below
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
468 Double l_subtrahendCurX = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
469 Double l_subtrahendNextX = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
470 Double l_subtrahendCurY = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
471 Double l_subtrahendNextY = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
472 double l_subtrahendMaxY = Double.NEGATIVE_INFINITY;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
473 double l_subtrahendMinY = Double.POSITIVE_INFINITY;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
474
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
475 // if a subtrahend is not specified, assume it is zero
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
476 if (b_impliedZeroSubtrahend) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
477 l_subtrahendItem = 0;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
478 l_subtrahendItemCount = 2;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
479 l_subtrahendCurX = new Double(x_dataset.getXValue(0, 0));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
480 l_subtrahendNextX = new Double(x_dataset.getXValue(0,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
481 (l_minuendItemCount - 1)));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
482 l_subtrahendCurY = new Double(0.0);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
483 l_subtrahendNextY = new Double(0.0);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
484 l_subtrahendMaxY = 0.0;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
485 l_subtrahendMinY = 0.0;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
486
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
487 l_subtrahendXs.add(l_subtrahendCurX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
488 l_subtrahendYs.add(l_subtrahendCurY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
489 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
490 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
491 l_subtrahendItemCount = x_dataset.getItemCount(1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
492 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
493
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
494 boolean b_minuendDone = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
495 boolean b_minuendAdvanced = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
496 boolean b_minuendAtIntersect = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
497 boolean b_minuendFastForward = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
498 boolean b_subtrahendDone = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
499 boolean b_subtrahendAdvanced = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
500 boolean b_subtrahendAtIntersect = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
501 boolean b_subtrahendFastForward = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
502 boolean b_colinear = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
503
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
504 boolean b_positive;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
505
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
506 // coordinate pairs
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
507 double l_x1 = 0.0, l_y1 = 0.0; // current minuend point
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
508 double l_x2 = 0.0, l_y2 = 0.0; // next minuend point
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
509 double l_x3 = 0.0, l_y3 = 0.0; // current subtrahend point
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
510 double l_x4 = 0.0, l_y4 = 0.0; // next subtrahend point
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
511
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
512 // fast-forward through leading tails
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
513 boolean b_fastForwardDone = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
514 while (!b_fastForwardDone) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
515 // get the x and y coordinates
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
516 l_x1 = x_dataset.getXValue(0, l_minuendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
517 l_y1 = x_dataset.getYValue(0, l_minuendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
518 l_x2 = x_dataset.getXValue(0, l_minuendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
519 l_y2 = x_dataset.getYValue(0, l_minuendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
520
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
521 l_minuendCurX = new Double(l_x1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
522 l_minuendCurY = new Double(l_y1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
523 l_minuendNextX = new Double(l_x2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
524 l_minuendNextY = new Double(l_y2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
525
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
526 if (b_impliedZeroSubtrahend) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
527 l_x3 = l_subtrahendCurX.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
528 l_y3 = l_subtrahendCurY.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
529 l_x4 = l_subtrahendNextX.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
530 l_y4 = l_subtrahendNextY.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
531 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
532 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
533 l_x3 = x_dataset.getXValue(1, l_subtrahendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
534 l_y3 = x_dataset.getYValue(1, l_subtrahendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
535 l_x4 = x_dataset.getXValue(1, l_subtrahendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
536 l_y4 = x_dataset.getYValue(1, l_subtrahendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
537
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
538 l_subtrahendCurX = new Double(l_x3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
539 l_subtrahendCurY = new Double(l_y3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
540 l_subtrahendNextX = new Double(l_x4);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
541 l_subtrahendNextY = new Double(l_y4);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
542 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
543
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
544 if (l_x2 <= l_x3) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
545 // minuend needs to be fast forwarded
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
546 l_minuendItem++;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
547 b_minuendFastForward = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
548 continue;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
549 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
550
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
551 if (l_x4 <= l_x1) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
552 // subtrahend needs to be fast forwarded
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
553 l_subtrahendItem++;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
554 b_subtrahendFastForward = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
555 continue;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
556 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
557
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
558 // check if initial polygon needs to be clipped
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
559 if ((l_x3 < l_x1) && (l_x1 < l_x4)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
560 // project onto subtrahend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
561 double l_slope = (l_y4 - l_y3) / (l_x4 - l_x3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
562 l_subtrahendCurX = l_minuendCurX;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
563 l_subtrahendCurY = new Double((l_slope * l_x1)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
564 + (l_y3 - (l_slope * l_x3)));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
565
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
566 l_subtrahendXs.add(l_subtrahendCurX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
567 l_subtrahendYs.add(l_subtrahendCurY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
568 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
569
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
570 if ((l_x1 < l_x3) && (l_x3 < l_x2)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
571 // project onto minuend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
572 double l_slope = (l_y2 - l_y1) / (l_x2 - l_x1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
573 l_minuendCurX = l_subtrahendCurX;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
574 l_minuendCurY = new Double((l_slope * l_x3)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
575 + (l_y1 - (l_slope * l_x1)));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
576
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
577 l_minuendXs.add(l_minuendCurX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
578 l_minuendYs.add(l_minuendCurY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
579 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
580
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
581 l_minuendMaxY = l_minuendCurY.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
582 l_minuendMinY = l_minuendCurY.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
583 l_subtrahendMaxY = l_subtrahendCurY.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
584 l_subtrahendMinY = l_subtrahendCurY.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
585
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
586 b_fastForwardDone = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
587 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
588
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
589 // start of algorithm
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
590 while (!b_minuendDone && !b_subtrahendDone) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
591 if (!b_minuendDone && !b_minuendFastForward && b_minuendAdvanced) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
592 l_x1 = x_dataset.getXValue(0, l_minuendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
593 l_y1 = x_dataset.getYValue(0, l_minuendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
594 l_minuendCurX = new Double(l_x1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
595 l_minuendCurY = new Double(l_y1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
596
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
597 if (!b_minuendAtIntersect) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
598 l_minuendXs.add(l_minuendCurX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
599 l_minuendYs.add(l_minuendCurY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
600 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
601
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
602 l_minuendMaxY = Math.max(l_minuendMaxY, l_y1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
603 l_minuendMinY = Math.min(l_minuendMinY, l_y1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
604
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
605 l_x2 = x_dataset.getXValue(0, l_minuendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
606 l_y2 = x_dataset.getYValue(0, l_minuendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
607 l_minuendNextX = new Double(l_x2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
608 l_minuendNextY = new Double(l_y2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
609 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
610
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
611 // never updated the subtrahend if it is implied to be zero
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
612 if (!b_impliedZeroSubtrahend && !b_subtrahendDone
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
613 && !b_subtrahendFastForward && b_subtrahendAdvanced) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
614 l_x3 = x_dataset.getXValue(1, l_subtrahendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
615 l_y3 = x_dataset.getYValue(1, l_subtrahendItem);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
616 l_subtrahendCurX = new Double(l_x3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
617 l_subtrahendCurY = new Double(l_y3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
618
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
619 if (!b_subtrahendAtIntersect) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
620 l_subtrahendXs.add(l_subtrahendCurX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
621 l_subtrahendYs.add(l_subtrahendCurY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
622 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
623
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
624 l_subtrahendMaxY = Math.max(l_subtrahendMaxY, l_y3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
625 l_subtrahendMinY = Math.min(l_subtrahendMinY, l_y3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
626
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
627 l_x4 = x_dataset.getXValue(1, l_subtrahendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
628 l_y4 = x_dataset.getYValue(1, l_subtrahendItem + 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
629 l_subtrahendNextX = new Double(l_x4);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
630 l_subtrahendNextY = new Double(l_y4);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
631 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
632
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
633 // deassert b_*FastForward (only matters for 1st time through loop)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
634 b_minuendFastForward = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
635 b_subtrahendFastForward = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
636
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
637 Double l_intersectX = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
638 Double l_intersectY = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
639 boolean b_intersect = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
640
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
641 b_minuendAtIntersect = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
642 b_subtrahendAtIntersect = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
643
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
644 // check for intersect
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
645 if ((l_x2 == l_x4) && (l_y2 == l_y4)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
646 // check if line segments are colinear
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
647 if ((l_x1 == l_x3) && (l_y1 == l_y3)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
648 b_colinear = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
649 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
650 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
651 // the intersect is at the next point for both the minuend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
652 // and subtrahend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
653 l_intersectX = new Double(l_x2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
654 l_intersectY = new Double(l_y2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
655
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
656 b_intersect = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
657 b_minuendAtIntersect = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
658 b_subtrahendAtIntersect = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
659 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
660 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
661 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
662 // compute common denominator
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
663 double l_denominator = ((l_y4 - l_y3) * (l_x2 - l_x1))
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
664 - ((l_x4 - l_x3) * (l_y2 - l_y1));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
665
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
666 // compute common deltas
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
667 double l_deltaY = l_y1 - l_y3;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
668 double l_deltaX = l_x1 - l_x3;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
669
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
670 // compute numerators
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
671 double l_numeratorA = ((l_x4 - l_x3) * l_deltaY)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
672 - ((l_y4 - l_y3) * l_deltaX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
673 double l_numeratorB = ((l_x2 - l_x1) * l_deltaY)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
674 - ((l_y2 - l_y1) * l_deltaX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
675
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
676 // check if line segments are colinear
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
677 if ((0 == l_numeratorA) && (0 == l_numeratorB)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
678 && (0 == l_denominator)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
679 b_colinear = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
680 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
681 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
682 // check if previously colinear
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
683 if (b_colinear) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
684 // clear colinear points and flag
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
685 l_minuendXs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
686 l_minuendYs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
687 l_subtrahendXs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
688 l_subtrahendYs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
689 l_polygonXs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
690 l_polygonYs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
691
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
692 b_colinear = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
693
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
694 // set new starting point for the polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
695 boolean b_useMinuend = ((l_x3 <= l_x1)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
696 && (l_x1 <= l_x4));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
697 l_polygonXs.add(b_useMinuend ? l_minuendCurX
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
698 : l_subtrahendCurX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
699 l_polygonYs.add(b_useMinuend ? l_minuendCurY
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
700 : l_subtrahendCurY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
701 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
702
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
703 // compute slope components
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
704 double l_slopeA = l_numeratorA / l_denominator;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
705 double l_slopeB = l_numeratorB / l_denominator;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
706
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
707 // check if the line segments intersect
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
708 if ((0 < l_slopeA) && (l_slopeA <= 1) && (0 < l_slopeB)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
709 && (l_slopeB <= 1)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
710 // compute the point of intersection
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
711 double l_xi = l_x1 + (l_slopeA * (l_x2 - l_x1));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
712 double l_yi = l_y1 + (l_slopeA * (l_y2 - l_y1));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
713
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
714 l_intersectX = new Double(l_xi);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
715 l_intersectY = new Double(l_yi);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
716 b_intersect = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
717 b_minuendAtIntersect = ((l_xi == l_x2)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
718 && (l_yi == l_y2));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
719 b_subtrahendAtIntersect = ((l_xi == l_x4)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
720 && (l_yi == l_y4));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
721
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
722 // advance minuend and subtrahend to intesect
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
723 l_minuendCurX = l_intersectX;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
724 l_minuendCurY = l_intersectY;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
725 l_subtrahendCurX = l_intersectX;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
726 l_subtrahendCurY = l_intersectY;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
727 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
728 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
729 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
730
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
731 if (b_intersect) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
732 // create the polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
733 // add the minuend's points to polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
734 l_polygonXs.addAll(l_minuendXs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
735 l_polygonYs.addAll(l_minuendYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
736
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
737 // add intersection point to the polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
738 l_polygonXs.add(l_intersectX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
739 l_polygonYs.add(l_intersectY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
740
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
741 // add the subtrahend's points to the polygon in reverse
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
742 Collections.reverse(l_subtrahendXs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
743 Collections.reverse(l_subtrahendYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
744 l_polygonXs.addAll(l_subtrahendXs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
745 l_polygonYs.addAll(l_subtrahendYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
746
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
747 // create an actual polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
748 b_positive = (l_subtrahendMaxY <= l_minuendMaxY)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
749 && (l_subtrahendMinY <= l_minuendMinY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
750 createPolygon(x_graphics, x_dataArea, x_plot, x_domainAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
751 x_rangeAxis, b_positive, l_polygonXs, l_polygonYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
752
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
753 // clear the point vectors
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
754 l_minuendXs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
755 l_minuendYs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
756 l_subtrahendXs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
757 l_subtrahendYs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
758 l_polygonXs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
759 l_polygonYs.clear();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
760
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
761 // set the maxY and minY values to intersect y-value
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
762 double l_y = l_intersectY.doubleValue();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
763 l_minuendMaxY = l_y;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
764 l_subtrahendMaxY = l_y;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
765 l_minuendMinY = l_y;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
766 l_subtrahendMinY = l_y;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
767
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
768 // add interection point to new polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
769 l_polygonXs.add(l_intersectX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
770 l_polygonYs.add(l_intersectY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
771 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
772
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
773 // advance the minuend if needed
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
774 if (l_x2 <= l_x4) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
775 l_minuendItem++;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
776 b_minuendAdvanced = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
777 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
778 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
779 b_minuendAdvanced = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
780 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
781
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
782 // advance the subtrahend if needed
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
783 if (l_x4 <= l_x2) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
784 l_subtrahendItem++;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
785 b_subtrahendAdvanced = true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
786 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
787 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
788 b_subtrahendAdvanced = false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
789 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
790
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
791 b_minuendDone = (l_minuendItem == (l_minuendItemCount - 1));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
792 b_subtrahendDone = (l_subtrahendItem == (l_subtrahendItemCount
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
793 - 1));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
794 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
795
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
796 // check if the final polygon needs to be clipped
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
797 if (b_minuendDone && (l_x3 < l_x2) && (l_x2 < l_x4)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
798 // project onto subtrahend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
799 double l_slope = (l_y4 - l_y3) / (l_x4 - l_x3);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
800 l_subtrahendNextX = l_minuendNextX;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
801 l_subtrahendNextY = new Double((l_slope * l_x2)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
802 + (l_y3 - (l_slope * l_x3)));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
803 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
804
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
805 if (b_subtrahendDone && (l_x1 < l_x4) && (l_x4 < l_x2)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
806 // project onto minuend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
807 double l_slope = (l_y2 - l_y1) / (l_x2 - l_x1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
808 l_minuendNextX = l_subtrahendNextX;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
809 l_minuendNextY = new Double((l_slope * l_x4)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
810 + (l_y1 - (l_slope * l_x1)));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
811 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
812
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
813 // consider last point of minuend and subtrahend for determining
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
814 // positivity
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
815 l_minuendMaxY = Math.max(l_minuendMaxY,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
816 l_minuendNextY.doubleValue());
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
817 l_subtrahendMaxY = Math.max(l_subtrahendMaxY,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
818 l_subtrahendNextY.doubleValue());
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
819 l_minuendMinY = Math.min(l_minuendMinY,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
820 l_minuendNextY.doubleValue());
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
821 l_subtrahendMinY = Math.min(l_subtrahendMinY,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
822 l_subtrahendNextY.doubleValue());
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
823
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
824 // add the last point of the minuned and subtrahend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
825 l_minuendXs.add(l_minuendNextX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
826 l_minuendYs.add(l_minuendNextY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
827 l_subtrahendXs.add(l_subtrahendNextX);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
828 l_subtrahendYs.add(l_subtrahendNextY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
829
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
830 // create the polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
831 // add the minuend's points to polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
832 l_polygonXs.addAll(l_minuendXs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
833 l_polygonYs.addAll(l_minuendYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
834
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
835 // add the subtrahend's points to the polygon in reverse
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
836 Collections.reverse(l_subtrahendXs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
837 Collections.reverse(l_subtrahendYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
838 l_polygonXs.addAll(l_subtrahendXs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
839 l_polygonYs.addAll(l_subtrahendYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
840
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
841 // create an actual polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
842 b_positive = (l_subtrahendMaxY <= l_minuendMaxY)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
843 && (l_subtrahendMinY <= l_minuendMinY);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
844 createPolygon(x_graphics, x_dataArea, x_plot, x_domainAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
845 x_rangeAxis, b_positive, l_polygonXs, l_polygonYs);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
846 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
847
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
848 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
849 * Draws the visual representation of a single data item, second pass. In
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
850 * the second pass, the renderer draws the lines and shapes for the
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
851 * individual points in the two series.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
852 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
853 * @param x_graphics the graphics device.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
854 * @param x_dataArea the area within which the data is being drawn.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
855 * @param x_info collects information about the drawing.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
856 * @param x_plot the plot (can be used to obtain standard color
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
857 * information etc).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
858 * @param x_domainAxis the domain (horizontal) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
859 * @param x_rangeAxis the range (vertical) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
860 * @param x_dataset the dataset.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
861 * @param x_series the series index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
862 * @param x_item the item index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
863 * @param x_crosshairState crosshair information for the plot
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
864 * (<code>null</code> permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
865 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
866 protected void drawItemPass1(Graphics2D x_graphics,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
867 Rectangle2D x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
868 PlotRenderingInfo x_info,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
869 XYPlot x_plot,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
870 ValueAxis x_domainAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
871 ValueAxis x_rangeAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
872 XYDataset x_dataset,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
873 int x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
874 int x_item,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
875 CrosshairState x_crosshairState) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
876
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
877 Shape l_entityArea = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
878 EntityCollection l_entities = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
879 if (null != x_info) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
880 l_entities = x_info.getOwner().getEntityCollection();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
881 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
882
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
883 Paint l_seriesPaint = getItemPaint(x_series, x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
884 Stroke l_seriesStroke = getItemStroke(x_series, x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
885 x_graphics.setPaint(l_seriesPaint);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
886 x_graphics.setStroke(l_seriesStroke);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
887
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
888 PlotOrientation l_orientation = x_plot.getOrientation();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
889 RectangleEdge l_domainAxisLocation = x_plot.getDomainAxisEdge();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
890 RectangleEdge l_rangeAxisLocation = x_plot.getRangeAxisEdge();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
891
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
892 double l_x0 = x_dataset.getXValue(x_series, x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
893 double l_y0 = x_dataset.getYValue(x_series, x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
894 double l_x1 = x_domainAxis.valueToJava2D(l_x0, x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
895 l_domainAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
896 double l_y1 = x_rangeAxis.valueToJava2D(l_y0, x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
897 l_rangeAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
898
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
899 if (getShapesVisible()) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
900 Shape l_shape = getItemShape(x_series, x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
901 if (l_orientation == PlotOrientation.HORIZONTAL) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
902 l_shape = ShapeUtilities.createTranslatedShape(l_shape,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
903 l_y1, l_x1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
904 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
905 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
906 l_shape = ShapeUtilities.createTranslatedShape(l_shape,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
907 l_x1, l_y1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
908 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
909 if (l_shape.intersects(x_dataArea)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
910 x_graphics.setPaint(getItemPaint(x_series, x_item));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
911 x_graphics.fill(l_shape);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
912 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
913 l_entityArea = l_shape;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
914 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
915
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
916 // add an entity for the item...
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
917 if (null != l_entities) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
918 if (null == l_entityArea) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
919 l_entityArea = new Rectangle2D.Double((l_x1 - 2), (l_y1 - 2),
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
920 4, 4);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
921 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
922 String l_tip = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
923 XYToolTipGenerator l_tipGenerator = getToolTipGenerator(x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
924 x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
925 if (null != l_tipGenerator) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
926 l_tip = l_tipGenerator.generateToolTip(x_dataset, x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
927 x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
928 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
929 String l_url = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
930 XYURLGenerator l_urlGenerator = getURLGenerator();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
931 if (null != l_urlGenerator) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
932 l_url = l_urlGenerator.generateURL(x_dataset, x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
933 x_item);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
934 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
935 XYItemEntity l_entity = new XYItemEntity(l_entityArea, x_dataset,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
936 x_series, x_item, l_tip, l_url);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
937 l_entities.add(l_entity);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
938 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
939
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
940 // draw the item label if there is one...
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
941 if (isItemLabelVisible(x_series, x_item)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
942 drawItemLabel(x_graphics, l_orientation, x_dataset, x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
943 x_item, l_x1, l_y1, (l_y1 < 0.0));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
944 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
945
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
946 int l_domainAxisIndex = x_plot.getDomainAxisIndex(x_domainAxis);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
947 int l_rangeAxisIndex = x_plot.getRangeAxisIndex(x_rangeAxis);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
948 updateCrosshairValues(x_crosshairState, l_x0, l_y0, l_domainAxisIndex,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
949 l_rangeAxisIndex, l_x1, l_y1, l_orientation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
950
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
951 if (0 == x_item) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
952 return;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
953 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
954
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
955 double l_x2 = x_domainAxis.valueToJava2D(x_dataset.getXValue(x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
956 (x_item - 1)), x_dataArea, l_domainAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
957 double l_y2 = x_rangeAxis.valueToJava2D(x_dataset.getYValue(x_series,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
958 (x_item - 1)), x_dataArea, l_rangeAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
959
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
960 Line2D l_line = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
961 if (PlotOrientation.HORIZONTAL == l_orientation) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
962 l_line = new Line2D.Double(l_y1, l_x1, l_y2, l_x2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
963 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
964 else if (PlotOrientation.VERTICAL == l_orientation) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
965 l_line = new Line2D.Double(l_x1, l_y1, l_x2, l_y2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
966 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
967
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
968 if ((null != l_line) && l_line.intersects(x_dataArea)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
969 x_graphics.setPaint(getItemPaint(x_series, x_item));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
970 x_graphics.setStroke(getItemStroke(x_series, x_item));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
971 x_graphics.draw(l_line);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
972 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
973 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
974
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
975 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
976 * Determines if a dataset is degenerate. A degenerate dataset is a
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
977 * dataset where either series has less than two (2) points.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
978 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
979 * @param x_dataset the dataset.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
980 * @param x_impliedZeroSubtrahend if false, do not check the subtrahend
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
981 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
982 * @return true if the dataset is degenerate.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
983 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
984 private boolean isEitherSeriesDegenerate(XYDataset x_dataset,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
985 boolean x_impliedZeroSubtrahend) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
986
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
987 if (x_impliedZeroSubtrahend) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
988 return (x_dataset.getItemCount(0) < 2);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
989 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
990
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
991 return ((x_dataset.getItemCount(0) < 2)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
992 || (x_dataset.getItemCount(1) < 2));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
993 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
994
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
995 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
996 * Determines if the two (2) series are disjoint.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
997 * Disjoint series do not overlap in the domain space.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
998 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
999 * @param x_dataset the dataset.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1000 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1001 * @return true if the dataset is degenerate.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1002 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1003 private boolean areSeriesDisjoint(XYDataset x_dataset) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1004
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1005 int l_minuendItemCount = x_dataset.getItemCount(0);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1006 double l_minuendFirst = x_dataset.getXValue(0, 0);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1007 double l_minuendLast = x_dataset.getXValue(0, l_minuendItemCount - 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1008
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1009 int l_subtrahendItemCount = x_dataset.getItemCount(1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1010 double l_subtrahendFirst = x_dataset.getXValue(1, 0);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1011 double l_subtrahendLast = x_dataset.getXValue(1,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1012 l_subtrahendItemCount - 1);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1013
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1014 return ((l_minuendLast < l_subtrahendFirst)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1015 || (l_subtrahendLast < l_minuendFirst));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1016 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1017
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1018 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1019 * Draws the visual representation of a polygon
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1020 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1021 * @param x_graphics the graphics device.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1022 * @param x_dataArea the area within which the data is being drawn.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1023 * @param x_plot the plot (can be used to obtain standard color
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1024 * information etc).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1025 * @param x_domainAxis the domain (horizontal) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1026 * @param x_rangeAxis the range (vertical) axis.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1027 * @param x_positive indicates if the polygon is positive (true) or
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1028 * negative (false).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1029 * @param x_xValues a linked list of the x values (expects values to be
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1030 * of type Double).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1031 * @param x_yValues a linked list of the y values (expects values to be
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1032 * of type Double).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1033 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1034 private void createPolygon (Graphics2D x_graphics,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1035 Rectangle2D x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1036 XYPlot x_plot,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1037 ValueAxis x_domainAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1038 ValueAxis x_rangeAxis,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1039 boolean x_positive,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1040 LinkedList x_xValues,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1041 LinkedList x_yValues) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1042
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1043 PlotOrientation l_orientation = x_plot.getOrientation();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1044 RectangleEdge l_domainAxisLocation = x_plot.getDomainAxisEdge();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1045 RectangleEdge l_rangeAxisLocation = x_plot.getRangeAxisEdge();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1046
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1047 Object[] l_xValues = x_xValues.toArray();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1048 Object[] l_yValues = x_yValues.toArray();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1049
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1050 GeneralPath l_path = new GeneralPath();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1051
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1052 if (PlotOrientation.VERTICAL == l_orientation) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1053 double l_x = x_domainAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1054 (Double) l_xValues[0]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1055 l_domainAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1056 if (this.roundXCoordinates) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1057 l_x = Math.rint(l_x);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1058 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1059
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1060 double l_y = x_rangeAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1061 (Double) l_yValues[0]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1062 l_rangeAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1063
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1064 l_path.moveTo((float) l_x, (float) l_y);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1065 for (int i = 1; i < l_xValues.length; i++) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1066 l_x = x_domainAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1067 (Double) l_xValues[i]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1068 l_domainAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1069 if (this.roundXCoordinates) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1070 l_x = Math.rint(l_x);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1071 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1072
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1073 l_y = x_rangeAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1074 (Double) l_yValues[i]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1075 l_rangeAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1076 l_path.lineTo((float) l_x, (float) l_y);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1077 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1078 l_path.closePath();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1079 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1080 else {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1081 double l_x = x_domainAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1082 (Double) l_xValues[0]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1083 l_domainAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1084 if (this.roundXCoordinates) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1085 l_x = Math.rint(l_x);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1086 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1087
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1088 double l_y = x_rangeAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1089 (Double) l_yValues[0]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1090 l_rangeAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1091
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1092 l_path.moveTo((float) l_y, (float) l_x);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1093 for (int i = 1; i < l_xValues.length; i++) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1094 l_x = x_domainAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1095 (Double) l_xValues[i]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1096 l_domainAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1097 if (this.roundXCoordinates) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1098 l_x = Math.rint(l_x);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1099 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1100
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1101 l_y = x_rangeAxis.valueToJava2D((
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1102 (Double) l_yValues[i]).doubleValue(), x_dataArea,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1103 l_rangeAxisLocation);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1104 l_path.lineTo((float) l_y, (float) l_x);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1105 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1106 l_path.closePath();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1107 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1108
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1109 if (l_path.intersects(x_dataArea)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1110 x_graphics.setPaint(x_positive ? getPositivePaint()
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1111 : getNegativePaint());
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1112 x_graphics.fill(l_path);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1113 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1114 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1115
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1116 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1117 * Returns a default legend item for the specified series. Subclasses
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1118 * should override this method to generate customised items.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1119 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1120 * @param datasetIndex the dataset index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1121 * @param series the series index (zero-based).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1122 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1123 * @return A legend item for the series.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1124 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1125 public LegendItem getLegendItem(int datasetIndex, int series) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1126 LegendItem result = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1127 XYPlot p = getPlot();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1128 if (p != null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1129 XYDataset dataset = p.getDataset(datasetIndex);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1130 if (dataset != null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1131 if (getItemVisible(series, 0)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1132 String label = getLegendItemLabelGenerator().generateLabel(
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1133 dataset, series);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1134 String description = label;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1135 String toolTipText = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1136 if (getLegendItemToolTipGenerator() != null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1137 toolTipText
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1138 = getLegendItemToolTipGenerator().generateLabel(
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1139 dataset, series);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1140 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1141 String urlText = null;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1142 if (getLegendItemURLGenerator() != null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1143 urlText = getLegendItemURLGenerator().generateLabel(
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1144 dataset, series);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1145 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1146 Paint paint = lookupSeriesPaint(series);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1147 Stroke stroke = lookupSeriesStroke(series);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1148 Shape line = getLegendLine();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1149 result = new LegendItem(label, description,
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1150 toolTipText, urlText, line, stroke, paint);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1151 result.setLabelFont(lookupLegendTextFont(series));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1152 Paint labelPaint = lookupLegendTextPaint(series);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1153 if (labelPaint != null) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1154 result.setLabelPaint(labelPaint);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1155 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1156 result.setDataset(dataset);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1157 result.setDatasetIndex(datasetIndex);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1158 result.setSeriesKey(dataset.getSeriesKey(series));
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1159 result.setSeriesIndex(series);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1160 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1161 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1162
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1163 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1164
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1165 return result;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1166
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1167 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1168
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1169 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1170 * Tests this renderer for equality with an arbitrary object.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1171 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1172 * @param obj the object (<code>null</code> permitted).
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1173 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1174 * @return A boolean.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1175 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1176 public boolean equals(Object obj) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1177 if (obj == this) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1178 return true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1179 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1180 if (!(obj instanceof StableXYDifferenceRenderer)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1181 return false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1182 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1183 if (!super.equals(obj)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1184 return false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1185 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1186 StableXYDifferenceRenderer that = (StableXYDifferenceRenderer) obj;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1187 if (!PaintUtilities.equal(this.positivePaint, that.positivePaint)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1188 return false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1189 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1190 if (!PaintUtilities.equal(this.negativePaint, that.negativePaint)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1191 return false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1192 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1193 if (this.shapesVisible != that.shapesVisible) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1194 return false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1195 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1196 if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1197 return false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1198 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1199 if (this.roundXCoordinates != that.roundXCoordinates) {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1200 return false;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1201 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1202 return true;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1203 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1204
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1205 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1206 * Returns a clone of the renderer.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1207 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1208 * @return A clone.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1209 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1210 * @throws CloneNotSupportedException if the renderer cannot be cloned.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1211 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1212 public Object clone() throws CloneNotSupportedException {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1213 StableXYDifferenceRenderer clone = (StableXYDifferenceRenderer) super.clone();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1214 clone.legendLine = ShapeUtilities.clone(this.legendLine);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1215 return clone;
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1216 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1217
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1218 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1219 * Provides serialization support.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1220 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1221 * @param stream the output stream.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1222 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1223 * @throws IOException if there is an I/O error.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1224 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1225 private void writeObject(ObjectOutputStream stream) throws IOException {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1226 stream.defaultWriteObject();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1227 SerialUtilities.writePaint(this.positivePaint, stream);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1228 SerialUtilities.writePaint(this.negativePaint, stream);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1229 SerialUtilities.writeShape(this.legendLine, stream);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1230 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1231
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1232 /**
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1233 * Provides serialization support.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1234 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1235 * @param stream the input stream.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1236 *
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1237 * @throws IOException if there is an I/O error.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1238 * @throws ClassNotFoundException if there is a classpath problem.
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1239 */
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1240 private void readObject(ObjectInputStream stream)
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1241 throws IOException, ClassNotFoundException {
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1242 stream.defaultReadObject();
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1243 this.positivePaint = SerialUtilities.readPaint(stream);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1244 this.negativePaint = SerialUtilities.readPaint(stream);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1245 this.legendLine = SerialUtilities.readShape(stream);
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1246 }
7a11b37d8594 Added a copy of JFreeChart's XYDifferenceRenderer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1247 }

http://dive4elements.wald.intevation.org