comparison artifacts/src/main/java/org/dive4elements/river/exports/ChartExportHelper.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 582aaac447ad
children ffd4e2b0381c 0a5239a1e46e
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
150 150
151 int[] size = getSize(context); 151 int[] size = getSize(context);
152 152
153 ChartRenderingInfo info = new ChartRenderingInfo(); 153 ChartRenderingInfo info = new ChartRenderingInfo();
154 154
155 chart.draw(graphics, new Rectangle2D.Double(0.0D, 0.0D,size[0],size[1]), info); 155 chart.draw(
156 graphics,
157 new Rectangle2D.Double(0.0D, 0.0D,size[0],size[1]),
158 info);
156 159
157 try { 160 try {
158 graphics.stream(new OutputStreamWriter(out, encoding)); 161 graphics.stream(new OutputStreamWriter(out, encoding));
159 } 162 }
160 catch (SVGGraphics2DIOException svge) { 163 catch (SVGGraphics2DIOException svge) {
161 log.error("Error while writing svg export to output stream.", svge); 164 log.error(
165 "Error while writing svg export to output stream.", svge);
162 } 166 }
163 catch (UnsupportedEncodingException uee) { 167 catch (UnsupportedEncodingException uee) {
164 log.error("Unsupported encoding: " + encoding, uee); 168 log.error("Unsupported encoding: " + encoding, uee);
165 } 169 }
166 } 170 }
218 float marginBottom = (Float) cc.getContextValue( 222 float marginBottom = (Float) cc.getContextValue(
219 "chart.marginBottom"); 223 "chart.marginBottom");
220 224
221 float spaceX = width - marginLeft - marginRight; 225 float spaceX = width - marginLeft - marginRight;
222 if (size[0] > spaceX) { 226 if (size[0] > spaceX) {
223 log.warn("Width of the chart is too big for pdf -> resize it now."); 227 log.warn(
228 "Width of the chart is too big for pdf -> resize it now.");
224 double ratio = ((double)spaceX) / size[0]; 229 double ratio = ((double)spaceX) / size[0];
225 size[0] *= ratio; 230 size[0] *= ratio;
226 size[1] *= ratio; 231 size[1] *= ratio;
227 log.debug("Resized chart to " + size[0] + "x" + size[1]); 232 log.debug("Resized chart to " + size[0] + "x" + size[1]);
228 } 233 }
229 234
230 float spaceY = height - marginTop - marginBottom; 235 float spaceY = height - marginTop - marginBottom;
231 if (size[1] > spaceY) { 236 if (size[1] > spaceY) {
232 log.warn("Height of the chart is too big for pdf -> resize it now."); 237 log.warn(
238 "Height of the chart is too big for pdf -> resize it now.");
233 double ratio = ((double)spaceY) / size[1]; 239 double ratio = ((double)spaceY) / size[1];
234 size[0] *= ratio; 240 size[0] *= ratio;
235 size[1] *= ratio; 241 size[1] *= ratio;
236 log.debug("Resized chart to " + size[0] + "x" + size[1]); 242 log.debug("Resized chart to " + size[0] + "x" + size[1]);
237 } 243 }
245 } 251 }
246 252
247 try { 253 try {
248 PdfWriter writer = PdfWriter.getInstance(document, out); 254 PdfWriter writer = PdfWriter.getInstance(document, out);
249 255
250 document.addSubject(chart.getTitle() != null ? chart.getTitle().getText() : ""); 256 document.addSubject(
257 chart.getTitle() != null ? chart.getTitle().getText() : "");
251 document.addCreationDate(); 258 document.addCreationDate();
252 document.open(); 259 document.open();
253 260
254 try { 261 try {
255 PdfContentByte content = writer.getDirectContent(); 262 PdfContentByte content = writer.getDirectContent();
420 return size; 427 return size;
421 } 428 }
422 429
423 430
424 /** 431 /**
425 * This method returns the anchor of the chart so that the chart is centered 432 * Returns the anchor of the chart so that the chart is centered
426 * according to the given parameters. 433 * according to the given parameters.
427 * 434 *
428 * @param mLeft Left margin 435 * @param mLeft Left margin
429 * @param mRight Right margin 436 * @param mRight Right margin
430 * @param mBottom Bottom margin 437 * @param mBottom Bottom margin

http://dive4elements.wald.intevation.org