diff flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java @ 3771:04309ca24614

Locales fix flys-artifacts/trunk@5476 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Sat, 15 Sep 2012 13:42:44 +0000
parents 1d2856de489d
children 2d2ca7bf70a7
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Sat Sep 15 07:07:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Sat Sep 15 13:42:44 2012 +0000
@@ -1,20 +1,5 @@
 package de.intevation.flys.exports;
 
-import de.intevation.artifactdatabase.state.ArtifactAndFacet;
-import de.intevation.artifacts.DataProvider;
-import de.intevation.flys.artifacts.geom.Lines;
-import de.intevation.flys.artifacts.model.CrossSectionFacet;
-import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.HYKFactory;
-import de.intevation.flys.jfree.FLYSAnnotation;
-import de.intevation.flys.jfree.StyledXYSeries;
-import de.intevation.flys.model.FastCrossSectionLine;
-import de.intevation.flys.themes.LineStyle;
-import de.intevation.flys.themes.TextStyle;
-import de.intevation.flys.themes.ThemeAccess;
-import de.intevation.flys.utils.Formatter;
-import de.intevation.flys.utils.ThemeUtil;
-
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Paint;
@@ -30,6 +15,22 @@
 import org.jfree.data.xy.XYSeries;
 import org.w3c.dom.Document;
 
+import de.intevation.artifactdatabase.state.ArtifactAndFacet;
+import de.intevation.artifacts.DataProvider;
+import de.intevation.flys.artifacts.geom.Lines;
+import de.intevation.flys.artifacts.model.CrossSectionFacet;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.HYKFactory;
+import de.intevation.flys.artifacts.resources.Resources;
+import de.intevation.flys.jfree.FLYSAnnotation;
+import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.model.FastCrossSectionLine;
+import de.intevation.flys.themes.LineStyle;
+import de.intevation.flys.themes.TextStyle;
+import de.intevation.flys.themes.ThemeAccess;
+import de.intevation.flys.utils.Formatter;
+import de.intevation.flys.utils.ThemeUtil;
+
 
 /**
  * An OutGenerator that generates cross section graphs.
@@ -40,19 +41,19 @@
 {
     /** The logger that is used in this generator. */
     private static Logger logger =
-        Logger.getLogger(CrossSectionGenerator.class);
+            Logger.getLogger(CrossSectionGenerator.class);
 
     public static final String I18N_CHART_TITLE =
-        "chart.cross_section.title";
+            "chart.cross_section.title";
 
     public static final String I18N_CHART_SUBTITLE =
-        "chart.cross_section.subtitle";
+            "chart.cross_section.subtitle";
 
     public static final String I18N_XAXIS_LABEL =
-        "chart.cross_section.xaxis.label";
+            "chart.cross_section.xaxis.label";
 
     public static final String I18N_YAXIS_LABEL =
-        "chart.cross_section.yaxis.label";
+            "chart.cross_section.yaxis.label";
 
     public static final String I18N_CHART_TITLE_DEFAULT = "Querprofildiagramm";
     public static final String I18N_XAXIS_LABEL_DEFAULT = "Abstand [m]";
@@ -88,7 +89,7 @@
     @Override
     public String getDefaultChartTitle() {
         Object[] i18n_msg_args = new Object[] {
-            getRiverName()
+                getRiverName()
         };
         return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, i18n_msg_args);
     }
@@ -110,20 +111,22 @@
     @Override
     protected String getDefaultChartSubtitle() {
         List<DataProvider> providers =
-            context.getDataProvider(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA);
+                context.getDataProvider(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA);
         double km = 0d;
         if (providers.size() > 0) {
             FastCrossSectionLine csl = (FastCrossSectionLine) providers.get(0).
-                provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA,
-                    null, context);
+                    provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA,
+                            null, context);
             km = csl == null ? -1 : csl.getKm();
         }
 
         Object[] args = new Object[] {
-            getRiverName(),
-            km
+                getRiverName(),
+                km
         };
 
+        logger.debug("Locale: " + Resources.getLocale(context.getMeta()));
+
         return msg(I18N_CHART_SUBTITLE, "", args);
     }
 
@@ -166,8 +169,8 @@
 
         // OPTMIMIZE: Pre-calculate positions
         ChartArea area = new ChartArea(
-            plot.getDomainAxis(0).getRange(),
-            plot.getRangeAxis().getRange());
+                plot.getDomainAxis(0).getRange(),
+                plot.getRangeAxis().getRange());
 
         for(FLYSAnnotation fa : this.annotations) {
 
@@ -203,13 +206,13 @@
                 fillPaint = colorForHYKZone(zone.getName());
 
                 XYBoxAnnotation boxA = new XYBoxAnnotation(zone.getFrom(), area.atGround(),
-                    zone.getTo(), area.ofGround(0.03f), basicStroke, tranPaint, fillPaint);
+                        zone.getTo(), area.ofGround(0.03f), basicStroke, tranPaint, fillPaint);
                 XYBoxAnnotation boxB = new XYBoxAnnotation(zone.getFrom(), area.atGround(),
-                    zone.getTo(), area.atTop(), basicStroke, fillPaint, tranPaint);
+                        zone.getTo(), area.atTop(), basicStroke, fillPaint, tranPaint);
 
                 XYTextAnnotation tex = new XYTextAnnotation(zone.getName(),
-                    zone.getFrom() + (zone.getTo() - zone.getFrom()) / 1.0d,
-                    area.ofGround(0.015f));
+                        zone.getFrom() + (zone.getTo() - zone.getFrom()) / 1.0d,
+                        area.ofGround(0.015f));
                 if (textStyle != null) {
                     textStyle.apply(tex);
                 }
