Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java @ 1141:bcba246d9c03
Fix various issues like i18n in cross section diagrams.
flys-artifacts/trunk@2662 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 07 Sep 2011 10:37:14 +0000 |
parents | 65d8b3340397 |
children | 01d42a2454f6 |
line wrap: on
line diff
--- 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];