# HG changeset patch # User Sascha L. Teichmann # Date 1328891127 0 # Node ID 8e2ae8813a063257d085d79603f93115ca22e514 # Parent dce0cc856357dbcf153273509d8bda6651c098db 'Bezugslinien': normalized reference curve is now derived from reference curve. flys-artifacts/trunk@4037 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r dce0cc856357 -r 8e2ae8813a06 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Feb 10 16:00:57 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 10 16:25:27 2012 +0000 @@ -1,3 +1,16 @@ +2012-02-10 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/exports/NormalizedReferenceCurveGenerator.java: + Inherits from ReferenceCurveGenerator now which really simplifies it a lot. + + * src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java: + Added to methods to be overwritten by sub classes. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: Adjusted i8n. + 2012-02-10 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java: diff -r dce0cc856357 -r 8e2ae8813a06 flys-artifacts/src/main/java/de/intevation/flys/exports/NormalizedReferenceCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/NormalizedReferenceCurveGenerator.java Fri Feb 10 16:00:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/NormalizedReferenceCurveGenerator.java Fri Feb 10 16:25:27 2012 +0000 @@ -1,259 +1,42 @@ package de.intevation.flys.exports; -import org.w3c.dom.Document; - -import java.awt.Font; - import org.apache.log4j.Logger; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.title.TextTitle; - -import org.jfree.data.xy.XYSeries; - -import de.intevation.artifactdatabase.state.ArtifactAndFacet; - -import de.intevation.flys.artifacts.model.FacetTypes; -import de.intevation.flys.artifacts.model.WW; -import de.intevation.flys.artifacts.model.WW.ApplyFunctionIterator; -import de.intevation.flys.artifacts.model.WWAxisTypes; - -import de.intevation.flys.jfree.StyledXYSeries; - - /** * An OutGenerator that generates reference curves. */ public class NormalizedReferenceCurveGenerator -extends XYChartGenerator -implements FacetTypes +extends ReferenceCurveGenerator { - public static enum YAXIS { - W_M(0), - W_CM(1); - - public int idx; - private YAXIS(int c) { - idx = c; - } - } - /** House logger. */ private static Logger logger = Logger.getLogger(NormalizedReferenceCurveGenerator.class); - public static final String I18N_CHART_TITLE = - "chart.reference.curve.title"; - - public static final String I18N_CHART_SUBTITLE = - "chart.reference.curve.subtitle"; - - public static final String W_CM_DEFAULT = - "chart.reference.curve.wcm"; - - public static final String W_NNM_DEFAULT = - "chart.reference.curve.wnn"; - - public static final String START_GAUGE = - "chart.reference.curve.start_at_gauge"; - - public static final String START_FREE = - "chart.reference.curve.start_free"; + public static final String I18N_NORMALIZED_CHART_TITLE = + "chart.normalized.reference.curve.title"; - /* - - public static final String I18N_XAXIS_LABEL = - "chart.reference.curve.xaxis.label"; - - public static final String I18N_YAXIS_LABEL = - "chart.reference.curve.yaxis.label"; -*/ -/* - public static final String I18N_XAXIS_LABEL_DEFAULT = - "W [NN + m]"; - - public static final String I18N_YAXIS_LABEL_DEFAULT = - "W [NN + m]"; - */ - - - public static final String I18N_CHART_TITLE_DEFAULT = - "Bezugslinie"; - + public static final String I18N_NORMALIZED_CHART_TITLE_DEFAULT = + "Reduzierte Bezugslinie"; public NormalizedReferenceCurveGenerator() { - super(); } - - /** - * Create Axis for given index. - * @return axis with according internationalized label. - */ - @Override - protected NumberAxis createYAxis(int index) { - Font labelFont = new Font("Tahoma", Font.BOLD, 14); - String label = getYAxisLabel(index); - - NumberAxis axis = createNumberAxis(index, label); - // TODO aspect-ratio settings. - /* - if (index == YAXIS.W_M.idx) { - axis.setAutoRangeIncludesZero(false); - } - */ - axis.setAutoRangeIncludesZero(false); - axis.setLabelFont(labelFont); - return axis; - } - - /** Get default chart title. */ @Override protected String getDefaultChartTitle() { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); + return msg( + I18N_NORMALIZED_CHART_TITLE, + I18N_NORMALIZED_CHART_TITLE_DEFAULT); } @Override - protected String getDefaultChartSubtitle() { - Object[] args = new Object[] { - getRiverName(), - }; - - return msg(I18N_CHART_SUBTITLE, "", args); - } - - - @Override - protected void addSubtitles(JFreeChart chart) { - String subtitle = getChartSubtitle(); - - if (subtitle != null && subtitle.length() > 0) { - chart.addSubtitle(new TextTitle(subtitle)); - } - } - - - /** Get Label for X-axis (W). */ - @Override - protected String getDefaultXAxisLabel() { - // TODO i18nreturn msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); - // at_gauge + w_cm - return "W am Bezugsort- oder Pegel."; - } - - - /** - * Get Label for primary and other Y Axes. - * @param index Axis-Index (0-based). - */ - @Override - protected String getDefaultYAxisLabel(int index) { - String label = "default"; - if (index == YAXIS.W_M.idx) { - //label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); - //TODO i18n - return "W am Zielort"; - } - else if (index == YAXIS.W_CM.idx) { - return "W am Zielpegel"; - } - - return label; + protected String facetName() { + return REFERENCE_CURVE_NORMALIZED; } - - /** - * Called for each facet/them in the out mapped to this generator. - * @param artifactFacet artifact and facet for this theme. - * @param theme styling info. - * @param visible Whether or not the theme is visible. - */ @Override - public void doOut( - ArtifactAndFacet artifactFacet, - Document theme, - boolean visible - ) { - String name = artifactFacet.getFacetName(); - - logger.debug("NormalizedReferenceCurveGenerator.doOut: " + name); - - if (name == null || name.length() == 0) { - logger.error("No facet given. Cannot create dataset."); - return; - } - - if (name.equals(REFERENCE_CURVE_NORMALIZED)) { - doReferenceOut(artifactFacet.getData(context), theme, visible); - } - else if (FacetTypes.IS.MANUALPOINTS(name)) { - doPoints( - artifactFacet.getData(context), - artifactFacet, - theme, - visible, YAXIS.W_M.idx); - } - else { - logger.warn("Unknown facet name: " + name); - return; - } - } - - - /** Register DataSeries with (maybe transformed) points. */ - public void doReferenceOut( - Object data, - Document theme, - boolean visible - ) { - WW ww = (WW)data; - - Object obj = context.getContextValue("reference.curve.axis.scale"); - - WWAxisTypes wwat = obj instanceof WWAxisTypes - ? (WWAxisTypes)obj - : new WWAxisTypes(ww); - - ApplyFunctionIterator iter = wwat.transform(ww, true); - - XYSeries series = new StyledXYSeries( - ww.getName(), false, theme); - - double [] values = new double[2]; - - while (iter.hasNext()) { - iter.next(values); - series.add(values[0], values[1], false); - } - - if (ww.endAtGauge()) { - addAxisSeries(series, YAXIS.W_M.idx, visible); - } - else { - addAxisSeries(series, YAXIS.W_CM.idx, visible); - } - } - - - /** Get Walker to iterate over all axes. */ - @Override - protected YAxisWalker getYAxisWalker() { - return new YAxisWalker() { - /** Get number of items. */ - @Override - public int length() { - return YAXIS.values().length; - } - - /** Get identifier for this index. */ - @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); - return yaxes[idx].toString(); - } - }; + protected boolean doNormalize() { + return true; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r dce0cc856357 -r 8e2ae8813a06 flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java Fri Feb 10 16:00:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java Fri Feb 10 16:25:27 2012 +0000 @@ -124,6 +124,10 @@ return msg(getInCm(1) ? I18N_Y_AXIS_IN_CM : I18N_Y_AXIS_IN_M); } + protected String facetName() { + return REFERENCE_CURVE; + } + /** * Called for each facet/them in the out mapped to this generator. @@ -146,7 +150,7 @@ return; } - if (name.equals(REFERENCE_CURVE)) { + if (name.equals(facetName())) { doReferenceOut(artifactFacet.getData(context), theme, visible); } else if (FacetTypes.IS.MANUALPOINTS(name)) { @@ -162,6 +166,10 @@ } } + protected boolean doNormalize() { + return false; + } + /** Register DataSeries with (maybe transformed) points. */ public void doReferenceOut( @@ -177,7 +185,7 @@ ? (WWAxisTypes)obj : new WWAxisTypes(ww); - ApplyFunctionIterator iter = wwat.transform(ww); + ApplyFunctionIterator iter = wwat.transform(ww, doNormalize()); XYSeries series = new StyledXYSeries( ww.getName(), false, theme); diff -r dce0cc856357 -r 8e2ae8813a06 flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Fri Feb 10 16:00:57 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri Feb 10 16:25:27 2012 +0000 @@ -101,6 +101,8 @@ chart.w_differences.yaxis.label = m chart.w_differences.yaxis.second.label = W [NN + m] +chart.normalized.reference.curve.title = Reduced Reference Curve + facet.longitudinal_section.annotations = POIs facet.discharge_curves.mainvalues.q = Q (main values) facet.discharge_curves.mainvalues.w = W (main values) diff -r dce0cc856357 -r 8e2ae8813a06 flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Fri Feb 10 16:00:57 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri Feb 10 16:25:27 2012 +0000 @@ -96,6 +96,8 @@ chart.reference.curve.y.axis.in.cm = Zielpegel [cm] chart.reference.curve.y.axis.in.m = Zielort(e) [NN + m] +chart.normalized.reference.curve.title = Reduzierte Bezugslinie + chart.w_differences.title = Differenzen chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} chart.w_differences.yaxis.label = m diff -r dce0cc856357 -r 8e2ae8813a06 flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Feb 10 16:00:57 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Feb 10 16:25:27 2012 +0000 @@ -96,6 +96,8 @@ chart.reference.curve.y.axis.in.cm = Zielpegel [cm] chart.reference.curve.y.axis.in.m = Zielort(e) [NN + m] +chart.normalized.reference.curve.title = Reduzierte Bezugslinie + chart.w_differences.title = Differenzen chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} chart.w_differences.yaxis.label = m diff -r dce0cc856357 -r 8e2ae8813a06 flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Fri Feb 10 16:00:57 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri Feb 10 16:25:27 2012 +0000 @@ -94,6 +94,8 @@ chart.reference.curve.y.axis.in.cm = Target Gauge(s) [cm] chart.reference.curve.y.axis.in.m = Target Station(s) [NN + m] +chart.normalized.reference.curve.title = Reduced Reference Curve + chart.w_differences.title = Differences chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} chart.w_differences.yaxis.label = m