diff flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java @ 1125:65d8b3340397

Cleanups of CrossSection*. flys-artifacts/trunk@2635 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 01 Sep 2011 13:00:36 +0000
parents 111794adf285
children bcba246d9c03
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu Sep 01 12:47:01 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu Sep 01 13:00:36 2011 +0000
@@ -45,12 +45,9 @@
     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;
+    public static final String I18N_CHART_TITLE_DEFAULT = "Querprofildiagramm";
+    public static final String I18N_XAXIS_LABEL_DEFAULT = "Abstand [m]";
+    public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]";
 
 
     /** Trivial Constructor. */
@@ -59,21 +56,21 @@
     }
 
 
+    /**
+     * Get localized chart title.
+     */
     protected String getChartTitle() {
+        // TODO get river etc for localized heading
         return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
     }
 
-    public boolean isInverted() {
-        return inverted;
-    }
 
-    public void setInverted(boolean inverted) {
-        this.inverted = inverted;
-    }
-
+    /**
+     * Add localized subtitle to chart.
+     */
     @Override
     protected void addSubtitles(JFreeChart chart) {
-        double[] dist  = getRange();
+        double[] dist = getRange();
 
         Object[] args = new Object[] {
             getRiverName(),
@@ -81,25 +78,22 @@
             dist[1]
         };
 
-        //String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
-        String subtitle = "bogus";
+        String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
         chart.addSubtitle(new TextTitle(subtitle));
     }
 
-    @Override
-    public JFreeChart generateChart() {
-        JFreeChart c = super.generateChart();
-        XYPlot p = (XYPlot) c.getPlot();
 
-        return c;
-    }
-
-
+    /**
+     * Get localized X Axis label.
+     */
     protected String getXAxisLabel() {
         return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
     }
 
 
+    /**
+     * Get localized Y Axis label.
+     */
     protected String getYAxisLabel() {
         return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
     }
@@ -112,14 +106,11 @@
             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.
+     * Overrides XYChartGenerators.zoomY() to include the 0 value on the Q axis.
      */
     @Override
     protected boolean zoomY(XYPlot plot, ValueAxis axis, Range range, Range x) {
@@ -133,22 +124,6 @@
 
 
     /**
-     * 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);
-        }
-    }
-
-
-    /**
      * Let one facet do its job.
      */
     public void doOut(Artifact artifact, Facet facet, Document attr) {
@@ -188,7 +163,8 @@
      */
     protected void doCrossSectionWaterLineOut(Object o, Document theme) {
         logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut");
-        XYSeries series = new StyledXYSeries("water", theme);
+        // TODO Series should get name like "Q=22.0"
+        XYSeries series = new StyledXYSeries("Q= ... ", theme);
 
         double[][] a = (double [][]) o;
         double [] pxs = a[0];
@@ -207,6 +183,9 @@
     protected void doCrossSectionOut(Object o, Document theme) {
         logger.debug("CrossSectionGenerator.doCrossSectionOut");
 
+        // TODO Series should get name of selected cross-section (e.g. 
+        // "0-93.1(1990-2002).PRF") (exposed as getCrossSectionName in
+        //  WINFOArtifact)
         XYSeries series = new StyledXYSeries("aliquide", theme);
 
         double[][] a = (double [][]) o;
@@ -216,20 +195,5 @@
         }
         addFirstAxisSeries(series);
     }
-
-
-    /**
-     * 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 :
-

http://dive4elements.wald.intevation.org