changeset 3286:f062b5a90e26

Add showpointlabel style attribute flys-artifacts/trunk@4948 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Thu, 12 Jul 2012 11:51:32 +0000
parents dc083f61253a
children 30f157c7e466
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/default-themes.xml flys-artifacts/doc/conf/virtual-themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 9 files changed, 105 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jul 12 11:51:32 2012 +0000
@@ -1,3 +1,18 @@
+2012-07-12	Christian Lins <christian.lins@intevation.de>
+
+	* doc/conf/default-themes.xml,
+	  doc/conf/virtual-themes.xml,
+	  src/main/java/de/intevation/flys/utils/ThemeUtil.java,
+	  src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java,
+	  src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java,
+	  src/main/java/de/intevation/flys/themes/ThemeAccess.java:
+	  Add showpointlabel style attribute. Refactor some styles to make use of
+	  general attributes in the virtual themes.
+
+	* src/main/java/de/intevation/flys/utils/GeometryUtils.java,
+	  src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java:
+	  Suppress or fix some warnings.
+
 2012-07-12	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* doc/conf/conf.xml: Fix class name.
--- a/flys-artifacts/doc/conf/default-themes.xml	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/doc/conf/default-themes.xml	Thu Jul 12 11:51:32 2012 +0000
@@ -1152,8 +1152,8 @@
                 default="3" />
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="0, 128, 0" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="true" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
         </fields>
     </theme>
     <theme name="FixingSectorAverageWQ1">
@@ -1168,8 +1168,8 @@
                 default="3" />
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="0, 0, 255" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="true" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
         </fields>
     </theme>
     <theme name="FixingSectorAverageWQ2">
@@ -1184,8 +1184,8 @@
                 default="3" />
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="255, 0, 255" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="true" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
         </fields>
     </theme>
     <theme name="FixingSectorAverageWQ3">
@@ -1200,8 +1200,8 @@
                 default="3" />
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="255, 0, 0" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="true" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
         </fields>
     </theme>
 
@@ -1210,15 +1210,13 @@
             <inherit from="ColorPoints" />
         </inherits>
         <fields>
-            <field name="showlinelabel" type="boolean"
-                display="Beschriftung anzeigen" default="false" hints="h" />
             <field name="showlines" type="boolean" default="false" />
             <field name="pointsize" type="int" display="Punktdicke"
                 default="3" />
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="0, 255, 0" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="true" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
         </fields>
     </theme>
 
@@ -1227,15 +1225,12 @@
             <inherit from="ColorPoints" />
         </inherits>
         <fields>
-            <field name="showlinelabel" type="boolean"
-                display="Beschriftung anzeigen" default="false" hints="h" />
-            <field name="showlines" type="boolean" default="false" />
             <field name="pointsize" type="int" display="Punktdicke"
                 default="3" />
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="0, 80, 160" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="true" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="true"/>
         </fields>
     </theme>
 
@@ -1244,9 +1239,8 @@
             <inherit from="ColorPoints" />
         </inherits>
         <fields>
-            <field name="showlines" type="boolean" default="false" />
-            <field name="textorientation" type="boolean" display="Textausrichtung"
-                default="true" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/doc/conf/virtual-themes.xml	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/doc/conf/virtual-themes.xml	Thu Jul 12 11:51:32 2012 +0000
@@ -30,14 +30,19 @@
 
     <theme name="Points" type="virtual">
         <fields>
-            <field name="showlines" type="boolean" display="Linie anzeigen"
-                default="false" />
+            <field name="showlinelabel" type="boolean"
+                display="Linienbeschriftung anzeigen" default="false" hints="h" />
+            <field name="showlines" type="boolean" default="false" />
             <field name="linesize" type="int" display="Liniendicke"
                 default="1" />
             <field name="linetype" type="Dash" display="Linienart"
                 default="10" />
             <field name="showpoints" type="boolean" display="Punkte anzeigen"
                 default="true" />
+            <field name="textorientation" type="boolean" display="Text horizontal"
+                default="true"/>
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
         </fields>
     </theme>
 
@@ -70,6 +75,9 @@
     </theme>
 
     <theme name="ColorPoints" type="virtual">
+        <inherits>
+            <inherit from="Points" />
+        </inherits>
         <fields>
             <field name="showpoints" type="boolean" display="Datenpunkte anzeigen"
                 default="true" />
