comparison 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
comparison
equal deleted inserted replaced
2257:86685feb5b1c 2258:ea173e4c07c7
1 package de.intevation.flys.utils; 1 package de.intevation.flys.utils;
2 2
3 import java.text.DateFormat;
3 import java.text.NumberFormat; 4 import java.text.NumberFormat;
4 import java.util.Locale; 5 import java.util.Locale;
5 6
6 import de.intevation.artifacts.CallContext; 7 import de.intevation.artifacts.CallContext;
7 8
24 public static final int COMPUTED_DISCHARGE_W_MAX_DIGITS = 2; 25 public static final int COMPUTED_DISCHARGE_W_MAX_DIGITS = 2;
25 public static final int COMPUTED_DISCHARGE_Q_MIN_DIGITS = 0; 26 public static final int COMPUTED_DISCHARGE_Q_MIN_DIGITS = 0;
26 public static final int COMPUTED_DISCHARGE_Q_MAX_DIGITS = 2; 27 public static final int COMPUTED_DISCHARGE_Q_MAX_DIGITS = 2;
27 28
28 29
30 // HISTORICAL DISCHARGE CURVE FORMATTER CONSTANTS
31 public static final int HISTORICAL_DISCHARGE_W_MIN_DIGITS = 0;
32 public static final int HISTORICAL_DISCHARGE_W_MAX_DIGITS = 2;
33 public static final int HISTORICAL_DISCHARGE_Q_MIN_DIGITS = 0;
34 public static final int HISTORICAL_DISCHARGE_Q_MAX_DIGITS = 2;
35
36
29 // DURATION CURVE FORMATTER CONSTANTS 37 // DURATION CURVE FORMATTER CONSTANTS
30 public static final int DURATION_W_MIN_DIGITS = 0; 38 public static final int DURATION_W_MIN_DIGITS = 0;
31 public static final int DURATION_W_MAX_DIGITS = 2; 39 public static final int DURATION_W_MAX_DIGITS = 2;
32 public static final int DURATION_Q_MIN_DIGITS = 0; 40 public static final int DURATION_Q_MIN_DIGITS = 0;
33 public static final int DURATION_Q_MAX_DIGITS = 1; 41 public static final int DURATION_Q_MAX_DIGITS = 1;
58 return NumberFormat.getInstance(locale); 66 return NumberFormat.getInstance(locale);
59 } 67 }
60 68
61 69
62 /** 70 /**
71 * Returns a date formatter with SHORT style.
72 */
73 public static DateFormat getShortDateFormat(CallContext cc) {
74 Locale locale = Resources.getLocale(cc.getMeta());
75 return DateFormat.getDateInstance(DateFormat.SHORT, locale);
76 }
77
78
79 /**
63 * Returns the number formatter for kilometer values in waterlevel exports. 80 * Returns the number formatter for kilometer values in waterlevel exports.
64 * 81 *
65 * @return the number formatter for kilometer values. 82 * @return the number formatter for kilometer values.
66 */ 83 */
67 public static NumberFormat getWaterlevelKM(CallContext context) { 84 public static NumberFormat getWaterlevelKM(CallContext context) {
125 COMPUTED_DISCHARGE_Q_MAX_DIGITS); 142 COMPUTED_DISCHARGE_Q_MAX_DIGITS);
126 } 143 }
127 144
128 145
129 /** 146 /**
147 * Returns the number formatter for W values in exports of historical
148 * discharge curves.
149 *
150 * @return the number formatter for W values.
151 */
152 public static NumberFormat getHistoricalDischargeW(CallContext context) {
153 return getFormatter(
154 context,
155 HISTORICAL_DISCHARGE_W_MIN_DIGITS,
156 HISTORICAL_DISCHARGE_W_MAX_DIGITS);
157 }
158
159
160 /**
161 * Returns the number formatter for Q values in exports of historical
162 * discharge curves.
163 *
164 * @return the number formatter for Q values.
165 */
166 public static NumberFormat getHistoricalDischargeQ(CallContext context) {
167 return getFormatter(
168 context,
169 HISTORICAL_DISCHARGE_Q_MIN_DIGITS,
170 HISTORICAL_DISCHARGE_Q_MAX_DIGITS);
171 }
172
173
174 /**
130 * Returns the number formatter for W values in duration curve exports. 175 * Returns the number formatter for W values in duration curve exports.
131 * 176 *
132 * @return the number formatter for W values. 177 * @return the number formatter for W values.
133 */ 178 */
134 public static NumberFormat getDurationW(CallContext context) { 179 public static NumberFormat getDurationW(CallContext context) {

http://dive4elements.wald.intevation.org