changeset 2591:74c02dbf17ca

#523 Improved the look of minimum and maximum shapes in chart series. flys-artifacts/trunk@4148 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 16 Mar 2012 07:06:19 +0000
parents d75b427da50a
children 26cd4dfafdf1
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java
diffstat 2 files changed, 93 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Mar 15 12:28:11 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Mar 16 07:06:19 2012 +0000
@@ -1,3 +1,11 @@
+2012-03-16  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue523 (W-INFO / Bezugslinienverfahren / Linieneinstellungen / Min+Max anzeigen)
+
+	* src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java:
+	  Improved the look of the minimum and maximum shape of a series. They are
+	  now rectangles with a darker fill color as the line color is.
+
 2012-03-15  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue522 (W-INFO / Bezugslinienverfahren / Schriftgröße der Achsenbeschriftung)
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java	Thu Mar 15 12:28:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java	Fri Mar 16 07:06:19 2012 +0000
@@ -1,6 +1,8 @@
 package de.intevation.flys.jfree;
 
+import java.awt.Color;
 import java.awt.Graphics2D;
+import java.awt.Paint;
 import java.awt.Shape;
 import java.awt.geom.Rectangle2D;
 import java.util.HashMap;
@@ -58,6 +60,54 @@
     }
 
 
+    public Shape getMaximumShape(int series, int column) {
+        return new Rectangle2D.Double(-5d, -5d, 10d, 10d);
+    }
+
+
+    public Shape getMinimumShape(int series, int column) {
+        return new Rectangle2D.Double(-5d, -5d, 10d, 10d);
+    }
+
+
+    public Paint getMaximumFillPaint(int series, int column) {
+        Paint p = getItemPaint(series, column);
+
+        if (p instanceof Color) {
+            Color c = (Color) p;
+            Color b = c;
+
+            for (int i = 0; i < 2; i++) {
+                b = b.darker();
+            }
+
+            return b;
+        }
+
+        logger.warn("Item paint is no instance of Color!");
+        return p;
+    }
+
+
+    public Paint getMinimumFillPaint(int series, int column) {
+        Paint p = getItemPaint(series, column);
+
+        if (p instanceof Color) {
+            Color c = (Color) p;
+            Color b = c;
+
+            for (int i = 0; i < 2; i++) {
+                b = b.darker();
+            }
+
+            return b;
+        }
+
+        logger.warn("Item paint is no instance of Color!");
+        return p;
+    }
+
+
     /**
      * Overrides XYLineAndShapeRenderer.drawSecondaryPass() to call an adapted
      * method getItemShapeVisible() which now takes an XYDataset. So, 99% of
@@ -93,7 +143,26 @@
         double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
 
         if (getItemShapeVisible(dataset, series, item)) {
-            Shape shape = getItemShape(series, item);
+            Shape shape = null;
+
+            boolean isMinimum = isMinimumShapeVisible(series)
+                && isMinimum(dataset, series, item);
+
+            boolean isMaximum = isMaximumShapeVisible(series)
+                && isMaximum(dataset, series, item);
+
+            if (isMinimum) {
+                logger.debug("Create a Minimum shape.");
+                shape = getMinimumShape(series, item);
+            }
+            else if (isMaximum) {
+                logger.debug("Create a Maximum shape.");
+                shape = getMaximumShape(series, item);
+            }
+            else {
+                shape = getItemShape(series, item);
+            }
+
             if (orientation == PlotOrientation.HORIZONTAL) {
                 shape = ShapeUtilities.createTranslatedShape(shape, transY1,
                         transX1);
@@ -123,6 +192,21 @@
                     g2.setStroke(getItemOutlineStroke(series, item));
                     g2.draw(shape);
                 }
+
+                if (isMinimum) {
+                    g2.setPaint(getMinimumFillPaint(series, item));
+                    g2.fill(shape);
+                    g2.setPaint(getItemOutlinePaint(series, item));
+                    g2.setStroke(getItemOutlineStroke(series, item));
+                    g2.draw(shape);
+                }
+                else if (isMaximum) {
+                    g2.setPaint(getMaximumFillPaint(series, item));
+                    g2.fill(shape);
+                    g2.setPaint(getItemOutlinePaint(series, item));
+                    g2.setStroke(getItemOutlineStroke(series, item));
+                    g2.draw(shape);
+                }
             }
         }
 

http://dive4elements.wald.intevation.org