comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 3245:dd3ddc8ecb14

Remove HYK references/code from ChartGenerator flys-artifacts/trunk@4878 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Fri, 06 Jul 2012 09:32:45 +0000
parents 1dca41dba135
children 4eb91fb1e73e
comparison
equal deleted inserted replaced
3244:1a79d47ed14b 3245:dd3ddc8ecb14
57 57
58 import de.intevation.flys.artifacts.FLYSArtifact; 58 import de.intevation.flys.artifacts.FLYSArtifact;
59 59
60 import de.intevation.flys.artifacts.resources.Resources; 60 import de.intevation.flys.artifacts.resources.Resources;
61 61
62 import de.intevation.flys.artifacts.model.HYKFactory;
63
64 import de.intevation.flys.jfree.Bounds; 62 import de.intevation.flys.jfree.Bounds;
65 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; 63 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
66 import de.intevation.flys.jfree.DoubleBounds; 64 import de.intevation.flys.jfree.DoubleBounds;
67 import de.intevation.flys.jfree.EnhancedLineAndShapeRenderer; 65 import de.intevation.flys.jfree.EnhancedLineAndShapeRenderer;
68 import de.intevation.flys.jfree.FLYSAnnotation; 66 import de.intevation.flys.jfree.FLYSAnnotation;
183 annotations = new ArrayList<FLYSAnnotation>(); 181 annotations = new ArrayList<FLYSAnnotation>();
184 } 182 }
185 183
186 annotations.add(annotation); 184 annotations.add(annotation);
187 } 185 }
188 186
189 /** 187 /**
190 * Add a text and a line annotation. 188 * Add a text and a line annotation.
191 * @param area convenience to determine positions in plot. 189 * @param area convenience to determine positions in plot.
192 * @param theme (optional) theme document 190 * @param theme (optional) theme document
193 */ 191 */
494 textStyle.apply(ta); 492 textStyle.apply(ta);
495 } 493 }
496 ta.setY(area.above(0.05d, ta.getY())); 494 ta.setY(area.above(0.05d, ta.getY()));
497 plot.getRenderer().addAnnotation(ta, org.jfree.ui.Layer.FOREGROUND); 495 plot.getRenderer().addAnnotation(ta, org.jfree.ui.Layer.FOREGROUND);
498 } 496 }
499 497 }
500 // Hyks. 498 }
501 for (HYKFactory.Zone zone: fa.getBoxes()) { 499
502 // For each zone, create a box to fill with color, a box to draw
503 // the lines and a text to display the type.
504 fillPaint = colorForHYKZone(zone.getName());
505
506 XYBoxAnnotation boxA = new XYBoxAnnotation(zone.getFrom(), area.atGround(),
507 zone.getTo(), area.ofGround(0.03f), basicStroke, tranPaint, fillPaint);
508 XYBoxAnnotation boxB = new XYBoxAnnotation(zone.getFrom(), area.atGround(),
509 zone.getTo(), area.atTop(), basicStroke, fillPaint, tranPaint);
510
511 XYTextAnnotation tex = new XYTextAnnotation(zone.getName(),
512 zone.getFrom() + (zone.getTo() - zone.getFrom()) / 1.0d,
513 area.ofGround(0.015f));
514 if (textStyle != null) {
515 textStyle.apply(tex);
516 }
517
518 plot.getRenderer().addAnnotation(boxA, org.jfree.ui.Layer.BACKGROUND);
519 plot.getRenderer().addAnnotation(boxB, org.jfree.ui.Layer.BACKGROUND);
520 plot.getRenderer().addAnnotation(tex, org.jfree.ui.Layer.BACKGROUND);
521 }
522 }
523 }
524
525 500
526 /** 501 /**
527 * This method needs to be implemented by concrete subclasses to create new 502 * This method needs to be implemented by concrete subclasses to create new
528 * instances of JFreeChart. 503 * instances of JFreeChart.
529 * 504 *
623 * 598 *
624 * @param chart The JFreeChart chart object. 599 * @param chart The JFreeChart chart object.
625 */ 600 */
626 protected void addSubtitles(JFreeChart chart) { 601 protected void addSubtitles(JFreeChart chart) {
627 // do nothing 602 // do nothing
628 }
629
630
631 /** Get color for hyk zones by their type (which is the name). */
632 protected Paint colorForHYKZone(String zoneName) {
633 if (zoneName.startsWith("R")) {
634 // Brownish.
635 return new Color(153, 60, 0);
636 }
637 else if (zoneName.startsWith("V")) {
638 // Greenish.
639 return new Color(0, 255, 0);
640 }
641 else if (zoneName.startsWith("B")) {
642 // Grayish.
643 return new Color(128, 128, 128);
644 }
645 else if (zoneName.startsWith("H")) {
646 // Blueish.
647 return new Color(0, 0, 255);
648 }
649 else {
650 // Default.
651 logger.debug("Unknown zone type found.");
652 return new Color(255, 0, 0);
653 }
654 } 603 }
655 604
656 605
657 /** 606 /**
658 * Register annotations like MainValues for later plotting 607 * Register annotations like MainValues for later plotting
685 634
686 if (visible) { 635 if (visible) {
687 addAnnotations(annotations); 636 addAnnotations(annotations);
688 } 637 }
689 } 638 }
690 639
691 640
692 /** 641 /**
693 * Generate chart. 642 * Generate chart.
694 */ 643 */
695 @Override 644 @Override

http://dive4elements.wald.intevation.org