diff flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java @ 2258:ea173e4c07c7

Added a CSV export for historical discharge curves. flys-artifacts/trunk@3913 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 06 Feb 2012 08:36:26 +0000
parents bda04ae1154f
children 6f4a1f513e89
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java	Mon Feb 06 07:39:59 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java	Mon Feb 06 08:36:26 2012 +0000
@@ -1,5 +1,6 @@
 package de.intevation.flys.utils;
 
+import java.text.DateFormat;
 import java.text.NumberFormat;
 import java.util.Locale;
 
@@ -26,6 +27,13 @@
     public static final int COMPUTED_DISCHARGE_Q_MAX_DIGITS  = 2;
 
 
+    // HISTORICAL DISCHARGE CURVE FORMATTER CONSTANTS
+    public static final int HISTORICAL_DISCHARGE_W_MIN_DIGITS = 0;
+    public static final int HISTORICAL_DISCHARGE_W_MAX_DIGITS = 2;
+    public static final int HISTORICAL_DISCHARGE_Q_MIN_DIGITS = 0;
+    public static final int HISTORICAL_DISCHARGE_Q_MAX_DIGITS = 2;
+
+
     // DURATION CURVE FORMATTER CONSTANTS
     public static final int DURATION_W_MIN_DIGITS = 0;
     public static final int DURATION_W_MAX_DIGITS = 2;
@@ -60,6 +68,15 @@
 
 
     /**
+     * Returns a date formatter with SHORT style.
+     */
+    public static DateFormat getShortDateFormat(CallContext cc) {
+        Locale locale = Resources.getLocale(cc.getMeta());
+        return DateFormat.getDateInstance(DateFormat.SHORT, locale);
+    }
+
+
+    /**
      * Returns the number formatter for kilometer values in waterlevel exports.
      *
      * @return the number formatter for kilometer values.
@@ -127,6 +144,34 @@
 
 
     /**
+     * Returns the number formatter for W values in exports of historical
+     * discharge curves.
+     *
+     * @return the number formatter for W values.
+     */
+    public static NumberFormat getHistoricalDischargeW(CallContext context) {
+        return getFormatter(
+            context,
+            HISTORICAL_DISCHARGE_W_MIN_DIGITS,
+            HISTORICAL_DISCHARGE_W_MAX_DIGITS);
+    }
+
+
+    /**
+     * Returns the number formatter for Q values in exports of historical
+     * discharge curves.
+     *
+     * @return the number formatter for Q values.
+     */
+    public static NumberFormat getHistoricalDischargeQ(CallContext context) {
+        return getFormatter(
+            context,
+            HISTORICAL_DISCHARGE_Q_MIN_DIGITS,
+            HISTORICAL_DISCHARGE_Q_MAX_DIGITS);
+    }
+
+
+    /**
      * Returns the number formatter for W values in duration curve exports.
      *
      * @return the number formatter for W values.

http://dive4elements.wald.intevation.org