changeset 1111:b96ce07ba56c

Added dummy sceleton for Cross Sections. flys-artifacts/trunk@2617 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 31 Aug 2011 10:24:49 +0000
parents 563e015f0f22
children aeae4d20f32f
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 10 files changed, 272 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Aug 31 10:24:49 2011 +0000
@@ -1,6 +1,31 @@
+2011-08-31  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Add sceleton for CrossSection outs.
+
+	* doc/conf/artifacts/winfo.xml:
+	  Added new output mode to respective state of winfo artifact configuration.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java
+	  Add new Dummy-Facet in state.
+
+	* doc/conf/conf.xml:
+	  Registered new OutputGenerator.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java:
+	  Added new CROSS_SECTION type.
+
+	* src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java:
+	  New, stubby skeleton for an CrossSectionGenerator.
+
+	* src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_de.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages.properties:
+	  Added cross_section translation, also cleanups (e.g. main values).
+
 2011-08-31  Ingo Weinzierl <ingo@intevation.de>
 
-	* src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java: Marked
+	* src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java: MarkedF
 	  required parameters with a comment.
 
 	* src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java:
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Aug 31 10:24:49 2011 +0000
@@ -198,6 +198,11 @@
                         <facet name="report" description="facet.waterlevel_export.report"/>
                     </facets>
                 </outputmode>
+                <outputmode name="cross_section" description="output.cross_section" mime-type="image/png" type="chart">
+                    <facets>
+                        <facet name="cross_section" description="facet.cross_section"/>
+                    </facets>
+                </outputmode>
             </outputmodes>
         </state>
 
--- a/flys-artifacts/doc/conf/conf.xml	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Wed Aug 31 10:24:49 2011 +0000
@@ -87,6 +87,7 @@
     <output-generators>
         <output-generator name="discharge_curve">de.intevation.flys.exports.DischargeCurveGenerator</output-generator>
         <output-generator name="discharge_curve_chartinfo">de.intevation.flys.exports.DischargeCurveInfoGenerator</output-generator>
+        <output-generator name="cross_section">de.intevation.flys.exports.CrossSectionGenerator</output-generator>
         <output-generator name="computed_discharge_curve">de.intevation.flys.exports.ComputedDischargeCurveGenerator</output-generator>
         <output-generator name="computed_discharge_curve_chartinfo">de.intevation.flys.exports.ComputedDischargeCurveInfoGenerator</output-generator>
         <output-generator name="longitudinal_section">de.intevation.flys.exports.LongitudinalSectionGenerator</output-generator>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Aug 31 10:24:49 2011 +0000
@@ -18,6 +18,8 @@
     String COMPUTED_DISCHARGE_MAINVALUES_Q = "computed_discharge_curve.mainvalues.q";
     String COMPUTED_DISCHARGE_MAINVALUES_W = "computed_discharge_curve.mainvalues.w";
 
+    String CROSS_SECTION = "cross_section";
+
     String DISCHARGE_CURVE = "discharge_curve.curve";
 
     String DURATION_W = "duration_curve.w";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Wed Aug 31 10:24:49 2011 +0000
@@ -17,13 +17,14 @@
 
 import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.artifactdatabase.state.DefaultFacet;
 
 
 public class WaterlevelState
 extends      DefaultState
 implements   FacetTypes
 {
-    /** The logger that is used in this state.*/
+    /** The logger that is used in this state. */
     private static Logger logger = Logger.getLogger(WaterlevelState.class);
 
 
@@ -94,6 +95,7 @@
             facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
         }
 
+        facets.add(new DefaultFacet(0, "cross_section", "facet.cross_section"));
         return res;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Wed Aug 31 10:24:49 2011 +0000
