changeset 3395:2a8919e0ed28

Cosmetics, doc. flys-artifacts/trunk@5025 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 17 Jul 2012 18:40:25 +0000
parents f091f2f55f88
children 3bffbf670b49
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 8 files changed, 93 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue Jul 17 18:40:25 2012 +0000
@@ -1,3 +1,32 @@
+2012-07-17	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java,
+	  src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java,
+	  src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java,
+	  src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java,
+	  src/main/java/de/intevation/flys/collections/CollectionAttribute.java:
+	  Cosmetics, doc.
+
+2012-07-17	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Partial implementation of issue720 (bandwith for curves), in
+	longitudinal section ws only, no styling, integer-based.
+
+	* doc/conf/default-themes.xml: Add bandwidth to fields of longitudinal
+	  section facets.
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java: Add bandwidth
+	  theme parsing.
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  If bandwidth is set, add an area data series with datapoints
+	  above/under the actual data points.
+
+	* src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java:
+	  Helper for adding points with offset.
+
 2012-07-17	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java	Tue Jul 17 18:40:25 2012 +0000
@@ -23,12 +23,12 @@
 import de.intevation.artifactdatabase.state.Settings;
 
 
+/** Create attribute part of collection document. */
 public class CollectionAttribute {
 
     private static final Logger logger =
         Logger.getLogger(CollectionAttribute.class);
 
-
     protected ElementCreator ec;
 
     protected Map<String, Output> outputMap;
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue Jul 17 18:40:25 2012 +0000
@@ -430,15 +430,18 @@
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
 
         StyledSeriesBuilder.addPoints(series, wkms);
-        XYSeries seriesDown = new StyledXYSeries(aandf.getFacetDescription()+"-",false, theme);
-        XYSeries seriesUp = new StyledXYSeries(aandf.getFacetDescription()+"+",false, theme);
-        StyledSeriesBuilder.addUpperBand(seriesUp, wkms, 5d);
-        StyledSeriesBuilder.addLowerBand(seriesDown, wkms, 5d);
-
         addAxisSeries(series, YAXIS.W.idx, visible);
 
+        // If a "band around the curve shall be drawn, add according area.
         int bandWidth = ThemeUtil.parseBandWidth(theme);
         if (bandWidth > 0 ) {
+            XYSeries seriesDown = new StyledXYSeries(
+                "band " + aandf.getFacetDescription(), false, theme);
+            XYSeries seriesUp = new StyledXYSeries(
+                aandf.getFacetDescription()+"-", false, theme);
+            StyledSeriesBuilder.addUpperBand(seriesUp, wkms, 5d);
+            StyledSeriesBuilder.addLowerBand(seriesDown, wkms, 5d);
+
             StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme);
             area.addSeries(seriesUp);
             area.addSeries(seriesDown);
@@ -446,7 +449,6 @@
             addAreaSeries(area, YAXIS.W.idx, visible);
         }
 
-
         if (needInvertAxis(wkms)) {
             setInverted(true);
         }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java	Tue Jul 17 18:40:25 2012 +0000
@@ -74,6 +74,13 @@
         }
     }
 
+
+    /**
+     * Add points to dataset with an offset (shift all points by given amount).
+     * @param series series to add data to.
+     * @param wkms WKms of which the Ws will be shifted.
+     * @param off the offset.
+     */
     public static void addUpperBand(XYSeries series, WKms wkms, double off) {
         if (wkms == null) {
             return;
@@ -86,10 +93,19 @@
         }
     }
 
+
+    /**
+     * Add points to dataset with an offset (shift all points 'down' by given
+     * amount).
+     * @param series series to add data to.
+     * @param wkms WKms of which the Ws will be shifted.
+     * @param off the offset.
+     */
     public static void addLowerBand(XYSeries series, WKms wkms, double off) {
         addUpperBand(series, wkms, -off);
     }
 
+
     /**
      * Add points to series (km to 1st dim, q to 2nd dim).
      *
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java	Tue Jul 17 18:40:25 2012 +0000
@@ -123,6 +123,7 @@
     }
 
 
+    /** Get fill paint for the maximum indicators. */
     public Paint getMaximumFillPaint(int series, int column) {
         Paint p = getItemPaint(series, column);
 
@@ -142,6 +143,7 @@
     }
 
 
+    /** Get fill paint for the minimum indicators. */
     public Paint getMinimumFillPaint(int series, int column) {
         Paint p = getItemPaint(series, column);
 
@@ -274,14 +276,17 @@
             yy = transX1;
         }
 
-        // draw the item label if there is one...
+        // Draw the item label if there is one...
         if (isItemLabelVisible(series, item)) {
             drawItemLabel(g2, orientation, dataset, series, item, xx, yy,
                     (y1 < 0.0));
         }
 
         // Draw label of line.
