comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java @ 1712:7e19449d7826

#253 Modified the title creation of chart curves - titles will now equal the Facet's description. flys-artifacts/trunk@2984 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 17 Oct 2011 10:47:36 +0000
parents bdb05dc9b763
children eb35570df0e8
comparison
equal deleted inserted replaced
1711:f708120cb7bc 1712:7e19449d7826
98 98
99 FLYSArtifact flys = (FLYSArtifact) artifact; 99 FLYSArtifact flys = (FLYSArtifact) artifact;
100 Facet f = flys.getNativeFacet(facet); 100 Facet f = flys.getNativeFacet(facet);
101 101
102 if (name.equals(COMPUTED_DISCHARGE_Q)) { 102 if (name.equals(COMPUTED_DISCHARGE_Q)) {
103 doQOut((WQKms) f.getData(artifact, context), attr, visible); 103 doQOut((WQKms) f.getData(artifact, context), facet, attr, visible);
104 } 104 }
105 else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q)) { 105 else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q)) {
106 doMainValueQAnnotations(f.getData(artifact, context), attr,visible); 106 doMainValueQAnnotations(
107 f.getData(artifact, context), facet, attr,visible);
107 } 108 }
108 else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_W)) { 109 else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_W)) {
109 doMainValueWAnnotations(f.getData(artifact, context), attr,visible); 110 doMainValueWAnnotations(
111 f.getData(artifact, context), facet, attr,visible);
110 } 112 }
111 else { 113 else {
112 logger.warn("Unknown facet type for computed discharge: " + name); 114 logger.warn("Unknown facet type for computed discharge: " + name);
113 return; 115 return;
114 } 116 }
118 /** 120 /**
119 * Store W MainValues as annotations for later plotting. 121 * Store W MainValues as annotations for later plotting.
120 */ 122 */
121 protected void doMainValueWAnnotations( 123 protected void doMainValueWAnnotations(
122 Object o, 124 Object o,
125 Facet facet,
123 Document theme, 126 Document theme,
124 boolean visible 127 boolean visible
125 ) { 128 ) {
126 logger.debug("ComputedDischargeCurveGenerator set W MainValues."); 129 logger.debug("ComputedDischargeCurveGenerator set W MainValues.");
127 130
128 FLYSAnnotation fa = (FLYSAnnotation) o; 131 FLYSAnnotation fa = (FLYSAnnotation) o;
129 fa.setTheme(theme); 132 fa.setTheme(theme);
133 fa.setLabel(facet.getDescription());
130 addAnnotations(fa, visible); 134 addAnnotations(fa, visible);
131 } 135 }
132 136
133 137
134 /** 138 /**
135 * Store Q MainValues as annotations for later plotting. 139 * Store Q MainValues as annotations for later plotting.
136 */ 140 */
137 protected void doMainValueQAnnotations( 141 protected void doMainValueQAnnotations(
138 Object o, 142 Object o,
143 Facet facet,
139 Document theme, 144 Document theme,
140 boolean visible 145 boolean visible
141 ) { 146 ) {
142 logger.debug("ComputedDischargeCurveGenerator set Q MainValues."); 147 logger.debug("ComputedDischargeCurveGenerator set Q MainValues.");
143 148
144 FLYSAnnotation fa = (FLYSAnnotation) o; 149 FLYSAnnotation fa = (FLYSAnnotation) o;
145 fa.setTheme(theme); 150 fa.setTheme(theme);
151 fa.setLabel(facet.getDescription());
146 addAnnotations(fa, visible); 152 addAnnotations(fa, visible);
147 } 153 }
148 154
149 155
150 /** 156 /**
151 * Add Q-Series to plot. 157 * Add Q-Series to plot.
152 * @param wqkms actual data 158 * @param wqkms actual data
153 * @param theme theme to use. 159 * @param theme theme to use.
154 */ 160 */
155 protected void doQOut(WQKms wqkms, Document theme, boolean visible) { 161 protected void doQOut(
162 WQKms wqkms,
163 Facet facet,
164 Document theme,
165 boolean visible
166 ) {
156 int size = wqkms.size(); 167 int size = wqkms.size();
157 168
158 double[] res = new double[3]; 169 double[] res = new double[3];
159 170
160 XYSeries series = new StyledXYSeries(getSeriesName(wqkms), theme); 171 XYSeries series = new StyledXYSeries(facet.getDescription(), theme);
161 for (int i = 0; i < size; i++) { 172 for (int i = 0; i < size; i++) {
162 res = wqkms.get(i, res); 173 res = wqkms.get(i, res);
163 series.add(res[1], res[0]); 174 series.add(res[1], res[0]);
164 } 175 }
165 176
166 addFirstAxisSeries(series, visible); 177 addFirstAxisSeries(series, visible);
167 } 178 }
168
169
170 /**
171 * Get the series name to display in legend.
172 */
173 protected String getSeriesName(WQKms wqkms) {
174 Object[] args = new Object[] {
175 getRiverName(),
176 wqkms.getName()
177 };
178
179 return msg(
180 "chart.computed.discharge.curve.curve.label",
181 "",
182 args);
183 }
184 } 179 }
185 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 180 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org