@@ -77,8 +85,6 @@
                 default="5" />
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="Color.BLACK" />
-            <field name="textorientation" type="boolean" display="Text horizontal"
-                default="true"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Thu Jul 12 11:51:32 2012 +0000
@@ -309,7 +309,7 @@
             boolean visible) {
         logger.debug("doQWDTextAnnotation()");
 
-        if (!ThemeUtil.parseShowLineLabel(theme)) {
+        if (!visible || !ThemeUtil.parseShowPointLabel(theme)) {
             logger.debug("doQWDTextAnnotation: annotation not visible");
             return;
         }
@@ -329,11 +329,9 @@
             logger.debug("annotation: " + x + "/" + qwd.getDeltaW());
         }
 
-        if(visible) {
-            FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, theme);
-            flysAnno.setTextAnnotations(textAnnos);
-            addAnnotations(flysAnno);
-        }
+        FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, theme);
+        flysAnno.setTextAnnotations(textAnnos);
+        addAnnotations(flysAnno);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java	Thu Jul 12 11:51:32 2012 +0000
@@ -1,33 +1,25 @@
 package de.intevation.flys.exports.fixings;
 
-import java.util.List;
-import java.util.ArrayList;
+import de.intevation.artifactdatabase.state.ArtifactAndFacet;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.fixings.AnalysisPeriod;
+import de.intevation.flys.artifacts.model.fixings.QWD;
+import de.intevation.flys.exports.ChartGenerator;
+import de.intevation.flys.exports.XYChartGenerator;
+import de.intevation.flys.jfree.StyledAreaSeriesCollection;
+import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.utils.KMIndex;
 
 import java.awt.BasicStroke;
 import java.awt.Color;
-
-import de.intevation.artifactdatabase.state.ArtifactAndFacet;
-
-import de.intevation.flys.artifacts.model.FacetTypes;
-
-import de.intevation.flys.artifacts.model.fixings.QWD;
-import de.intevation.flys.artifacts.model.fixings.AnalysisPeriod;
-
-import de.intevation.flys.exports.ChartGenerator;
-import de.intevation.flys.exports.XYChartGenerator;
-
-import de.intevation.flys.jfree.StyledXYSeries;
-import de.intevation.flys.jfree.StyledAreaSeriesCollection;
-
-import de.intevation.flys.utils.KMIndex;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.log4j.Logger;
-
-import org.jfree.data.xy.XYSeries;
 import org.jfree.chart.plot.Marker;
 import org.jfree.chart.plot.ValueMarker;
+import org.jfree.data.xy.XYSeries;
 import org.jfree.data.xy.XYSeriesCollection;
-
 import org.w3c.dom.Document;
 
 public class FixLongitudinalSectionGenerator
