changeset 3164:6d0567a8387d

Label more points in FixingsKMChartService flys-artifacts/trunk@4776 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 25 Jun 2012 13:15:35 +0000
parents dad513d5ce37
children 6b13d7e7b403
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java
diffstat 4 files changed, 78 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jun 25 11:55:34 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jun 25 13:15:35 2012 +0000
@@ -1,3 +1,16 @@
+2012-06-25	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/jfree/ShapeRenderer.java: If a label collides
+	  with a other labels try to draw it on the other side of the point.
+	  This results in more labeled points which is useful because you cannot zoom
+	  in for details in the fixings km chart.
+
+	* src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java:
+	  Paint measured points blue and interpolated green.
+
+	* src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java:
+	  Set background color to white.
+
 2012-06-25	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java	Mon Jun 25 11:55:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java	Mon Jun 25 13:15:35 2012 +0000
@@ -274,7 +274,12 @@
 
         applyQSectorMarkers(plot, river, km);
 
-        ChartUtilities.applyCurrentTheme(chart);
+        chart.setBackgroundPaint(Color.white);
+        plot.setBackgroundPaint(Color.white);
+        plot.setDomainGridlinePaint(Color.gray);
+        plot.setRangeGridlinePaint(Color.gray);
+        plot.setDomainGridlinesVisible(true);
+        plot.setRangeGridlinesVisible(true);
 
         return chart;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java	Mon Jun 25 11:55:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java	Mon Jun 25 13:15:35 2012 +0000
@@ -87,14 +87,18 @@
     }
 
     protected static ShapeRenderer.Entry classify(QW qw) {
-        Shape shape = qw.getInterpolated()
+        boolean interpolated = qw.getInterpolated();
+
+        Shape shape = interpolated
             ? ShapeUtils.INTERPOLATED_SHAPE
             : ShapeUtils.MEASURED_SHAPE;
 
-        boolean filled = !qw.getInterpolated();
+        boolean filled = !interpolated;
+        Color color = interpolated
+            ? Color.green
+            : Color.blue;
 
-        return new ShapeRenderer.Entry(
-            shape, Color.black, filled);
+        return new ShapeRenderer.Entry(shape, color, filled);
     }
 
     public void add(QW qw) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java	Mon Jun 25 11:55:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java	Mon Jun 25 13:15:35 2012 +0000
@@ -293,50 +293,61 @@
 
         String label = generator.generateLabel(dataset, series, item);
 
-        // get the label position..
-        ItemLabelPosition position = null;
-        if (!negative) {
-            position = getPositiveItemLabelPosition(series, item);
-        }
-        else {
-            position = getNegativeItemLabelPosition(series, item);
-        }
-
-        // work out the label anchor point...
-        Point2D anchorPoint = calculateLabelAnchorPoint(
-            position.getItemLabelAnchor(), x, y, orientation);
-
-        Shape labelShape = TextUtilities.calculateRotatedStringBounds(
-            label, g2,
-            (float)anchorPoint.getX(), (float)anchorPoint.getY(),
-            position.getTextAnchor(), position.getAngle(),
-            position.getRotationAnchor());
-
-        Rectangle2D bbox = labelShape.getBounds2D();
+        ATTEMPS: for (int attempt = 0; attempt < 2; ++attempt) {
+            // get the label position..
+            ItemLabelPosition position = null;
 
-        Point2D shift = shiftBox(bbox);
-
-        bbox = new Rectangle2D.Double(
-            bbox.getX() + shift.getX(),
-            bbox.getY() + shift.getY(),
-            bbox.getWidth(),
-            bbox.getHeight());
+            boolean pos;
+            switch (attempt) {
+                case 0: pos = negative; break;
+                case 1: pos = !negative; break;
+                default: break ATTEMPS;
+            }
 
-        if (labelBoundingBoxes != null) {
-            for (Rectangle2D old: labelBoundingBoxes) {
-                if (old.intersects(bbox)) {
-                    return;
-                }
+            if (pos) {
+                position = getNegativeItemLabelPosition(series, item);
             }
-            labelBoundingBoxes.add(bbox);
-        }
+            else {
+                position = getPositiveItemLabelPosition(series, item);
+            }
 
-        TextUtilities.drawRotatedString(
-            label, g2,
-            (float)(anchorPoint.getX() + shift.getX()),
-            (float)(anchorPoint.getY() + shift.getY()),
-            position.getTextAnchor(), position.getAngle(),
-            position.getRotationAnchor());
+            // work out the label anchor point...
+            Point2D anchorPoint = calculateLabelAnchorPoint(
+                position.getItemLabelAnchor(), x, y, orientation);
+
+            Shape labelShape = TextUtilities.calculateRotatedStringBounds(
+                label, g2,
+                (float)anchorPoint.getX(), (float)anchorPoint.getY(),
+                position.getTextAnchor(), position.getAngle(),
+                position.getRotationAnchor());
+
+            Rectangle2D bbox = labelShape.getBounds2D();
+
+            Point2D shift = shiftBox(bbox);
+
+            bbox = new Rectangle2D.Double(
+                bbox.getX() + shift.getX(),
+                bbox.getY() + shift.getY(),
+                bbox.getWidth(),
+                bbox.getHeight());
+
+            if (labelBoundingBoxes != null) {
+                for (Rectangle2D old: labelBoundingBoxes) {
+                    if (old.intersects(bbox)) {
+                        continue ATTEMPS;
+                    }
+                }
+                labelBoundingBoxes.add(bbox);
+            }
+
+            TextUtilities.drawRotatedString(
+                label, g2,
+                (float)(anchorPoint.getX() + shift.getX()),
+                (float)(anchorPoint.getY() + shift.getY()),
+                position.getTextAnchor(), position.getAngle(),
+                position.getRotationAnchor());
+            break;
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org