changeset 7541:d20a26e96ef1

issue1585: Part 1/2 of patch from Sascha Teichmann to define shape for datapoints. Just a tiny fix done by me.
author sascha.teichmann@intevation.de
date Fri, 08 Nov 2013 11:57:37 +0100
parents 9344aa0fb021
children db780379ea82
files artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java artifacts/src/main/java/org/dive4elements/river/jfree/XYStyle.java
diffstat 2 files changed, 39 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java	Fri Nov 08 10:38:37 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java	Fri Nov 08 11:57:37 2013 +0100
@@ -16,6 +16,8 @@
 import org.jfree.data.xy.XYDataItem;
 import org.jfree.data.xy.XYSeries;
 
+import java.awt.Shape;
+
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
@@ -30,8 +32,7 @@
 
 
     public StyledXYSeries(String key, ThemeDocument theme) {
-        this(key, true, theme);
-        this.label = key.toString();
+        this(key, true, theme, (Shape)null);
     }
 
 
@@ -40,31 +41,48 @@
         add(unstyledSeries);
     }
 
+    public StyledXYSeries(String key, boolean sorted, ThemeDocument theme) {
+        this(key, sorted, theme, (Shape)null);
+    }
+
+
+    public StyledXYSeries(String key, ThemeDocument theme, Shape shape) {
+        this(key, true, theme, shape);
+    }
 
     /**
      * @param sorted whether or not to sort the points. Sorting will move NANs
      *               to one extrema which can cause problems in certain
      *               algorithms.
      */
-    public StyledXYSeries(String key, boolean sorted, ThemeDocument theme) {
+    public StyledXYSeries(String key, boolean sorted, ThemeDocument theme, Shape shape) {
         super(key, sorted);
-        setStyle(new XYStyle(theme));
+        setStyle(new XYStyle(theme, shape));
         this.label = key.toString();
     }
 
     public StyledXYSeries(
-        String  key,
-        boolean sorted,
-        boolean allowDuplicateXValues,
+        String        key,
+        boolean       sorted,
+        boolean       allowDuplicateXValues,
         ThemeDocument theme
     ) {
+        this(key, sorted, allowDuplicateXValues, theme, (Shape)null);
+    }
+
+    public StyledXYSeries(
+        String        key,
+        boolean       sorted,
+        boolean       allowDuplicateXValues,
+        ThemeDocument theme,
+        Shape         shape
+    ) {
         super(key, sorted, allowDuplicateXValues);
-        setStyle(new XYStyle(theme));
+        setStyle(new XYStyle(theme, shape));
         this.label = key.toString();
     }
 
 
-
     @Override
     public void setStyle(Style style) {
         this.style = style;
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/XYStyle.java	Fri Nov 08 10:38:37 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/jfree/XYStyle.java	Fri Nov 08 11:57:37 2013 +0100
@@ -12,6 +12,7 @@
 
 import java.awt.BasicStroke;
 import java.awt.Color;
+import java.awt.Shape;
 import java.awt.geom.Ellipse2D;
 
 import org.apache.log4j.Logger;
@@ -30,11 +31,18 @@
 
     protected XYLineAndShapeRenderer renderer;
 
+    protected Shape shape;
+
 
     public XYStyle(ThemeDocument theme) {
         this.theme = theme;
     }
 
+    public XYStyle(ThemeDocument theme, Shape shape) {
+        this.theme = theme;
+        this.shape = shape;
+    }
+
 
     /**
      * Applies line color, size and type attributes to renderer, also
@@ -42,11 +50,14 @@
      */
     @Override
     public XYLineAndShapeRenderer applyTheme(XYLineAndShapeRenderer r, int idx) {
+        this.renderer = r;
+        if (shape != null) {
+            r.setShape(shape);
+        }
         if (theme == null) {
             // Hurray we already applied nothing :)
             return r;
         }
-        this.renderer = r;
         applyLineColor(r, idx);
         applyLineSize(r, idx);
         applyLineType(r, idx);

http://dive4elements.wald.intevation.org