Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java @ 2249:997df76c6f58
Create title, subtitle and axes labels for charts from type historical discharge curve.
flys-artifacts/trunk@3898 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 03 Feb 2012 13:42:48 +0000 |
parents | d70a04cad84d |
children | b8df8d1476ba |
comparison
equal
deleted
inserted
replaced
2248:e1eaf9c2b5bf | 2249:997df76c6f58 |
---|---|
7 | 7 |
8 import org.apache.log4j.Logger; | 8 import org.apache.log4j.Logger; |
9 | 9 |
10 import org.jfree.chart.JFreeChart; | 10 import org.jfree.chart.JFreeChart; |
11 import org.jfree.chart.axis.NumberAxis; | 11 import org.jfree.chart.axis.NumberAxis; |
12 import org.jfree.chart.title.TextTitle; | |
12 | 13 |
13 import org.jfree.data.general.SeriesException; | 14 import org.jfree.data.general.SeriesException; |
14 import org.jfree.data.time.Day; | 15 import org.jfree.data.time.Day; |
15 import org.jfree.data.time.RegularTimePeriod; | 16 import org.jfree.data.time.RegularTimePeriod; |
16 import org.jfree.data.time.TimeSeries; | 17 import org.jfree.data.time.TimeSeries; |
20 | 21 |
21 import de.intevation.flys.artifacts.FLYSArtifact; | 22 import de.intevation.flys.artifacts.FLYSArtifact; |
22 import de.intevation.flys.artifacts.model.FacetTypes; | 23 import de.intevation.flys.artifacts.model.FacetTypes; |
23 import de.intevation.flys.artifacts.model.Timerange; | 24 import de.intevation.flys.artifacts.model.Timerange; |
24 import de.intevation.flys.artifacts.model.WQTimerange; | 25 import de.intevation.flys.artifacts.model.WQTimerange; |
26 import de.intevation.flys.utils.FLYSUtils; | |
25 | 27 |
26 | 28 |
27 /** | 29 /** |
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 30 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
29 */ | 31 */ |
33 { | 35 { |
34 private static Logger logger = | 36 private static Logger logger = |
35 Logger.getLogger(HistoricalDischargeCurveGenerator.class); | 37 Logger.getLogger(HistoricalDischargeCurveGenerator.class); |
36 | 38 |
37 | 39 |
40 public static final String I18N_CHART_TITLE = | |
41 "chart.historical.discharge.title"; | |
42 | |
43 public static final String I18N_CHART_SUBTITLE = | |
44 "chart.historical.discharge.subtitle"; | |
45 | |
46 public static final String I18N_XAXIS_LABEL = | |
47 "chart.historical.discharge.xaxis.label"; | |
48 | |
49 public static final String I18N_YAXIS_LABEL = | |
50 "chart.historical.discharge.yaxis.label"; | |
51 | |
52 public static final String I18N_YAXIS_SECOND_LABEL = | |
53 "chart.historical.discharge.yaxis.second.label"; | |
54 | |
55 | |
38 public static enum YAXIS { | 56 public static enum YAXIS { |
39 Q(0); | 57 Q(0); |
40 protected int idx; | 58 protected int idx; |
41 private YAXIS(int c) { | 59 private YAXIS(int c) { |
42 idx = c; | 60 idx = c; |
61 } | 79 } |
62 | 80 |
63 | 81 |
64 @Override | 82 @Override |
65 protected String getDefaultChartTitle() { | 83 protected String getDefaultChartTitle() { |
66 return "TODO: CHART TITLE"; | 84 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); |
85 } | |
86 | |
87 | |
88 @Override | |
89 protected String getDefaultChartSubtitle() { | |
90 String[] args = new String[] { | |
91 FLYSUtils.getReferenceGaugeName((FLYSArtifact) master) | |
92 }; | |
93 | |
94 return msg(I18N_CHART_SUBTITLE, "", args); | |
67 } | 95 } |
68 | 96 |
69 | 97 |
70 /** | 98 /** |
71 * Empty (suppress subtitle). | 99 * Empty (suppress subtitle). |
72 */ | 100 */ |
73 @Override | 101 @Override |
74 protected void addSubtitles(JFreeChart chart) { | 102 protected void addSubtitles(JFreeChart chart) { |
75 // this chart has no subtitle | 103 String subtitle = getChartSubtitle(); |
104 | |
105 if (subtitle != null && subtitle.length() > 0) { | |
106 chart.addSubtitle(new TextTitle(subtitle)); | |
107 } | |
76 } | 108 } |
77 | 109 |
78 | 110 |
79 @Override | 111 @Override |
80 protected String getDefaultXAxisLabel() { | 112 protected String getDefaultXAxisLabel() { |
81 return "TODO: DEFAULT X AXIS LABEL"; | 113 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL); |
82 } | 114 } |
83 | 115 |
84 @Override | 116 @Override |
85 protected String getDefaultYAxisLabel(int pos) { | 117 protected String getDefaultYAxisLabel(int pos) { |
86 return "TODO: DEFAULT Y AXIS LABEL FOR: " + pos; | 118 if (pos == 0) { |
119 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL); | |
120 } | |
121 else if (pos == 1) { | |
122 return msg(I18N_YAXIS_SECOND_LABEL, I18N_YAXIS_SECOND_LABEL); | |
123 } | |
124 else { | |
125 return "NO TITLE FOR Y AXIS: " + pos; | |
126 } | |
87 } | 127 } |
88 | 128 |
89 | 129 |
90 /** | 130 /** |
91 * Creates a new Y-Axis. | 131 * Creates a new Y-Axis. |