@@ -0,0 +1,215 @@
+package de.intevation.flys.exports;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.Range;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+import org.jfree.ui.TextAnchor;
+
+import org.w3c.dom.Document;
+
+import de.intevation.artifacts.Artifact;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WQKms;
+
+import de.intevation.flys.model.Annotation;
+import de.intevation.flys.jfree.StickyAxisAnnotation;
+
+
+/**
+ * An OutGenerator that generates cross section graphs.
+ */
+public class CrossSectionGenerator
+extends      XYChartGenerator
+implements   FacetTypes
+{
+    /** The logger that is used in this generator. */
+    private static Logger logger =
+        Logger.getLogger(CrossSectionGenerator.class);
+
+    public static final String I18N_CHART_TITLE =
+        "chart.cross_section.title";
+
+    public static final String I18N_CHART_SUBTITLE =
+        "chart.cross_section.subtitle";
+
+    public static final String I18N_XAXIS_LABEL =
+        "chart.cross_section.xaxis.label";
+
+    public static final String I18N_YAXIS_LABEL =
+        "chart.cross_section.yaxis.label";
+
+    public static final String I18N_CHART_TITLE_DEFAULT  = "Querschnittt";
+    public static final String I18N_XAXIS_LABEL_DEFAULT  = "m";
+    public static final String I18N_YAXIS_LABEL_DEFAULT  = "W [NN + m]";
+
+
+    protected boolean inverted;
+
+
+    /** Trivial Constructor. */
+    public CrossSectionGenerator() {
+        super();
+    }
+
+
+    protected String getChartTitle() {
+        return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
+    }
+
+    public boolean isInverted() {
+        return inverted;
+    }
+
+    public void setInverted(boolean inverted) {
+        this.inverted = inverted;
+    }
+
+    @Override
+    protected void addSubtitles(JFreeChart chart) {
+        double[] dist  = getRange();
+
+        Object[] args = new Object[] {
+            getRiverName(),
+            dist[0],
+            dist[1]
+        };
+
+        //String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
+        String subtitle = "bogus";
+        chart.addSubtitle(new TextTitle(subtitle));
+    }
+
+    @Override
+    public JFreeChart generateChart() {
+        JFreeChart c = super.generateChart();
+        XYPlot p = (XYPlot) c.getPlot();
+
+        return c;
+    }
+
+
+    protected String getXAxisLabel() {
+        return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
+    }
+
+
+    protected String getYAxisLabel() {
+        return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
+    }
+
+
+    protected void adjustAxes(XYPlot plot) {
+        super.adjustAxes(plot);
+
+        NumberAxis qAxis = new NumberAxis(
+            msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT));
+
+        plot.setRangeAxis(1, qAxis);
+
+        invertXAxis(plot.getDomainAxis());
+    }
+
+
+    /**
+     * This method overrides the XYChartGenerators zoomY method to include the 0
+     * value on the Q axis.
+     */
+    @Override
+    protected boolean zoomY(XYPlot plot, ValueAxis axis, Range range, Range x) {
+        if (plot.getRangeAxisIndex(axis) == 1) {
+            // we want the Q axis to start at 0 if no zooming has been done
+            range = new Range(0d, range.getUpperBound());
+        }
+
+        return super.zoomY(plot, axis, range, x);
+    }
+
+
+    /**
+     * This method inverts the x-axis based on the kilometer information of the
+     * selected river. If the head of the river is at kilometer 0, the axis is
+     * not inverted, otherwise it is.
+     *
+     * @param xaxis The domain axis.
+     */
+    protected void invertXAxis(ValueAxis xaxis) {
+
+        if (inverted) {
+            logger.debug("Invert X-Axis.");
+            xaxis.setInverted(true);
+        }
+    }
+
+
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
+        String name = facet.getName();
+
+        logger.debug("CrossSectionGenerator.doOut: " + name);
+
+        if (name == null) {
+            logger.error("No facet name for doOut(). No output generated!");
+            return;
+        }
+
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
+
+        if (f == null) {
+            return;
+        }
+
+        if (name.equals(CROSS_SECTION)) {
+            doCrossSectionOut(f.getData(artifact, context), attr);
+        }
+        else {
+            logger.warn("CrossSection.doOut: Unknown facet name: " + name);
+            return;
+        }
+    }
+
+
+    /**
+     * Register annotations available for the diagram.
+     *
+     * @param o     list of annotations (data of facet).
+     * @param theme yet ignored.
+     */
+    protected void doCrossSectionOut(Object o, Document theme) {
+        logger.debug("LongitudinalSectionGenerator.doCrossSectionOut");
+
+        /*Object[] args = new Object[] {getRiverName()};
+        String label = msg(I18N_ANNOTATIONS_LABEL, "", args);
+        pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme));*/
+    }
+
+
+    /**
+     * Get name of series (displayed in legend).
+     * @return name of the series.
+     */
+    protected String getSeriesName(WQKms wqkms, String mode) {
+        String name   = wqkms.getName();
+        String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode;
+
+        return prefix != null && prefix.length() > 0
+            ? prefix + "(" + name +")"
+            : name;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+
--- a/flys-artifacts/src/main/resources/messages.properties	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Wed Aug 31 10:24:49 2011 +0000
@@ -17,10 +17,12 @@
 calc.duration.curve = Duration Curve
 calc.discharge.longitudinal.section = TODO (W bei...)
 
+cross_section = Cross Section
+
+
 scenario.current = Current
 scenario.potentiel = Potentiel
 scenario.scenario = Scenario
-
 floodplain.option = Use Floodplain?
 
 river = River
@@ -49,6 +51,8 @@
 chart.duration.curve.curve.w = Waterlevel duration curve for {0}
 chart.duration.curve.curve.q = Discharge duration curve for {0}
 facet.longitudinal_section.annotations = POIs
+facet.discharge_curves.mainvalues.q = Q (main values)
+facet.discharge_curves.mainvalues.w = W (main values)
 
 export.waterlevel.csv.header.km = River-Km
 export.waterlevel.csv.header.w = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_de.properties	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Wed Aug 31 10:24:49 2011 +0000
@@ -14,8 +14,10 @@
 calc.surface.curve = wasserstand/wasserspiegellage
 calc.flood.map = \u00dcberschwemmungsfl\u00e4che
 calc.discharge.curve = abflusskurve/abflusstafel
-calc.duration.curve = dauerlinie
-calc.discharge.longitudinal.section = w bei ungleichwertigem abflussl\u00e4ngsschnitt
+calc.duration.curve = Dauerlinie
+calc.discharge.longitudinal.section = w bei ungleichwertigem Abflussl\u00e4ngsschnitt
+
+cross_section = Querprofil
 
 scenario.current = Aktuell
 scenario.potentiel = Potentiell
@@ -23,9 +25,9 @@
 
 floodplain.option = Talaue verwenden?
 
-river = fluss
-calculation_mode = berechnungsart
-ld_locations = ort(e)
+river = Fluss
+calculation_mode = Berechnungsart
+ld_locations = Ort(e)
 
 chart.longitudinal.section.title = W-L\u00e4ngsschnitt
 chart.longitudinal.section.subtitle = Bereich: {0}-km {1,number,#.###} - {2,number,#.###}
@@ -50,6 +52,8 @@
 chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0}
 
 facet.longitudinal_section.annotations = streckenfavoriten
+facet.discharge_curves.mainvalues.q = Q (Haupt- und Extremwerte)
+facet.discharge_curves.mainvalues.w = W (Haupt- und Extremwerte)
 
 export.waterlevel.csv.header.km = Fluss-Km
 export.waterlevel.csv.header.w = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Aug 31 10:24:49 2011 +0000
@@ -17,6 +17,8 @@
 calc.duration.curve = Dauerlinie
 calc.discharge.longitudinal.section = W bei ungleichwertigem Abflussl\u00e4ngsschnitt
 
+cross_section = Querprofil
+
 scenario.current = Aktuell
 scenario.potentiel = Potentiell
 scenario.scenario = Szenario
@@ -49,6 +51,8 @@
 chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0}
 chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0}
 facet.longitudinal_section.annotations = Streckenfavoriten
+facet.discharge_curves.mainvalues.q = Q (Haupt- und Extremwerte)
+facet.discharge_curves.mainvalues.w = W (Haupt- und Extremwerte)
 
 export.waterlevel.csv.header.km = Fluss-Km
 export.waterlevel.csv.header.w = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_en.properties	Wed Aug 31 08:53:30 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Wed Aug 31 10:24:49 2011 +0000
@@ -17,6 +17,8 @@
 calc.duration.curve = Duration Curve
 calc.discharge.longitudinal.section = TODO (W bei...)
 
+cross_section = Cross Section
+
 scenario.current = Current
 scenario.potentiel = Potentiel
 scenario.scenario = Scenario

http://dive4elements.wald.intevation.org