-        if (dataset instanceof XYSeriesCollection && isShowLineLabel(series) && isMinimumX (dataset, series, item)) {
+        if (dataset instanceof XYSeriesCollection
+            && isShowLineLabel(series)
+            && isMinimumX (dataset, series, item)
+            ) {
             XYSeries xYSeries = ((XYSeriesCollection) dataset).getSeries(series);
             String waterlevelLabel = (xYSeries instanceof HasLabel)
                 ? ((HasLabel)xYSeries).getLabel()
@@ -297,9 +302,11 @@
 
             // Move to right until no collisions exist anymore
             Shape hotspot = TextUtilities.calculateRotatedStringBounds(
-                waterlevelLabel, g2, (float)xx, (float)yy-3f, TextAnchor.CENTER_LEFT,
+                waterlevelLabel, g2, (float)xx, (float)yy-3f,
+                TextAnchor.CENTER_LEFT,
                 0f, TextAnchor.CENTER_LEFT);
-            while (JFreeUtil.collides(hotspot, entities, CollisionFreeLineLabelEntity.class)) {
+            while (JFreeUtil.collides(hotspot, entities,
+                                      CollisionFreeLineLabelEntity.class)) {
                 xx += 5f;
                 hotspot = TextUtilities.calculateRotatedStringBounds(
                     waterlevelLabel, g2, (float)xx, (float)yy-3f, TextAnchor.CENTER_LEFT,
@@ -327,7 +334,7 @@
         updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex,
                 rangeAxisIndex, transX1, transY1, orientation);
 
-        // add an entity for the item, but only if it falls within the data
+        // Add an entity for the item, but only if it falls within the data
         // area...
         if (entities != null && isPointInRect(dataArea, xx, yy)) {
             addEntity(entities, entityArea, dataset, series, item, xx, yy);
@@ -343,6 +350,9 @@
     }
 
 
+    /**
+     * Whether or not the minimum should be rendered with shape.
+     */
     public boolean isMinimumShapeVisible(int series) {
         if (this.isMinimumShapeVisible.size() <= series) {
             return false;
@@ -352,11 +362,17 @@
     }
 
 
+    /**
+     * Sets whether or not the maximum should be rendered with shape.
+     */
     public void setIsMaximumShapeVisible(int series, boolean isVisible) {
         this.isMaximumShapeVisible.setBoolean(series, isVisible);
     }
 
 
+    /**
+     * Whether or not the maximum should be rendered with shape.
+     */
     public boolean isMaximumShapeVisible(int series) {
         if (this.isMaximumShapeVisible.size() <= series) {
             return false;
@@ -380,6 +396,7 @@
         this.showLineLabel.setBoolean(series, showLineLabel);
     }
 
+
     /** Whether or not a label should be shown for series. */
     public boolean isShowLineLabelBG(int series) {
         if (this.showLineLabelBG.size() <= series) {
@@ -389,6 +406,7 @@
         return showLineLabelBG.getBoolean(series);
     }
 
+
     public void setShowLineLabelBG(int series, boolean doShow) {
         this.showLineLabelBG.setBoolean(series, doShow);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java	Tue Jul 17 18:40:25 2012 +0000
@@ -502,7 +502,7 @@
      * The renderer can do nothing if it chooses.
      *
      * @param g2  the graphics device.
-     * @param dataArea  the area inside the axes.
+     * @param dataArea  the (visible) area inside the axes.
      * @param plot  the plot.
      * @param data  the data.
      * @param info  an optional info collection object to return data back to
@@ -532,6 +532,10 @@
         return 2;
     }
 
+
+    /**
+     * Adds x/y data to series.
+     */
     private static final void addSeries(
         DefaultXYDataset ds,
         Comparable       key,
@@ -830,6 +834,7 @@
         }
     }
 
+
     /**
      * Draws the visual representation of a single data item.
      *
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java	Tue Jul 17 18:40:25 2012 +0000
@@ -58,6 +58,8 @@
     /**
      * Applies line color, size and type attributes to renderer, also
      * whether to draw lines and/or points.
+     * @param renderer Renderer to apply theme to.
+     * @return \param renderer
      */
     public StableXYDifferenceRenderer applyTheme(
         StableXYDifferenceRenderer renderer
@@ -117,14 +119,13 @@
         renderer.setDrawOutline(show);
     }
 
+
     protected void applyShowLine(StableXYDifferenceRenderer renderer) {
         boolean show = ThemeUtil.parseShowLine(theme);
         renderer.setShapesVisible(show);
     }
 
-    /**
-     *
-     */
+
     protected void applyOutlineColor(StableXYDifferenceRenderer renderer) {
         Color c = ThemeUtil.parseLineColorField(theme);
         renderer.setOutlinePaint(c);
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue Jul 17 18:31:34 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue Jul 17 18:40:25 2012 +0000
@@ -134,6 +134,7 @@
     public final static String XPATH_WSPLGEN_FIELDS =
         "/theme[@name='WSPLGEN']/field";
 
+    /** XPATH to bandwidth field. */
     public final static String XPATH_BANDWIDTH =
         "/theme/field[@name='bandwidth']/@default";
 
@@ -191,12 +192,17 @@
     }
 
 
+    /**
+     * Parse band width, defaulting to 0.
+     * @param theme the theme.
+     */
     public static int parseBandWidth(Document theme) {
         String bandWidth = XMLUtils.xpathString(theme, XPATH_BANDWIDTH, null);
 
         return parseInteger(bandWidth, 0);
     }
 
+
     public static int parsePointWidth(Document theme) {
         String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null);
 

http://dive4elements.wald.intevation.org