# HG changeset patch # User Ingo Weinzierl # Date 1339755442 0 # Node ID 5c87d4ca1bd3d5b4b90fa3101b1e20bff7f64f1a # Parent 5642a83420f2f3a0b0d7472895185e53cec14971 Added chart and export generator stubs for SQ relation. flys-artifacts/trunk@4672 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Jun 15 09:30:07 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jun 15 10:17:22 2012 +0000 @@ -1,3 +1,23 @@ +2012-06-15 Ingo Weinzierl + + * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added + new functions to determine if a Facet is a SQ curve, measurement or + outlier independend of their parameter. + + * src/main/java/de/intevation/flys/exports/sq/SQRelationInfoGenerator.java, + src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java, + src/main/java/de/intevation/flys/exports/sq/SQRelationExporter.java: + Stubs for chart and export generators. + + * doc/conf/conf.xml: Registered new output-generators for SQ relation + charts and exports. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: Added i18n strings for CSV + export of SQ relations. + 2012-06-15 Sascha L. Teichmann * src/main/java/de/intevation/flys/**/*.java: Removed trailing whitespace. diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/doc/conf/conf.xml --- a/flys-artifacts/doc/conf/conf.xml Fri Jun 15 09:30:07 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Fri Jun 15 10:17:22 2012 +0000 @@ -242,6 +242,19 @@ de.intevation.flys.exports.MiddleBedHeightGenerator de.intevation.flys.exports.MiddleBedHeightInfoGenerator de.intevation.flys.exports.MiddleBedHeightExporter + de.intevation.flys.exports.sq.SQRelationGenerator + de.intevation.flys.exports.sq.SQRelationGenerator + de.intevation.flys.exports.sq.SQRelationGenerator + de.intevation.flys.exports.sq.SQRelationGenerator + de.intevation.flys.exports.sq.SQRelationGenerator + de.intevation.flys.exports.sq.SQRelationGenerator + de.intevation.flys.exports.sq.SQRelationInfoGenerator + de.intevation.flys.exports.sq.SQRelationInfoGenerator + de.intevation.flys.exports.sq.SQRelationInfoGenerator + de.intevation.flys.exports.sq.SQRelationInfoGenerator + de.intevation.flys.exports.sq.SQRelationInfoGenerator + de.intevation.flys.exports.sq.SQRelationInfoGenerator + de.intevation.flys.exports.SQRelationExporter de.intevation.flys.exports.DeltaWtExporter de.intevation.flys.exports.ReportGenerator diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Fri Jun 15 09:30:07 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Fri Jun 15 10:17:22 2012 +0000 @@ -45,6 +45,45 @@ public static boolean MANUALPOINTS(String type) { return type.endsWith("manualpoints"); } + public static boolean SQ_CURVE(String type) { + if (type.equals(SQ_A_CURVE) + || type.equals(SQ_B_CURVE) + || type.equals(SQ_C_CURVE) + || type.equals(SQ_D_CURVE) + || type.equals(SQ_E_CURVE) + || type.equals(SQ_F_CURVE)) + { + return true; + } + + return false; + } + public static boolean SQ_MEASUREMENT(String type) { + if (type.equals(SQ_A_MEASUREMENT) + || type.equals(SQ_B_MEASUREMENT) + || type.equals(SQ_C_MEASUREMENT) + || type.equals(SQ_D_MEASUREMENT) + || type.equals(SQ_E_MEASUREMENT) + || type.equals(SQ_F_MEASUREMENT)) + { + return true; + } + + return false; + } + public static boolean SQ_OUTLIER(String type) { + if (type.equals(SQ_A_OUTLIER) + || type.equals(SQ_B_OUTLIER) + || type.equals(SQ_C_OUTLIER) + || type.equals(SQ_D_OUTLIER) + || type.equals(SQ_E_OUTLIER) + || type.equals(SQ_F_OUTLIER)) + { + return true; + } + + return false; + } }; public enum ChartType { diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationExporter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationExporter.java Fri Jun 15 10:17:22 2012 +0000 @@ -0,0 +1,141 @@ +package de.intevation.flys.exports; + +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +import org.w3c.dom.Document; + +import org.apache.log4j.Logger; + +import au.com.bytecode.opencsv.CSVWriter; + +import de.intevation.artifacts.CallContext; + +import de.intevation.flys.artifacts.model.CalculationResult; + + +/** + * @author Ingo Weinzierl + */ +public class SQRelationExporter extends AbstractExporter { + + /** Private logger. */ + private static final Logger logger = + Logger.getLogger(SQRelationExporter.class); + + + public static final String CSV_PARAMETER = + "export.sqrelation.csv.header.parameter"; + + public static final String CSV_STATION = + "export.sqrelation.csv.header.station"; + + public static final String CSV_KM = + "export.sqrelation.csv.header.km"; + + public static final String CSV_FUNCTION = + "export.sqrelation.csv.header.function"; + + public static final String CSV_GAUGE = + "export.sqrelation.csv.header.gauge"; + + public static final String CSV_COEFF_A = + "export.sqrelation.csv.header.coeff.a"; + + public static final String CSV_COEFF_B = + "export.sqrelation.csv.header.coeff.b"; + + public static final String CSV_COEFF_Q = + "export.sqrelation.csv.header.coeff.q"; + + public static final String CSV_COEFF_R = + "export.sqrelation.csv.header.coeff.r"; + + public static final String CSV_N_TOTAL = + "export.sqrelation.csv.header.n.total"; + + public static final String CSV_N_OUTLIERS = + "export.sqrelation.csv.header.n.outliers"; + + public static final String CSV_C_DUAN = + "export.sqrelation.csv.header.c.duan"; + + public static final String CSV_C_FERGUSON = + "export.sqrelation.csv.header.c.ferguson"; + + public static final String CSV_VARIANCE = + "export.sqrelation.csv.header.variance"; + + + // TODO use correct model class here! + protected List data; + + + public void init(Document request, OutputStream out, CallContext cc) { + super.init(request, out, cc); + data = new ArrayList(); + } + + + @Override + protected void addData(Object d) { + if (d instanceof CalculationResult) { + d = ((CalculationResult) d).getData(); + + if (d instanceof Object[]) { + logger.debug("Add new data of type XXX"); + data.add((Object[]) d); + } + } + } + + + @Override + protected void writeCSVData(CSVWriter writer) { + logger.debug("writeCSVData"); + logger.error("NOT IMPLEMENTED: writeCSVData"); + + logger.debug("CSV gets " + data.size() + " rows."); + + writeCSVHeader(writer); + + for (Object[] d: data) { + data2CSV(writer, d); + } + } + + + protected void writeCSVHeader(CSVWriter writer) { + writer.writeNext(new String[] { + msg(CSV_PARAMETER, CSV_PARAMETER), + msg(CSV_STATION, CSV_STATION), + msg(CSV_KM , CSV_KM), + msg(CSV_FUNCTION , CSV_FUNCTION), + msg(CSV_GAUGE , CSV_GAUGE), + msg(CSV_COEFF_A , CSV_COEFF_A), + msg(CSV_COEFF_B , CSV_COEFF_B), + msg(CSV_COEFF_Q , CSV_COEFF_Q), + msg(CSV_COEFF_R , CSV_COEFF_R), + msg(CSV_N_TOTAL , CSV_N_TOTAL), + msg(CSV_N_OUTLIERS, CSV_N_OUTLIERS), + msg(CSV_C_DUAN , CSV_C_DUAN), + msg(CSV_C_FERGUSON, CSV_C_FERGUSON), + msg(CSV_VARIANCE , CSV_VARIANCE) + }); + } + + + protected void data2CSV(CSVWriter writer, Object[] mData) { + logger.debug("data2CSV"); + logger.error("NOT IMPLEMENTED: data2CSV"); + } + + + @Override + protected void writePDF(OutputStream out) { + logger.debug("writePDF"); + logger.error("NOT IMPLEMENTED: writePDF"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java Fri Jun 15 10:17:22 2012 +0000 @@ -0,0 +1,135 @@ +package de.intevation.flys.exports.sq; + +import org.apache.log4j.Logger; + +import org.jfree.chart.axis.LogarithmicAxis; +import org.jfree.chart.axis.NumberAxis; + +import org.w3c.dom.Document; + +import de.intevation.artifactdatabase.state.ArtifactAndFacet; +import de.intevation.artifactdatabase.state.Facet; + +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.exports.XYChartGenerator; + +/** + * An OutGenerator that generates charts for MINFO sq relation. + * + * @author Ingo Weinzierl + */ +public class SQRelationGenerator +extends XYChartGenerator +implements FacetTypes +{ + public enum YAXIS { + S(0); + protected int idx; + private YAXIS(int c) { + idx = c; + } + } + + /** The logger that is used in this generator. */ + private static Logger logger = Logger.getLogger(SQRelationGenerator.class); + + + @Override + protected YAxisWalker getYAxisWalker() { + return new YAxisWalker() { + @Override + public int length() { + return YAXIS.values().length; + } + + @Override + public String getId(int idx) { + YAXIS[] yaxes = YAXIS.values(); + return yaxes[idx].toString(); + } + }; + } + + + @Override + public String getDefaultChartTitle() { + return "TODO: CHART TITLE"; + } + + + @Override + protected String getDefaultXAxisLabel() { + return "TODO: XAXIS LABEL"; + } + + + @Override + protected String getDefaultYAxisLabel(int index) { + return "TODO: YAXIS LABEL " + index; + } + + + @Override + protected NumberAxis createYAxis(int index) { + return new LogarithmicAxis("TODO: LABEL " + index); + } + + + @Override + public void doOut( + ArtifactAndFacet artifactAndFacet, + Document attr, + boolean visible + ) { + logger.debug("doOut"); + + Facet facet = artifactAndFacet.getFacet(); + String name = facet != null ? facet.getName() : null; + + if (name == null || name.length() == 0) { + logger.warn("Invalid facet with no name given!"); + return; + } + + if (IS.SQ_CURVE(name)) { + doSQCurveOut(artifactAndFacet, attr, visible); + } + else if (IS.SQ_MEASUREMENT(name)) { + doSQMeasurementsOut(artifactAndFacet, attr, visible); + } + else if (IS.SQ_OUTLIER(name)) { + doSQOutliersOut(artifactAndFacet, attr, visible); + } + } + + + protected void doSQCurveOut( + ArtifactAndFacet artifactAndFacet, + Document attr, + boolean visible + ) { + logger.debug("doSQCurveOut"); + logger.error("NOT IMPLEMENTED: doSQCurveOut"); + } + + + protected void doSQMeasurementsOut( + ArtifactAndFacet artifactAndFacet, + Document attr, + boolean visible + ) { + logger.debug("doSQMeasurementsOut"); + logger.error("NOT IMPLEMENTED: doSQMeasurementsOut"); + } + + + protected void doSQOutliersOut( + ArtifactAndFacet artifactAndFacet, + Document attr, + boolean visible + ) { + logger.debug("doSQOutliersOut"); + logger.error("NOT IMPLEMENTED: doSQOutliersOut"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationInfoGenerator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationInfoGenerator.java Fri Jun 15 10:17:22 2012 +0000 @@ -0,0 +1,19 @@ +package de.intevation.flys.exports.sq; + +import de.intevation.flys.exports.ChartInfoGenerator; + + +/** + * A ChartInfoGenerator that generates meta information for specific + * sq relation charts. + * + * @author Ingo Weinzierl + */ +public class SQRelationInfoGenerator +extends ChartInfoGenerator +{ + public SQRelationInfoGenerator() { + super(new SQRelationGenerator()); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Fri Jun 15 09:30:07 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri Jun 15 10:17:22 2012 +0000 @@ -212,6 +212,20 @@ export.bedheight_middle.csv.header.soundingwidth = Sounding Width [m] export.bedheight_middle.csv.header.width = morphological active width [m] export.bedheight_middle.csv.header.locations = Location +export.sqrelation.csv.header.parameter = Parameter +export.sqrelation.csv.header.station = Station +export.sqrelation.csv.header.km = River-Km +export.sqrelation.csv.header.function = Function +export.sqrelation.csv.header.gauge = Gauge +export.sqrelation.csv.header.coeff.a = a +export.sqrelation.csv.header.coeff.b = b +export.sqrelation.csv.header.coeff.q = Q +export.sqrelation.csv.header.coeff.r = r^2 +export.sqrelation.csv.header.n.total = n total +export.sqrelation.csv.header.n.outliers = n outliers +export.sqrelation.csv.header.c.duan = C (DUAN) +export.sqrelation.csv.header.c.ferguson = C (FERGUSON) +export.sqrelation.csv.header.variance = Standard variance floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Fri Jun 15 09:30:07 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri Jun 15 10:17:22 2012 +0000 @@ -212,6 +212,20 @@ export.bedheight_middle.csv.header.soundingwidth = Peilbreite [m] export.bedheight_middle.csv.header.width = morphologisch aktive Breite [m] export.bedheight_middle.csv.header.locations = Streckendaten +export.sqrelation.csv.header.parameter = Parameter +export.sqrelation.csv.header.station = Station +export.sqrelation.csv.header.km = Fluss-Km +export.sqrelation.csv.header.function = Funktion +export.sqrelation.csv.header.gauge = Pegel +export.sqrelation.csv.header.coeff.a = a +export.sqrelation.csv.header.coeff.b = b +export.sqrelation.csv.header.coeff.q = Q +export.sqrelation.csv.header.coeff.r = r^2 +export.sqrelation.csv.header.n.total = n gesamt +export.sqrelation.csv.header.n.outliers = n Ausrei\u00dfer +export.sqrelation.csv.header.c.duan = C (DUAN) +export.sqrelation.csv.header.c.ferguson = C (FERGUSON) +export.sqrelation.csv.header.variance = Standardabweichung floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Jun 15 09:30:07 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Jun 15 10:17:22 2012 +0000 @@ -209,6 +209,20 @@ export.bedheight_middle.csv.header.soundingwidth = Peilbreite [m] export.bedheight_middle.csv.header.width = morphologisch aktive Breite [m] export.bedheight_middle.csv.header.locations = Streckendaten +export.sqrelation.csv.header.parameter = Parameter +export.sqrelation.csv.header.station = Station +export.sqrelation.csv.header.km = Fluss-Km +export.sqrelation.csv.header.function = Funktion +export.sqrelation.csv.header.gauge = Pegel +export.sqrelation.csv.header.coeff.a = a +export.sqrelation.csv.header.coeff.b = b +export.sqrelation.csv.header.coeff.q = Q +export.sqrelation.csv.header.coeff.r = r^2 +export.sqrelation.csv.header.n.total = n gesamt +export.sqrelation.csv.header.n.outliers = n Ausrei\u00dfer +export.sqrelation.csv.header.c.duan = C (DUAN) +export.sqrelation.csv.header.c.ferguson = C (FERGUSON) +export.sqrelation.csv.header.variance = Standardabweichung floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse diff -r 5642a83420f2 -r 5c87d4ca1bd3 flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Fri Jun 15 09:30:07 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri Jun 15 10:17:22 2012 +0000 @@ -211,6 +211,20 @@ export.bedheight_middle.csv.header.soundingwidth = Sounding Width [m] export.bedheight_middle.csv.header.width = morphological active width [m] export.bedheight_middle.csv.header.locations = Location +export.sqrelation.csv.header.parameter = Parameter +export.sqrelation.csv.header.station = Station +export.sqrelation.csv.header.km = River-Km +export.sqrelation.csv.header.function = Function +export.sqrelation.csv.header.gauge = Gauge +export.sqrelation.csv.header.coeff.a = a +export.sqrelation.csv.header.coeff.b = b +export.sqrelation.csv.header.coeff.q = Q +export.sqrelation.csv.header.coeff.r = r^2 +export.sqrelation.csv.header.n.total = n total +export.sqrelation.csv.header.n.outliers = n outliers +export.sqrelation.csv.header.c.duan = C (DUAN) +export.sqrelation.csv.header.c.ferguson = C (FERGUSON) +export.sqrelation.csv.header.variance = Standard variance floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis