Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.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 | 6dfc3a1fc70d |
children | a7f1d4c9add4 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
116 /** The CallContext object.*/ | 116 /** The CallContext object.*/ |
117 protected CallContext context; | 117 protected CallContext context; |
118 | 118 |
119 protected D4EArtifactCollection collection; | 119 protected D4EArtifactCollection collection; |
120 | 120 |
121 /** The artifact that is used to decorate the chart with meta information.*/ | 121 /** Artifact that is used to decorate the chart with meta information.*/ |
122 protected Artifact master; | 122 protected Artifact master; |
123 | 123 |
124 /** The settings that should be used during output creation.*/ | 124 /** The settings that should be used during output creation.*/ |
125 protected Settings settings; | 125 protected Settings settings; |
126 | 126 |
127 /** Map of datasets ("index"). */ | 127 /** Map of datasets ("index"). */ |
128 protected SortedMap<Integer, AxisDataset> datasets; | 128 protected SortedMap<Integer, AxisDataset> datasets; |
129 | 129 |
130 /** List of annotations to insert in plot. */ | 130 /** List of annotations to insert in plot. */ |
131 protected List<RiverAnnotation> annotations = new ArrayList<RiverAnnotation>(); | 131 protected List<RiverAnnotation> annotations = |
132 new ArrayList<RiverAnnotation>(); | |
132 | 133 |
133 protected String outName; | 134 protected String outName; |
134 | 135 |
135 /** | 136 /** |
136 * A mini interface that allows to walk over the YAXIS enums defined in | 137 * A mini interface that allows to walk over the YAXIS enums defined in |
368 } | 369 } |
369 } | 370 } |
370 | 371 |
371 | 372 |
372 @Override | 373 @Override |
373 public void init(String outName, Document request, OutputStream out, CallContext context) { | 374 public void init( |
375 String outName, | |
376 Document request, | |
377 OutputStream out, | |
378 CallContext context | |
379 ) { | |
374 log.debug("ChartGenerator.init"); | 380 log.debug("ChartGenerator.init"); |
375 | 381 |
376 this.outName = outName; | 382 this.outName = outName; |
377 this.request = request; | 383 this.request = request; |
378 this.out = out; | 384 this.out = out; |
408 this.settings = settings; | 414 this.settings = settings; |
409 } | 415 } |
410 | 416 |
411 | 417 |
412 /** | 418 /** |
413 * Returns an instance of <i>ChartSettings</i> with a chart specific section | 419 * Returns instance of <i>ChartSettings</i> with a chart specific section |
414 * but with no axes settings. | 420 * but with no axes settings. |
415 * | 421 * |
416 * @return an instance of <i>ChartSettings</i>. | 422 * @return an instance of <i>ChartSettings</i>. |
417 */ | 423 */ |
418 @Override | 424 @Override |
484 return exportSection; | 490 return exportSection; |
485 } | 491 } |
486 | 492 |
487 | 493 |
488 /** | 494 /** |
489 * Creates a list of Sections that contains all axes of the chart (including | 495 * Create list of Sections that contains all axes of the chart (including |
490 * X and Y axes). | 496 * X and Y axes). |
491 * | 497 * |
492 * @return a list of Sections for each axis in this chart. | 498 * @return a list of Sections for each axis in this chart. |
493 */ | 499 */ |
494 protected List<AxisSection> buildAxisSections() { | 500 protected List<AxisSection> buildAxisSections() { |
957 /* Only time series charts have time ranges so prefer those. */ | 963 /* Only time series charts have time ranges so prefer those. */ |
958 if (axisId.equals("X")) { | 964 if (axisId.equals("X")) { |
959 Long lowerTime = as.getLowerTimeRange(); | 965 Long lowerTime = as.getLowerTimeRange(); |
960 Long upperTime = as.getUpperTimeRange(); | 966 Long upperTime = as.getUpperTimeRange(); |
961 if ( lowerTime != null && upperTime != null ) { | 967 if ( lowerTime != null && upperTime != null ) { |
962 log.debug("Using time range: " + lowerTime + " - " + upperTime); | 968 log.debug("Using time range: " |
969 + lowerTime + " - " + upperTime); | |
963 return lowerTime < upperTime | 970 return lowerTime < upperTime |
964 ? new Range(lowerTime, upperTime) | 971 ? new Range(lowerTime, upperTime) |
965 : new Range(upperTime, lowerTime); | 972 : new Range(upperTime, lowerTime); |
966 } | 973 } |
967 } | 974 } |
1216 | 1223 |
1217 return new String[] { lower, upper }; | 1224 return new String[] { lower, upper }; |
1218 } | 1225 } |
1219 | 1226 |
1220 | 1227 |
1221 /** Returns null if the (x|y)range-element was not found in request document. | 1228 /** Returns null if the (x|y)range-element was not found in |
1229 * request document. | |
1222 * This usally means that the axis are not manually zoomed, i.e. showing | 1230 * This usally means that the axis are not manually zoomed, i.e. showing |
1223 * full data extent. */ | 1231 * full data extent. */ |
1224 protected String[] getValueAxisRangeFromRequest() { | 1232 protected String[] getValueAxisRangeFromRequest() { |
1225 Element yrange = (Element)XMLUtils.xpath( | 1233 Element yrange = (Element)XMLUtils.xpath( |
1226 request, | 1234 request, |
1278 if (axis.getAutoRangeIncludesZero()) { | 1286 if (axis.getAutoRangeIncludesZero()) { |
1279 axisDataset.setRange( | 1287 axisDataset.setRange( |
1280 Range.expandToInclude(axisDataset.getRange(), 0d)); | 1288 Range.expandToInclude(axisDataset.getRange(), 0d)); |
1281 } | 1289 } |
1282 | 1290 |
1283 setYBounds(axisIndex, expandPointRange(axisDataset.getRange())); | 1291 setYBounds( |
1292 axisIndex, expandPointRange(axisDataset.getRange())); | |
1284 | 1293 |
1285 // Add contained datasets, mapping to axis. | 1294 // Add contained datasets, mapping to axis. |
1286 for (XYDataset dataset: axisDataset.getDatasets()) { | 1295 for (XYDataset dataset: axisDataset.getDatasets()) { |
1287 plot.setDataset(datasetIndex, dataset); | 1296 plot.setDataset(datasetIndex, dataset); |
1288 plot.mapDatasetToRangeAxis(datasetIndex, axisIndex); | 1297 plot.mapDatasetToRangeAxis(datasetIndex, axisIndex); |
1409 plot.setRenderer(idx, dRenderer); | 1418 plot.setRenderer(idx, dRenderer); |
1410 | 1419 |
1411 area.applyTheme(dRenderer); | 1420 area.applyTheme(dRenderer); |
1412 | 1421 |
1413 // i18n | 1422 // i18n |
1414 dRenderer.setAreaLabelNumberFormat(Formatter.getFormatter(context.getMeta(), 2, 4)); | 1423 dRenderer.setAreaLabelNumberFormat( |
1424 Formatter.getFormatter(context.getMeta(), 2, 4)); | |
1415 | 1425 |
1416 dRenderer.setAreaLabelTemplate(Resources.getMsg( | 1426 dRenderer.setAreaLabelTemplate(Resources.getMsg( |
1417 context.getMeta(), "area.label.template", "Area=%sm2")); | 1427 context.getMeta(), "area.label.template", "Area=%sm2")); |
1418 | 1428 |
1419 LegendItem legendItem = dRenderer.getLegendItem(idx, 0); | 1429 LegendItem legendItem = dRenderer.getLegendItem(idx, 0); |
1445 if (range == null) { | 1455 if (range == null) { |
1446 return null; | 1456 return null; |
1447 } | 1457 } |
1448 else if (range.getLowerBound() == range.getUpperBound()) { | 1458 else if (range.getLowerBound() == range.getUpperBound()) { |
1449 Range expandedRange = ChartHelper.expandRange(range, 5d); | 1459 Range expandedRange = ChartHelper.expandRange(range, 5d); |
1450 return new DoubleBounds(expandedRange.getLowerBound(), expandedRange.getUpperBound()); | 1460 return new DoubleBounds( |
1461 expandedRange.getLowerBound(), expandedRange.getUpperBound()); | |
1451 } | 1462 } |
1452 | 1463 |
1453 return new DoubleBounds(range.getLowerBound(), range.getUpperBound()); | 1464 return new DoubleBounds(range.getLowerBound(), range.getUpperBound()); |
1454 } | 1465 } |
1455 | 1466 |