Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java @ 855:e26935963871
Adjusted chart titles of different horizontalprofile charts.
gnv-artifacts/trunk@973 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 23 Apr 2010 12:11:18 +0000 |
parents | 05bf8534a35a |
children | f953c9a559d8 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java Fri Apr 23 10:13:23 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java Fri Apr 23 12:11:18 2010 +0000 @@ -14,6 +14,7 @@ import org.jfree.chart.ChartTheme; import de.intevation.artifacts.CallContext; +import de.intevation.gnv.artifacts.ressource.RessourceFactory; import de.intevation.gnv.chart.Chart; import de.intevation.gnv.chart.ChartLabels; import de.intevation.gnv.chart.HorizontalProfileChart; @@ -23,13 +24,12 @@ import de.intevation.gnv.exports.Export.Profile; import de.intevation.gnv.geobackend.base.Result; import de.intevation.gnv.state.InputData; +import de.intevation.gnv.state.State; import de.intevation.gnv.state.describedata.KeyValueDescibeData; import de.intevation.gnv.state.exception.StateException; import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; import de.intevation.gnv.statistics.HorizontalProfileStatistics; import de.intevation.gnv.statistics.Statistics; -import de.intevation.gnv.utils.InputValidator; -import de.intevation.gnv.utils.WKTUtils; /** * This <code>OutputState</code> is used for 'Horizontalprofile' products. @@ -254,86 +254,58 @@ } - /** - * Creates and returns the subtitle of a chart. - * - * @param locale The Locale used to adjust the language of the subtitle. - * @param uuid The UUID of the current artifact. - * @return the timeperiod of this chart and the start coordinate. - */ @Override protected String createChartSubtitle(Locale locale, String uuid) { - log.debug("create chart subtitle."); - String subtitle = createTimePeriod(locale, uuid); + log.debug("Create subtitle for horizontalprofile chart on meshes."); - // ODV results contain meta information about cruise, station and so on - Collection results = getODVResult(uuid); - if (results != null) { - Iterator iter = results.iterator(); - Result result = iter.hasNext() ? (Result) iter.next() : null; - - subtitle += subtitle.length() != 0 ? "\n" : ""; - subtitle += createMetaChartSubtitle(locale, result); + StringBuilder sb = new StringBuilder(); + String ship = getData(locale, "vehicleid"); + if (ship != null) { + sb.append(ship); } - return subtitle; + String cruise = getData(locale, "cruiseid"); + if (cruise != null) { + if (ship != null) + sb.append("\n"); + + sb.append(cruise); + } + + String track = getData(locale, "trackid"); + if (track != null) { + if (cruise != null) + sb.append("\n"); + + sb.append(track); + } + + return sb.toString(); } - /** - * Create meta information used in subtitles. - * - * @param locale The Locale used to adjust the language of the subtitle. - * @param result A data object. - * @return the start coordinate as human readable string. - */ - protected String createMetaChartSubtitle(Locale locale, Result result) { - log.debug("Fetch meta information and put it into subtitle."); - if (result == null) - return ""; - - StringBuilder meta = new StringBuilder(); - - for (int i = 0; i < CHART_TITLE_META.length; i++) { - String qry = CHART_TITLE_META[i]; + protected String getData(Locale locale, String data) { + InputData input = null; - if (qry.equals("SHAPE")) { - try { - InputData data = getInputDataByName("mesh_coordinate"); - if (data == null) { - continue; - } - String wktPoint = data.getValue(); - meta.append(getMessage(locale,"coordinate","coordinate")); - meta.append(": "); - meta.append(WKTUtils.toText( - locale, - InputValidator.getPointValue(wktPoint))); - } - catch (Exception e) { - log.error(e, e); - } - } - else { - log.debug( - "Add " + qry + " to meta information of subtitle: " - + result.getString(qry) - ); - meta.append(getMessage( - locale, - CHART_TITLE_META_RESSOURCES[i], - CHART_TITLE_META_RESSOURCES[i] - )); - meta.append(": "); - meta.append(result.getString(qry)); - } + State parent = this; + do { + input = inputData.get(data); - if (i != CHART_TITLE_META.length-1) - meta.append("\n"); + if (input != null) + break; + } + while ((parent = parent.getParent()) != null); + + if (input == null) { + log.warn("No data found for: " + data); + return null; } - log.debug("Meta title for chart: " + meta.toString()); - return meta.toString(); + String value = input.getDescription(input.getValue()); + String title = RessourceFactory.getInstance().getRessource( + locale, data, data); + + return (title + ": " + value); }