@@ -238,10 +241,10 @@
      */
     @Override
     public void doOut(
-        ArtifactAndFacet artifactFacet,
-        Document         attr,
-        boolean          visible
-    ) {
+            ArtifactAndFacet artifactFacet,
+            Document         attr,
+            boolean          visible
+            ) {
         String name = artifactFacet.getFacetName();
 
         logger.debug("CrossSectionGenerator.doOut: " + name);
@@ -253,41 +256,41 @@
 
         if (name.equals(CROSS_SECTION)) {
             doCrossSectionOut(
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                attr,
-                visible);
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    attr,
+                    visible);
         }
         else if (name.equals(CROSS_SECTION_WATER_LINE)) {
             doCrossSectionWaterLineOut(
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                attr,
-                visible);
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    attr,
+                    visible);
         }
         else if (FacetTypes.IS.AREA(name)) {
             doArea(artifactFacet.getData(context),
-                artifactFacet,
-                attr,
-                visible);
+                    artifactFacet,
+                    attr,
+                    visible);
         }
         else if (name.equals(HYK)) {
             doHyk(artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                attr,
-                visible);
+                    artifactFacet.getFacetDescription(),
+                    attr,
+                    visible);
         }
         else if (FacetTypes.IS.MANUALLINE(name)) {
             doCrossSectionWaterLineOut(
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                attr,
-                visible);
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    attr,
+                    visible);
         }
         else if (FacetTypes.IS.MANUALPOINTS(name)) {
             doPoints(artifactFacet.getData(context),
-                artifactFacet,
-                attr, visible, YAXIS.W.idx);
+                    artifactFacet,
+                    attr, visible, YAXIS.W.idx);
         }
         else {
             logger.warn("CrossSection.doOut: Unknown facet name: " + name);
@@ -311,11 +314,11 @@
      * @param theme Theme for the data series.
      */
     protected void doCrossSectionWaterLineOut(
-        Object   o,
-        String   seriesName,
-        Document theme,
-        boolean  visible
-    ) {
+            Object   o,
+            String   seriesName,
+            Document theme,
+            boolean  visible
+            ) {
         logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut");
 
         Lines.LineData lines = (Lines.LineData) o;
@@ -329,7 +332,7 @@
             NumberFormat nf = Formatter.getMeterFormat(this.context);
             String labelAdd = "b=" + nf.format(lines.width) + "m";
             if (series.getLabel().length() == 0) {
-               series.setLabel(labelAdd);
+                series.setLabel(labelAdd);
             }
             else {
                 series.setLabel(series.getLabel() + ", " + labelAdd);
@@ -340,7 +343,7 @@
             NumberFormat nf = Formatter.getMeterFormat(this.context);
             String labelAdd = "W=" + nf.format(lines.points[1][0]) + "NN+m";
             if (series.getLabel().length() == 0) {
-               series.setLabel(labelAdd);
+                series.setLabel(labelAdd);
             }
             else {
                 series.setLabel(series.getLabel() + ", " + labelAdd);
@@ -349,9 +352,9 @@
         if (ThemeUtil.parseShowMiddleHeight(theme) && lines.width != 0) {
             NumberFormat nf = Formatter.getMeterFormat(this.context);
             String labelAdd = "T=" + nf.format(lines.area / lines.width) + "m";
-                // : " + lines.area + "/" + lines.width);
+            // : " + lines.area + "/" + lines.width);
             if (series.getLabel().length() == 0) {
-               series.setLabel(labelAdd);
+                series.setLabel(labelAdd);
             }
             else {
                 series.setLabel(series.getLabel() + ", " + labelAdd);
@@ -366,11 +369,11 @@
 
     /** Add HYK-Annotations (colorize and label some areas, draw lines. */
     protected void doHyk(
-        Object   o,
-        String   seriesName,
-        Document theme,
-        boolean  visible
-    ) {
+            Object   o,
+            String   seriesName,
+            Document theme,
+            boolean  visible
+            ) {
         logger.debug("CrossSectionGenerator.doHyk");
 
         List<HYKFactory.Zone> zones = (List<HYKFactory.Zone>) o;
@@ -394,11 +397,11 @@
      * @param theme Theme for the data series.
      */
     protected void doCrossSectionOut(
-        Object   o,
-        String   seriesName,
-        Document theme,
-        boolean  visible
-    ) {
+            Object   o,
+            String   seriesName,
+            Document theme,
+            boolean  visible
+            ) {
         logger.debug("CrossSectionGenerator.doCrossSectionOut");
 
         XYSeries series = new StyledXYSeries(seriesName, theme);

http://dive4elements.wald.intevation.org