Mercurial > dive4elements > river
changeset 2284:5d1ba04d2f68
Refactored Formatter access to ease reuse.
flys-artifacts/trunk@3946 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 07 Feb 2012 09:54:29 +0000 |
parents | d4330439be3a |
children | 5a00269406f3 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java |
diffstat | 4 files changed, 48 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Feb 07 09:52:55 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Feb 07 09:54:29 2012 +0000 @@ -1,3 +1,10 @@ +2012-02-07 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/exports/DurationCurveExporter.java, + src/main/java/de/intevation/flys/exports/WaterlevelExporter.java, + src/main/java/de/intevation/flys/exports/AbstractExporter.java: + Recactored, moved Formatter accessors to base class AbstractExporter. + 2012-02-07 Felix Wolfsteller <felix.wolfsteller@intevation.de> Let reference curve calculation result in specific WWQQ, extended CSV
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java Tue Feb 07 09:52:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java Tue Feb 07 09:54:29 2012 +0000 @@ -4,6 +4,8 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.text.NumberFormat; + import org.w3c.dom.Document; import org.apache.log4j.Logger; @@ -21,6 +23,8 @@ import de.intevation.flys.artifacts.resources.Resources; +import de.intevation.flys.utils.Formatter; + /** * An abstract exporter that implements some basic methods for exporting data of @@ -168,7 +172,7 @@ * @return true, if <i>facet</i> is valid, otherwise false. */ protected boolean isFacetValid(String facet) { - logger.debug("AbstractExporter.isFacetValid"); + logger.debug("AbstractExporter.isFacetValid : " + facet + " (" + getFacet() + ")" ); String thisFacet = getFacet(); @@ -263,5 +267,35 @@ public void setSettings(Settings settings) { // do nothing } + + + /** + * Returns the number formatter for kilometer values. + * + * @return the number formatter for kilometer values. + */ + protected NumberFormat getKmFormatter() { + return Formatter.getWaterlevelKM(context); + } + + + /** + * Returns the number formatter for W values. + * + * @return the number formatter for W values. + */ + protected NumberFormat getWFormatter() { + return Formatter.getWaterlevelW(context); + } + + + /** + * Returns the number formatter for Q values. + * + * @return the number formatter for Q values. + */ + protected NumberFormat getQFormatter() { + return Formatter.getWaterlevelQ(context); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java Tue Feb 07 09:52:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java Tue Feb 07 09:54:29 2012 +0000 @@ -16,6 +16,7 @@ import au.com.bytecode.opencsv.CSVWriter; +import java.text.NumberFormat; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; @@ -142,6 +143,7 @@ * * @return the number formatter for W values. */ + @Override protected NumberFormat getWFormatter() { return Formatter.getDurationW(context); } @@ -152,6 +154,7 @@ * * @return the number formatter for Q values. */ + @Override protected NumberFormat getQFormatter() { return Formatter.getDurationQ(context); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Tue Feb 07 09:52:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Tue Feb 07 09:54:29 2012 +0000 @@ -13,6 +13,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.text.NumberFormat; + import org.w3c.dom.Document; import org.apache.log4j.Logger; @@ -51,10 +53,8 @@ /** The logger used in this exporter.*/ private static Logger logger = Logger.getLogger(WaterlevelExporter.class); - public static final String FACET_WST = "wst"; - public static final String CSV_KM_HEADER = "export.waterlevel.csv.header.km"; @@ -118,7 +118,7 @@ "außerhalb des gewählten Bezugspegels"; public static final String PDF_HEADER_MODE = "export.waterlevel.pdf.mode"; - public static final String JASPER_FILE = "export.waterlevel.pdf.file"; + public static final String JASPER_FILE = "export.waterlevel.pdf.file"; /** The storage that contains all WQKms objects for the different facets.*/ protected List<WQKms[]> data; @@ -557,36 +557,6 @@ /** - * Returns the number formatter for kilometer values. - * - * @return the number formatter for kilometer values. - */ - protected NumberFormat getKmFormatter() { - return Formatter.getWaterlevelKM(context); - } - - - /** - * Returns the number formatter for W values. - * - * @return the number formatter for W values. - */ - protected NumberFormat getWFormatter() { - return Formatter.getWaterlevelW(context); - } - - - /** - * Returns the number formatter for Q values. - * - * @return the number formatter for Q values. - */ - protected NumberFormat getQFormatter() { - return Formatter.getWaterlevelQ(context); - } - - - /** * */ @Override