# HG changeset patch # User Felix Wolfsteller # Date 1315391834 0 # Node ID bcba246d9c03ab1d664e0774553603f39f0817f3 # Parent 96d7842e80ee4de0068024014d458bdcdd4abdb5 Fix various issues like i18n in cross section diagrams. flys-artifacts/trunk@2662 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 96d7842e80ee -r bcba246d9c03 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Sep 07 09:26:34 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Sep 07 10:37:14 2011 +0000 @@ -1,3 +1,22 @@ +2011-09-07 Felix Wolfsteller + + Fix various display-issues like i18n in cross-section diagram. + + * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java: + Set description of facets to expected values. + + * src/main/java/de/intevation/flys/artifacts/exports/CrossSectionGenerator.java: + Fix i18n of chart title. Set subtitle to expected value, pass facets + description to StyledSeries to see expected legend. + +2011-09-07 Felix Wolfsteller + + Cosmetics, resolved refactoring todo. + + * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java + (compute, computeAdvance, computeFeed): Refactored, extracted method, + resolving duplicate code and TODO. + 2011-09-07 Felix Wolfsteller Fix waterline "calculation" at given km. Chosen approach is diff -r 96d7842e80ee -r bcba246d9c03 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 Sep 07 09:26:34 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Wed Sep 07 10:37:14 2011 +0000 @@ -94,8 +94,9 @@ } // Also register the CrossSectionFacet (added to respective out). - facets.add(new CrossSectionFacet("facet.cross_section")); - facets.add(new CrossSectionWaterLineFacet("facet.cross_section_water_line")); + facets.add(new CrossSectionFacet(winfo.getCrossSectionName())); + // Assume to be in wq_single mode. + facets.add(new CrossSectionWaterLineFacet("Q=" + winfo.getDataAsString("wq_single"))); return res; } diff -r 96d7842e80ee -r bcba246d9c03 flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java Wed Sep 07 09:26:34 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java Wed Sep 07 10:37:14 2011 +0000 @@ -17,6 +17,7 @@ import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.WINFOArtifact; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.WQKms; @@ -61,7 +62,10 @@ */ protected String getChartTitle() { // TODO get river etc for localized heading - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); + Object[] i18n_msg_args = new Object[] { + getRiverName() + }; + return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, i18n_msg_args); } @@ -74,8 +78,7 @@ Object[] args = new Object[] { getRiverName(), - dist[0], - dist[1] + getKm() }; String subtitle = msg(I18N_CHART_SUBTITLE, "", args); @@ -92,6 +95,21 @@ /** + * Get cross_section.km data from artifact. + */ + protected Double getKm() { + try { + WINFOArtifact winfo = (WINFOArtifact) master; + return Double.parseDouble(winfo.getDataAsString("cross_section.km")); + } + catch (Exception e) { + logger.error("Cannot convert cross_section.km to double"); + return 0.0d; + } + } + + + /** * Get localized Y Axis label. */ protected String getYAxisLabel() { @@ -144,10 +162,10 @@ } if (name.equals(CROSS_SECTION)) { - doCrossSectionOut(f.getData(artifact, context), attr); + doCrossSectionOut(f.getData(artifact, context), f.getDescription(), attr); } else if (name.equals(CROSS_SECTION_WATER_LINE)) { - doCrossSectionWaterLineOut(f.getData(artifact, context), attr); + doCrossSectionWaterLineOut(f.getData(artifact, context), f.getDescription(), attr); } else { logger.warn("CrossSection.doOut: Unknown facet name: " + name); @@ -159,12 +177,13 @@ /** * Do cross sections waterline out. * + * @param seriesName name of the data (line) to display in legend. * @param theme Theme for the data series. */ - protected void doCrossSectionWaterLineOut(Object o, Document theme) { + protected void doCrossSectionWaterLineOut(Object o, String seriesName, Document theme) { logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut"); - // TODO Series should get name like "Q=22.0" - XYSeries series = new StyledXYSeries("Q= ... ", theme); + + XYSeries series = new StyledXYSeries(seriesName, theme); double[][] a = (double [][]) o; double [] pxs = a[0]; @@ -178,15 +197,13 @@ /** * Do cross sections out. * + * @param seriesName name of the data (line) to display in legend. * @param theme Theme for the data series. */ - protected void doCrossSectionOut(Object o, Document theme) { + protected void doCrossSectionOut(Object o, String seriesName, Document theme) { logger.debug("CrossSectionGenerator.doCrossSectionOut"); - // TODO Series should get name of selected cross-section (e.g. - // "0-93.1(1990-2002).PRF") (exposed as getCrossSectionName in - // WINFOArtifact) - XYSeries series = new StyledXYSeries("aliquide", theme); + XYSeries series = new StyledXYSeries(seriesName, theme); double[][] a = (double [][]) o; double [] pxs = a[0];