@@ -92,6 +84,7 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     protected void doSectorAverageOut(
         ArtifactAndFacet aaf,
         Document doc,
@@ -128,6 +121,7 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     protected void doSectorAverageDeviationOut(
         ArtifactAndFacet aaf,
         Document doc,
@@ -175,6 +169,7 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     protected void doReferenceDeviationOut(
         ArtifactAndFacet aaf,
         Document doc,
@@ -218,6 +213,7 @@
         addAreaSeries(area, 0, visible);
     }
 
+    @SuppressWarnings("unchecked")
     protected void doAnalysisEventsOut(
         ArtifactAndFacet aaf,
         Document doc,
@@ -225,7 +221,6 @@
     {
         logger.debug("doAnalysisEventsOut");
         int index = aaf.getFacet().getIndex();
-        int sectorNdx = index & 3;
         int periodNdx = index >> 2;
 
         KMIndex<AnalysisPeriod[]> kms =
@@ -262,6 +257,7 @@
         addAxisDataset(col, 0, visible);
     }
 
+    @SuppressWarnings("unchecked")
     protected void doReferenceEventsOut(
         ArtifactAndFacet aaf,
         Document doc,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Thu Jul 12 11:51:32 2012 +0000
@@ -11,6 +11,7 @@
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.JFreeUtil;
 import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.utils.ThemeUtil;
 
 import java.text.DateFormat;
 import java.util.ArrayList;
@@ -22,7 +23,7 @@
 import org.w3c.dom.Document;
 
 /**
- *
+ * Generator for WQ fixing charts.
  * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a>
  */
 public class FixWQCurveGenerator
@@ -159,9 +160,9 @@
         addQWSeries(qws, aaf, doc, visible);
     }
 
-    protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document doc, boolean visible) {
+    protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document theme, boolean visible) {
          if(qws != null) {
-            XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
+            XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
             List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
 
             DateFormat dateFormat = DateFormat.getDateInstance(
@@ -178,8 +179,8 @@
             }
 
             addAxisSeries(series, 0, visible);
-            if(visible) {
-                FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, doc);
+            if(visible && ThemeUtil.parseShowPointLabel(theme)) {
+                FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, theme);
                 flysAnno.setTextAnnotations(textAnnos);
                 addAnnotations(flysAnno);
             }
--- a/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java	Thu Jul 12 11:51:32 2012 +0000
@@ -1,15 +1,14 @@
 package de.intevation.flys.themes;
 
+import de.intevation.flys.jfree.StableXYDifferenceRenderer;
+import de.intevation.flys.utils.ThemeUtil;
+
 import java.awt.Color;
 import java.awt.Font;
 
+import org.jfree.chart.annotations.XYTextAnnotation;
 import org.w3c.dom.Document;
 
-import de.intevation.flys.jfree.StableXYDifferenceRenderer;
-import de.intevation.flys.utils.ThemeUtil;
-
-import org.jfree.chart.annotations.XYTextAnnotation;
-
 
 /** Undocumented. */
 public class ThemeAccess
@@ -116,6 +115,10 @@
         return new LineStyle(parseLineColorField(), Integer.valueOf(parseLineWidth()));
     }
 
+    public static class PointStyle {
+        // TODO tbd
+    }
+
     public static class LineStyle {
         protected Color lineColor;
         protected int   lineWidth;
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Thu Jul 12 11:51:32 2012 +0000
@@ -1,7 +1,13 @@
 package de.intevation.flys.utils;
 
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.Geometry;
+
+import de.intevation.flys.model.RiverAxis;
+
+import java.io.File;
 import java.io.IOException;
-import java.io.File;
 import java.io.Serializable;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
@@ -10,11 +16,19 @@
 import java.util.Map;
 
 import org.apache.log4j.Logger;
-
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.Envelope;
-import com.vividsolutions.jts.geom.Geometry;
-
+import org.geotools.data.DataStoreFactorySpi;
+import org.geotools.data.DefaultTransaction;
+import org.geotools.data.FeatureWriter;
+import org.geotools.data.Transaction;
+import org.geotools.data.shapefile.ShapefileDataStore;
+import org.geotools.data.shapefile.ShapefileDataStoreFactory;
+import org.geotools.data.simple.SimpleFeatureIterator;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.FeatureIterator;
+import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
+import org.geotools.geojson.feature.FeatureJSON;
+import org.geotools.geometry.jts.JTS;
+import org.geotools.referencing.CRS;
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
 import org.opengis.referencing.FactoryException;
@@ -23,22 +37,6 @@
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 
-import org.geotools.data.DataStoreFactorySpi;
-import org.geotools.data.DefaultTransaction;
-import org.geotools.data.FeatureWriter;
-import org.geotools.data.Transaction;
-import org.geotools.data.shapefile.ShapefileDataStore;
-import org.geotools.data.shapefile.ShapefileDataStoreFactory;
-import org.geotools.data.simple.SimpleFeatureIterator;
-import org.geotools.feature.FeatureIterator;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
-import org.geotools.geojson.feature.FeatureJSON;
-import org.geotools.geometry.jts.JTS;
-import org.geotools.referencing.CRS;
-
-import de.intevation.flys.model.RiverAxis;
-
 
 public class GeometryUtils {
 
@@ -134,7 +132,7 @@
 
 
     public static SimpleFeatureType buildFeatureType(
-        String name, String srs, Class geometryType)
+        String name, String srs, Class<?> geometryType)
     {
         return buildFeatureType(name, srs, geometryType, null);
     }
@@ -153,7 +151,7 @@
      * @return a new SimpleFeatureType.
      */
     public static SimpleFeatureType buildFeatureType(
-        String name, String srs, Class geometryType, Object[][] attrs)
+        String name, String srs, Class<?> geometryType, Object[][] attrs)
     {
         try {
             SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
@@ -168,7 +166,7 @@
 
             if (attrs != null) {
                 for (Object[] attr: attrs) {
-                    builder.add((String) attr[0], (Class) attr[1]);
+                    builder.add((String) attr[0], (Class<?>) attr[1]);
                 }
             }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Thu Jul 12 07:47:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Thu Jul 12 11:51:32 2012 +0000
@@ -62,6 +62,9 @@
     public final static String XPATH_SHOW_LINE_LABEL =
         "/theme/field[@name='showlinelabel']/@default";
 
+    public final static String XPATH_SHOW_POINT_LABEL =
+            "/theme/field[@name='showpointlabel']/@default";
+
     public final static String XPATH_LINE_LABEL_FONT =
         "/theme/field[@name='linelabelfont']/@default";
 
@@ -322,6 +325,11 @@
         return parseBoolean(show, false);
     }
 
+    public static boolean parseShowPointLabel(Document theme) {
+        String show = XMLUtils.xpathString(theme, XPATH_SHOW_POINT_LABEL, null);
+        return parseBoolean(show, false);
+    }
+
     /**
      * Parses text color.
      * @param theme The theme.

http://dive4elements.wald.intevation.org