# HG changeset patch # User Sascha L. Teichmann # Date 1340641706 0 # Node ID 0cf647fe2a962455321f3c6fcadb6ecc573b694a # Parent 36806f6e23fba48b36b9daa87e38758a268f4f4f FixA: Finished I18N for km chart service. flys-artifacts/trunk@4786 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/ChangeLog Mon Jun 25 16:28:26 2012 +0000 @@ -1,3 +1,20 @@ +2012-06-25 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java: + Finished I18N. + + * src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java: + Accept callback to label legend items. + + * src/main/java/de/intevation/flys/jfree/ShapeRenderer.java: Added interface + LabelGenerator to create labels for entries. + + * 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 strings. + 2012-06-25 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalReferenceFacet.java: diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java Mon Jun 25 16:28:26 2012 +0000 @@ -24,6 +24,8 @@ import de.intevation.flys.backend.SessionHolder; +import de.intevation.flys.jfree.ShapeRenderer; + import de.intevation.flys.utils.Formatter; import de.intevation.flys.utils.Pair; @@ -111,6 +113,17 @@ public static final String DEFAULT_W_AXIS = "W [NN + m]"; + public static final String I18N_MEASURED = + "fix.km.chart.meassured"; + + public static final String DEFAULT_MEASURED = + "measured"; + + public static final String I18N_INTERPOLATED = + "fix.km.chart.interpolated"; + + public static final String DEFAULT_INTERPOLATED = + "interpolated"; public static final String DEFAULT_FORMAT = "png"; @@ -312,8 +325,19 @@ area.getMaxY() + wInset)); } + final String measuredS = Resources.getMsg( + callMeta, I18N_MEASURED, DEFAULT_MEASURED); + + final String interpolatedS = Resources.getMsg( + callMeta, I18N_INTERPOLATED, DEFAULT_INTERPOLATED); + LegendItemCollection lic = plot.getLegendItems(); - dataset.addLegendItems(lic); + dataset.addLegendItems(lic, new ShapeRenderer.LabelGenerator() { + @Override + public String createLabel(ShapeRenderer.Entry entry) { + return entry.getFilled() ? measuredS : interpolatedS; + } + }); plot.setFixedLegendItems(lic); applyQSectorMarkers(plot, river, km, callMeta); diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java Mon Jun 25 16:28:26 2012 +0000 @@ -213,14 +213,13 @@ Color.white); } - public void addLegendItems(LegendItemCollection lic) { + public void addLegendItems( + LegendItemCollection lic, + ShapeRenderer.LabelGenerator lg + ) { for (ShapeRenderer.Entry entry: knownShapes.keySet()) { - // TODO: i18n - String label = entry.getFilled() - ? "gemessene Werte" - : "interpolierte Werte"; lic.add(legendItem( - label, + lg.createLabel(entry), entry.getPaint(), entry.getShape(), entry.getFilled())); diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java Mon Jun 25 16:28:26 2012 +0000 @@ -111,6 +111,10 @@ } } // class Entry + public interface LabelGenerator { + String createLabel(Entry entry); + } // interface EntryLabelGenerator + protected Entry [] entries; protected List labelBoundingBoxes; diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Mon Jun 25 16:28:26 2012 +0000 @@ -367,3 +367,5 @@ fix.km.chart.title=Fixings {0} km {1,number,#.###} fix.km.chart.q.axis=Q [m\u00b3/s] fix.km.chart.w.axis=W [NN + m] +fix.km.chart.measured=measured +fix.km.chart.interpolated=interpolated diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Mon Jun 25 16:28:26 2012 +0000 @@ -368,3 +368,5 @@ fix.km.chart.title=Fixierungen {0} km {1,number,#.###} fix.km.chart.q.axis=Q [m\u00b3/s] fix.km.chart.w.axis=W [NN + m] +fix.km.chart.measured=gemessen +fix.km.chart.interpolated=interpoliert diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Mon Jun 25 16:28:26 2012 +0000 @@ -367,3 +367,5 @@ fix.km.chart.title=Fixierungen {0} km {1,number,#.###} fix.km.chart.q.axis=Q [m\u00b3/s] fix.km.chart.w.axis=W [NN + m] +fix.km.chart.measured=gemessen +fix.km.chart.interpolated=interpoliert diff -r 36806f6e23fb -r 0cf647fe2a96 flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Mon Jun 25 16:04:08 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Mon Jun 25 16:28:26 2012 +0000 @@ -367,3 +367,5 @@ fix.km.chart.title=Fixings {0} km {1,number,#.###} fix.km.chart.q.axis=Q [m\u00b3/s] fix.km.chart.w.axis=W [NN + m] +fix.km.chart.measured=measured +fix.km.chart.interpolated=interpolated