Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java @ 4942:04c68af45534
Merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 31 Jan 2013 16:00:21 +0100 |
parents | 450840751f1b 65059ad920c6 |
children | 7669747d22f2 |
comparison
equal
deleted
inserted
replaced
4940:450840751f1b | 4942:04c68af45534 |
---|---|
32 | 32 |
33 public static final int COLUMNS = 10; | 33 public static final int COLUMNS = 10; |
34 | 34 |
35 public static final String I18N_AT_HEADER = | 35 public static final String I18N_AT_HEADER = |
36 "export.discharge.curve.at.header"; | 36 "export.discharge.curve.at.header"; |
37 | |
38 public static final String I18N_AT_GAUGE_HEADER = | |
39 "export.discharge.curve.at.gauge.header"; | |
37 | 40 |
38 public static final String EMPTY = " "; | 41 public static final String EMPTY = " "; |
39 | 42 |
40 protected double minW; | 43 protected double minW; |
41 protected double maxW; | 44 protected double maxW; |
107 } | 110 } |
108 out.printf(Locale.US, format, q); | 111 out.printf(Locale.US, format, q); |
109 } | 112 } |
110 | 113 |
111 | 114 |
112 protected static void printHeader( | 115 protected static void printGaugeHeader( |
113 PrintWriter out, | 116 PrintWriter out, |
114 CallMeta callMeta, | 117 CallMeta callMeta, |
115 String river, | 118 String river, |
116 double km, | 119 double km, |
117 String gName, | 120 String gName, |
119 Date date | 122 Date date |
120 ) { | 123 ) { |
121 DateFormat f = DateFormat.getDateInstance(); | 124 DateFormat f = DateFormat.getDateInstance(); |
122 out.print(Resources.getMsg( | 125 out.print(Resources.getMsg( |
123 callMeta, | 126 callMeta, |
127 I18N_AT_GAUGE_HEADER, | |
128 I18N_AT_GAUGE_HEADER, | |
129 new Object[] { river, gName, f.format(date), datum } )); | |
130 out.print("\r\n"); | |
131 } | |
132 | |
133 protected static void printHeader( | |
134 PrintWriter out, | |
135 CallMeta callMeta, | |
136 String river, | |
137 double km | |
138 ) { | |
139 DateFormat f = DateFormat.getDateInstance(); | |
140 out.print(Resources.getMsg( | |
141 callMeta, | |
124 I18N_AT_HEADER, | 142 I18N_AT_HEADER, |
125 I18N_AT_HEADER, | 143 I18N_AT_HEADER, |
126 new Object[] { river, gName, f.format(date), datum } )); | 144 new Object[] { river, km } )); |
127 out.print("\r\n"); | 145 out.print("\r\n"); |
128 } | 146 } |
129 | |
130 | 147 |
131 public void write( | 148 public void write( |
132 Writer writer, | 149 Writer writer, |
133 CallMeta meta, | 150 CallMeta meta, |
134 String river, | 151 String river, |
135 double km, | 152 double km, |
136 String gName, | 153 String gName, |
137 BigDecimal datum, | 154 BigDecimal datum, |
138 Date date) | 155 Date date, |
156 double scale) | |
139 throws IOException | 157 throws IOException |
140 { | 158 { |
141 PrintWriter out = new PrintWriter(writer); | 159 PrintWriter out = new PrintWriter(writer); |
142 | 160 |
143 // a header is required, because the desktop version of FLYS will skip | 161 // a header is required, because the desktop version of FLYS will skip |
144 // the first row. | 162 // the first row. |
145 printHeader(out, meta, river, km, gName, datum, date); | 163 if (gName != null) { |
164 printGaugeHeader(out, meta, river, km, gName, datum, date); | |
165 } | |
166 else { | |
167 printHeader(out, meta, river, km); | |
168 } | |
146 | 169 |
147 double rest = (minW * 100.0) % 10.0; | 170 double rest = (minW * 100.0) % 10.0; |
148 | 171 |
149 double startW = Math.rint((minW - rest*0.01)*10.0)*0.1; | 172 double startW = Math.rint((minW - rest*0.01)*10.0)*0.1; |
150 | 173 |
154 } | 177 } |
155 | 178 |
156 int col = 0; | 179 int col = 0; |
157 for (double w = startW; w <= maxW; w += 0.01) { | 180 for (double w = startW; w <= maxW; w += 0.01) { |
158 if (col == 0) { | 181 if (col == 0) { |
159 out.printf(Locale.US, "%8d", (int)Math.round(w)); | 182 out.printf(Locale.US, "%8d", (int)Math.round(w * scale)); |
160 } | 183 } |
161 | 184 |
162 if (w < minW) { | 185 if (w < minW) { |
163 out.print(EMPTY); | 186 out.print(EMPTY); |
164 } | 187 } |