Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.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 | be5ce2882708 |
children | 0071702ba03f |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
181 flys-artifacts/src/main/resources/images/ | 181 flys-artifacts/src/main/resources/images/ |
182 flys-client/src/main/webapp/images/ | 182 flys-client/src/main/webapp/images/ |
183 */ | 183 */ |
184 java.net.URL imageURL; | 184 java.net.URL imageURL; |
185 if (logo.equals("Intevation")) { | 185 if (logo.equals("Intevation")) { |
186 imageURL = XYChartGenerator.class.getResource("/images/intevation.png"); | 186 imageURL = XYChartGenerator.class.getResource( |
187 "/images/intevation.png"); | |
187 } | 188 } |
188 else { // TODO else if ... | 189 else { // TODO else if ... |
189 imageURL = XYChartGenerator.class.getResource("/images/bfg_logo.gif"); | 190 imageURL = XYChartGenerator.class.getResource( |
191 "/images/bfg_logo.gif"); | |
190 } | 192 } |
191 imageIcon = new ImageIcon(imageURL); | 193 imageIcon = new ImageIcon(imageURL); |
192 double xPos = 0d, yPos = 0d; | 194 double xPos = 0d, yPos = 0d; |
193 | 195 |
194 String placeh = logoHPlace(); | 196 String placeh = logoHPlace(); |
202 } | 204 } |
203 else if (placev.equals("bottom")) { | 205 else if (placev.equals("bottom")) { |
204 yPos = (Double)getYBounds(0).getLower(); | 206 yPos = (Double)getYBounds(0).getLower(); |
205 } | 207 } |
206 else if (placev.equals("center")) { | 208 else if (placev.equals("center")) { |
207 yPos = ((Double)getYBounds(0).getUpper() + (Double)getYBounds(0).getLower())/2d; | 209 yPos = ((Double)getYBounds(0).getUpper() |
210 + (Double)getYBounds(0).getLower())/2d; | |
208 } | 211 } |
209 else { | 212 else { |
210 log.debug("Unknown place-v value: " + placev); | 213 log.debug("Unknown place-v value: " + placev); |
211 } | 214 } |
212 | 215 |
218 } | 221 } |
219 else if (placeh.equals("right")) { | 222 else if (placeh.equals("right")) { |
220 xPos = getRightX(); | 223 xPos = getRightX(); |
221 } | 224 } |
222 else if (placeh.equals("center")) { | 225 else if (placeh.equals("center")) { |
223 xPos = ((Long)getXBounds(0).getUpper() + (Long)getXBounds(0).getLower())/2d; | 226 xPos = ((Long)getXBounds(0).getUpper() |
227 + (Long)getXBounds(0).getLower())/2d; | |
224 } | 228 } |
225 else { | 229 else { |
226 log.debug("Unknown place-h value: " + placeh); | 230 log.debug("Unknown place-h value: " + placeh); |
227 } | 231 } |
228 | 232 |
264 } | 268 } |
265 } | 269 } |
266 | 270 |
267 XYAnnotation xyannotation = | 271 XYAnnotation xyannotation = |
268 new XYImageAnnotation(xPos, yPos, imageIcon.getImage(), anchor); | 272 new XYImageAnnotation(xPos, yPos, imageIcon.getImage(), anchor); |
269 plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND); | 273 plot.getRenderer().addAnnotation( |
274 xyannotation, org.jfree.ui.Layer.BACKGROUND); | |
270 } | 275 } |
271 | 276 |
272 /** | 277 /** |
273 * This method zooms the plot to the specified ranges in the attribute | 278 * This method zooms the plot to the specified ranges in the attribute |
274 * document or to the ranges specified by the min/max values in the | 279 * document or to the ranges specified by the min/max values in the |
526 if (user != null) { | 531 if (user != null) { |
527 long min = total.getLower().longValue(); | 532 long min = total.getLower().longValue(); |
528 long max = total.getUpper().longValue(); | 533 long max = total.getUpper().longValue(); |
529 long diff = max > min ? max - min : min - max; | 534 long diff = max > min ? max - min : min - max; |
530 | 535 |
531 long newMin = Math.round(min + user.getLower().doubleValue() * diff); | 536 long newMin = Math.round( |
532 long newMax = Math.round(min + user.getUpper().doubleValue() * diff); | 537 min + user.getLower().doubleValue() * diff); |
538 long newMax = Math.round( | |
539 min + user.getUpper().doubleValue() * diff); | |
533 | 540 |
534 TimeBounds newBounds = new TimeBounds(newMin, newMax); | 541 TimeBounds newBounds = new TimeBounds(newMin, newMax); |
535 | 542 |
536 log.debug(" Zoom axis to: " + newBounds); | 543 log.debug(" Zoom axis to: " + newBounds); |
537 | 544 |
583 } | 590 } |
584 } | 591 } |
585 | 592 |
586 | 593 |
587 /** | 594 /** |
588 * Adjusts the (look of) axes of a plot. This method sets the <i>labelFont</i> of the | 595 * Adjusts the (look of) axes of a plot. |
596 * This method sets the <i>labelFont</i> of the | |
589 * X axis. | 597 * X axis. |
590 * | 598 * |
591 * (Duplicate in XYChartGenerator). | 599 * (Duplicate in XYChartGenerator). |
592 * | 600 * |
593 * @param plot The XYPlot of the chart. | 601 * @param plot The XYPlot of the chart. |
608 xaxis.setLabelFont(labelFont); | 616 xaxis.setLabelFont(labelFont); |
609 xaxis.setTickLabelFont(labelFont); | 617 xaxis.setTickLabelFont(labelFont); |
610 } | 618 } |
611 | 619 |
612 | 620 |
613 protected Date decodeXAxisValue(JSONArray array) throws JSONException, ParseException { | 621 protected Date decodeXAxisValue(JSONArray array) |
622 throws JSONException, ParseException { | |
614 try { | 623 try { |
615 double x = array.getDouble(0); | 624 double x = array.getDouble(0); |
616 long l = (new Double(x)).longValue(); | 625 long l = (new Double(x)).longValue(); |
617 return new Date(l); | 626 return new Date(l); |
618 } | 627 } |
637 String seriesName = aandf.getFacetDescription(); | 646 String seriesName = aandf.getFacetDescription(); |
638 TimeSeries series = new StyledTimeSeries(seriesName, theme); | 647 TimeSeries series = new StyledTimeSeries(seriesName, theme); |
639 | 648 |
640 // Add text annotations for single points. | 649 // Add text annotations for single points. |
641 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>(); | 650 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>(); |
642 HashMap<FixedMillisecond, String> names = new HashMap<FixedMillisecond, String>(); | 651 HashMap<FixedMillisecond, String> names = |
652 new HashMap<FixedMillisecond, String>(); | |
643 | 653 |
644 try { | 654 try { |
645 JSONArray points = new JSONArray((String) o); | 655 JSONArray points = new JSONArray((String) o); |
646 for (int i = 0, P = points.length(); i < P; i++) { | 656 for (int i = 0, P = points.length(); i < P; i++) { |
647 JSONArray array = points.getJSONArray(i); | 657 JSONArray array = points.getJSONArray(i); |
683 } | 693 } |
684 RiverAnnotation annotations = | 694 RiverAnnotation annotations = |
685 new RiverAnnotation(null, null, null, theme); | 695 new RiverAnnotation(null, null, null, theme); |
686 annotations.setTextAnnotations(xy); | 696 annotations.setTextAnnotations(xy); |
687 | 697 |
688 // Do not generate second legend entry. (null was passed for the aand before). | 698 // Do not generate second legend entry. |
699 // (null was passed for the aand before). | |
689 doAnnotations(annotations, null, theme, visible); | 700 doAnnotations(annotations, null, theme, visible); |
690 | 701 |
691 addAxisDataset(tsc, axisIndex, visible); | 702 addAxisDataset(tsc, axisIndex, visible); |
692 } | 703 } |
693 | 704 |
766 legendItem.getLine(), | 777 legendItem.getLine(), |
767 legendItem.getLineStroke(), | 778 legendItem.getLineStroke(), |
768 legendItem.getLinePaint() | 779 legendItem.getLinePaint() |
769 ); | 780 ); |
770 interLegend.setSeriesKey(series.getKey()); | 781 interLegend.setSeriesKey(series.getKey()); |
771 log.debug("applySeriesAttributes: draw unfilled legend item"); | 782 log.debug("applySeriesAttributes: " |
783 + "draw unfilled legend item"); | |
772 plot.getLegendItems().add(interLegend); | 784 plot.getLegendItems().add(interLegend); |
773 } | 785 } |
774 } | 786 } |
775 } | 787 } |
776 | 788 |