comparison artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveGenerator.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveGenerator.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.exports;
2
3 import org.dive4elements.river.artifacts.model.FacetTypes;
4 import org.dive4elements.river.artifacts.model.WKms;
5
6 import org.jfree.chart.JFreeChart;
7 import org.jfree.chart.plot.XYPlot;
8
9
10 /**
11 * An OutGenerator that generates w differences curves.
12 */
13 public class WDifferencesCurveGenerator
14 extends LongitudinalSectionGenerator
15 implements FacetTypes
16 {
17 public enum YAXIS {
18 W(0),
19 D(1),
20 Q(2);
21 protected int idx;
22 private YAXIS(int c) {
23 idx = c;
24 }
25 }
26
27 /** Key for internationalized title of WDiff charts. */
28 public final static String I18N_WDIFF_TITLE = "chart.w_differences.title";
29
30 /** Default for internationalized title (when no translation found). */
31 public final static String I18N_WDIFF_TITLE_DEFAULT = "Differences";
32
33 public final static String I18N_WDIFF_SUBTITLE =
34 "chart.w_differences.subtitle";
35
36
37 @Override
38 protected YAxisWalker getYAxisWalker() {
39 return new YAxisWalker() {
40 @Override
41 public int length() {
42 return YAXIS.values().length;
43 }
44
45 @Override
46 public String getId(int idx) {
47 YAXIS[] yaxes = YAXIS.values();
48 return yaxes[idx].toString();
49 }
50 };
51 }
52
53
54 /**
55 * Get internationalized title for chart.
56 * @return internationalized Chart title.
57 */
58 @Override
59 public String getDefaultChartTitle() {
60 return msg(I18N_WDIFF_TITLE, I18N_WDIFF_TITLE_DEFAULT);
61 }
62
63
64 @Override
65 protected String getDefaultChartSubtitle() {
66 return getRiverName();
67 }
68
69
70 /**
71 * Gets key to look up internationalized String for the charts subtitle.
72 * @return key to look up translated subtitle.
73 */
74 @Override
75 protected String getChartSubtitleKey() {
76 return I18N_WDIFF_SUBTITLE;
77 }
78
79
80 /**
81 *
82 */
83 @Override
84 public JFreeChart generateChart() {
85 JFreeChart chart = super.generateChart();
86 if (chart != null && chart.getPlot() != null) {
87 XYPlot plot = (XYPlot) chart.getPlot();
88 plot.setRangeZeroBaselineVisible(true);
89 }
90 return chart;
91 }
92
93
94 /**
95 * Get name of series (displayed in legend).
96 * @return name of the series.
97 */
98 protected String getSeriesName(WKms wqkms, String mode) {
99 String name = wqkms.getName();
100 String prefix = (name != null && name.indexOf(mode) >= 0)
101 ? null
102 : mode;
103
104 return (prefix != null && prefix.length() > 0)
105 ? prefix + "(" + name +")"
106 : name;
107 }
108 }
109 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org