# HG changeset patch # User Felix Wolfsteller # Date 1314786289 0 # Node ID b96ce07ba56c8e4ee733f7cfa28256c19de7df36 # Parent 563e015f0f228e2996794e36ccc4a6ba9b2b2ef1 Added dummy sceleton for Cross Sections. flys-artifacts/trunk@2617 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Aug 31 10:24:49 2011 +0000 @@ -1,6 +1,31 @@ +2011-08-31 Felix Wolfsteller + + Add sceleton for CrossSection outs. + + * doc/conf/artifacts/winfo.xml: + Added new output mode to respective state of winfo artifact configuration. + + * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java + Add new Dummy-Facet in state. + + * doc/conf/conf.xml: + Registered new OutputGenerator. + + * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: + Added new CROSS_SECTION type. + + * src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java: + New, stubby skeleton for an CrossSectionGenerator. + + * src/main/resources/messages_de_DE.properties, + src/main/resources/messages_de.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages.properties: + Added cross_section translation, also cleanups (e.g. main values). + 2011-08-31 Ingo Weinzierl - * src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java: Marked + * src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java: MarkedF required parameters with a comment. * src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java: diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/doc/conf/artifacts/winfo.xml --- a/flys-artifacts/doc/conf/artifacts/winfo.xml Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Wed Aug 31 10:24:49 2011 +0000 @@ -198,6 +198,11 @@ + + + + + diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/doc/conf/conf.xml --- a/flys-artifacts/doc/conf/conf.xml Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Wed Aug 31 10:24:49 2011 +0000 @@ -87,6 +87,7 @@ de.intevation.flys.exports.DischargeCurveGenerator de.intevation.flys.exports.DischargeCurveInfoGenerator + de.intevation.flys.exports.CrossSectionGenerator de.intevation.flys.exports.ComputedDischargeCurveGenerator de.intevation.flys.exports.ComputedDischargeCurveInfoGenerator de.intevation.flys.exports.LongitudinalSectionGenerator diff -r 563e015f0f22 -r b96ce07ba56c 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 Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Aug 31 10:24:49 2011 +0000 @@ -18,6 +18,8 @@ String COMPUTED_DISCHARGE_MAINVALUES_Q = "computed_discharge_curve.mainvalues.q"; String COMPUTED_DISCHARGE_MAINVALUES_W = "computed_discharge_curve.mainvalues.w"; + String CROSS_SECTION = "cross_section"; + String DISCHARGE_CURVE = "discharge_curve.curve"; String DURATION_W = "duration_curve.w"; diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Wed Aug 31 10:24:49 2011 +0000 @@ -17,13 +17,14 @@ import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.artifactdatabase.state.DefaultFacet; public class WaterlevelState extends DefaultState implements FacetTypes { - /** The logger that is used in this state.*/ + /** The logger that is used in this state. */ private static Logger logger = Logger.getLogger(WaterlevelState.class); @@ -94,6 +95,7 @@ facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); } + facets.add(new DefaultFacet(0, "cross_section", "facet.cross_section")); return res; } } diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java Wed Aug 31 10:24:49 2011 +0000 @@ -0,0 +1,215 @@ +package de.intevation.flys.exports; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.Range; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.ui.TextAnchor; + +import org.w3c.dom.Document; + +import de.intevation.artifacts.Artifact; + +import de.intevation.artifactdatabase.state.Facet; + +import de.intevation.flys.artifacts.FLYSArtifact; + +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.WQKms; + +import de.intevation.flys.model.Annotation; +import de.intevation.flys.jfree.StickyAxisAnnotation; + + +/** + * An OutGenerator that generates cross section graphs. + */ +public class CrossSectionGenerator +extends XYChartGenerator +implements FacetTypes +{ + /** The logger that is used in this generator. */ + private static Logger logger = + Logger.getLogger(CrossSectionGenerator.class); + + public static final String I18N_CHART_TITLE = + "chart.cross_section.title"; + + public static final String I18N_CHART_SUBTITLE = + "chart.cross_section.subtitle"; + + public static final String I18N_XAXIS_LABEL = + "chart.cross_section.xaxis.label"; + + public static final String I18N_YAXIS_LABEL = + "chart.cross_section.yaxis.label"; + + public static final String I18N_CHART_TITLE_DEFAULT = "Querschnittt"; + public static final String I18N_XAXIS_LABEL_DEFAULT = "m"; + public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; + + + protected boolean inverted; + + + /** Trivial Constructor. */ + public CrossSectionGenerator() { + super(); + } + + + protected String getChartTitle() { + return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); + } + + public boolean isInverted() { + return inverted; + } + + public void setInverted(boolean inverted) { + this.inverted = inverted; + } + + @Override + protected void addSubtitles(JFreeChart chart) { + double[] dist = getRange(); + + Object[] args = new Object[] { + getRiverName(), + dist[0], + dist[1] + }; + + //String subtitle = msg(I18N_CHART_SUBTITLE, "", args); + String subtitle = "bogus"; + chart.addSubtitle(new TextTitle(subtitle)); + } + + @Override + public JFreeChart generateChart() { + JFreeChart c = super.generateChart(); + XYPlot p = (XYPlot) c.getPlot(); + + return c; + } + + + protected String getXAxisLabel() { + return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); + } + + + protected String getYAxisLabel() { + return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); + } + + + protected void adjustAxes(XYPlot plot) { + super.adjustAxes(plot); + + NumberAxis qAxis = new NumberAxis( + msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT)); + + plot.setRangeAxis(1, qAxis); + + invertXAxis(plot.getDomainAxis()); + } + + + /** + * This method overrides the XYChartGenerators zoomY method to include the 0 + * value on the Q axis. + */ + @Override + protected boolean zoomY(XYPlot plot, ValueAxis axis, Range range, Range x) { + if (plot.getRangeAxisIndex(axis) == 1) { + // we want the Q axis to start at 0 if no zooming has been done + range = new Range(0d, range.getUpperBound()); + } + + return super.zoomY(plot, axis, range, x); + } + + + /** + * This method inverts the x-axis based on the kilometer information of the + * selected river. If the head of the river is at kilometer 0, the axis is + * not inverted, otherwise it is. + * + * @param xaxis The domain axis. + */ + protected void invertXAxis(ValueAxis xaxis) { + + if (inverted) { + logger.debug("Invert X-Axis."); + xaxis.setInverted(true); + } + } + + + public void doOut(Artifact artifact, Facet facet, Document attr) { + String name = facet.getName(); + + logger.debug("CrossSectionGenerator.doOut: " + name); + + if (name == null) { + logger.error("No facet name for doOut(). No output generated!"); + return; + } + + FLYSArtifact flys = (FLYSArtifact) artifact; + Facet f = flys.getNativeFacet(facet); + + if (f == null) { + return; + } + + if (name.equals(CROSS_SECTION)) { + doCrossSectionOut(f.getData(artifact, context), attr); + } + else { + logger.warn("CrossSection.doOut: Unknown facet name: " + name); + return; + } + } + + + /** + * Register annotations available for the diagram. + * + * @param o list of annotations (data of facet). + * @param theme yet ignored. + */ + protected void doCrossSectionOut(Object o, Document theme) { + logger.debug("LongitudinalSectionGenerator.doCrossSectionOut"); + + /*Object[] args = new Object[] {getRiverName()}; + String label = msg(I18N_ANNOTATIONS_LABEL, "", args); + pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme));*/ + } + + + /** + * Get name of series (displayed in legend). + * @return name of the series. + */ + protected String getSeriesName(WQKms wqkms, String mode) { + String name = wqkms.getName(); + String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode; + + return prefix != null && prefix.length() > 0 + ? prefix + "(" + name +")" + : name; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : + diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Wed Aug 31 10:24:49 2011 +0000 @@ -17,10 +17,12 @@ calc.duration.curve = Duration Curve calc.discharge.longitudinal.section = TODO (W bei...) +cross_section = Cross Section + + scenario.current = Current scenario.potentiel = Potentiel scenario.scenario = Scenario - floodplain.option = Use Floodplain? river = River @@ -49,6 +51,8 @@ chart.duration.curve.curve.w = Waterlevel duration curve for {0} chart.duration.curve.curve.q = Discharge duration curve for {0} facet.longitudinal_section.annotations = POIs +facet.discharge_curves.mainvalues.q = Q (main values) +facet.discharge_curves.mainvalues.w = W (main values) export.waterlevel.csv.header.km = River-Km export.waterlevel.csv.header.w = W [NN + m] diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Wed Aug 31 10:24:49 2011 +0000 @@ -14,8 +14,10 @@ calc.surface.curve = wasserstand/wasserspiegellage calc.flood.map = \u00dcberschwemmungsfl\u00e4che calc.discharge.curve = abflusskurve/abflusstafel -calc.duration.curve = dauerlinie -calc.discharge.longitudinal.section = w bei ungleichwertigem abflussl\u00e4ngsschnitt +calc.duration.curve = Dauerlinie +calc.discharge.longitudinal.section = w bei ungleichwertigem Abflussl\u00e4ngsschnitt + +cross_section = Querprofil scenario.current = Aktuell scenario.potentiel = Potentiell @@ -23,9 +25,9 @@ floodplain.option = Talaue verwenden? -river = fluss -calculation_mode = berechnungsart -ld_locations = ort(e) +river = Fluss +calculation_mode = Berechnungsart +ld_locations = Ort(e) chart.longitudinal.section.title = W-L\u00e4ngsschnitt chart.longitudinal.section.subtitle = Bereich: {0}-km {1,number,#.###} - {2,number,#.###} @@ -50,6 +52,8 @@ chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} facet.longitudinal_section.annotations = streckenfavoriten +facet.discharge_curves.mainvalues.q = Q (Haupt- und Extremwerte) +facet.discharge_curves.mainvalues.w = W (Haupt- und Extremwerte) export.waterlevel.csv.header.km = Fluss-Km export.waterlevel.csv.header.w = W [NN + m] diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Aug 31 10:24:49 2011 +0000 @@ -17,6 +17,8 @@ calc.duration.curve = Dauerlinie calc.discharge.longitudinal.section = W bei ungleichwertigem Abflussl\u00e4ngsschnitt +cross_section = Querprofil + scenario.current = Aktuell scenario.potentiel = Potentiell scenario.scenario = Szenario @@ -49,6 +51,8 @@ chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0} chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} facet.longitudinal_section.annotations = Streckenfavoriten +facet.discharge_curves.mainvalues.q = Q (Haupt- und Extremwerte) +facet.discharge_curves.mainvalues.w = W (Haupt- und Extremwerte) export.waterlevel.csv.header.km = Fluss-Km export.waterlevel.csv.header.w = W [NN + m] diff -r 563e015f0f22 -r b96ce07ba56c flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Wed Aug 31 08:53:30 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Wed Aug 31 10:24:49 2011 +0000 @@ -17,6 +17,8 @@ calc.duration.curve = Duration Curve calc.discharge.longitudinal.section = TODO (W bei...) +cross_section = Cross Section + scenario.current = Current scenario.potentiel = Potentiel scenario.scenario = Scenario