# HG changeset patch # User sascha.teichmann@intevation.de # Date 1383908257 -3600 # Node ID d20a26e96ef1e97b6619eedd4ad9e7e96855f08f # Parent 9344aa0fb02135996a4aad0e2938977ab9d2e2b9 issue1585: Part 1/2 of patch from Sascha Teichmann to define shape for datapoints. Just a tiny fix done by me. diff -r 9344aa0fb021 -r d20a26e96ef1 artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java --- 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 Ingo Weinzierl */ @@ -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; diff -r 9344aa0fb021 -r d20a26e96ef1 artifacts/src/main/java/org/dive4elements/river/jfree/XYStyle.java --- 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);