# HG changeset patch # User Ingo Weinzierl # Date 1272024678 0 # Node ID e2693596387153e6fe5cc0e6ddc38e530985a85b # Parent bb2175726c8ad2be23842854d79c2c538fb18cc5 Adjusted chart titles of different horizontalprofile charts. gnv-artifacts/trunk@973 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r bb2175726c8a -r e26935963871 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Fri Apr 23 10:13:23 2010 +0000 +++ b/gnv-artifacts/ChangeLog Fri Apr 23 12:11:18 2010 +0000 @@ -1,3 +1,15 @@ +2010-04-23 Ingo Weinzierl + + Issue138 + + * doc/conf/products/horizontalprofile/conf_mesh.xml: Splitted the + outputstates of horizontalprofiles into meshes and non-meshes to handle + the chart subtitle creation. + + * src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshOutputState.java, + src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java: + Outputstates for horizontal profiles. + 2010-04-23 Tim Englich * src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java (getWMS): diff -r bb2175726c8a -r e26935963871 gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh.xml --- a/gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh.xml Fri Apr 23 10:13:23 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh.xml Fri Apr 23 12:11:18 2010 +0000 @@ -274,7 +274,8 @@ - + horizontalprofile_mesh_chart_data horizontalprofile_mesh_odv_data diff -r bb2175726c8a -r e26935963871 gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshOutputState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshOutputState.java Fri Apr 23 12:11:18 2010 +0000 @@ -0,0 +1,55 @@ +package de.intevation.gnv.state.profile.horizontal; + +import java.util.Locale; + +import org.apache.log4j.Logger; + +public class HorizontalProfileMeshOutputState +extends HorizontalProfileOutputState +{ + private static Logger logger = + Logger.getLogger(HorizontalProfileMeshOutputState.class); + + + public HorizontalProfileMeshOutputState() { + super(); + } + + + /** + * 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) { + logger.debug("create chart subtitle."); + + StringBuilder sb = new StringBuilder(); + String time = getData(locale, "dateid"); + if (time != null) { + sb.append(time); + } + + String coordinate = getData(locale, "mesh_point"); + if (coordinate != null) { + if (time != null) + sb.append("\n"); + + sb.append(coordinate); + } + + String depth = getData(locale, "depthid"); + if (depth != null) { + if (coordinate != null) + sb.append("\n"); + + sb.append(depth); + } + + return sb.toString(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r bb2175726c8a -r e26935963871 gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java --- 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 OutputState 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); }