comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java @ 924:f7761914f745

An initial implementation to render chart series based on the XML configuration in themes.xml. flys-artifacts/trunk@2276 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 01 Jul 2011 14:46:13 +0000
parents 7ca4a287cd0e
children 0cb1a70b8b92
comparison
equal deleted inserted replaced
923:7ca4a287cd0e 924:f7761914f745
1 package de.intevation.flys.exports; 1 package de.intevation.flys.exports;
2
3 import java.awt.Color;
4 2
5 import org.apache.log4j.Logger; 3 import org.apache.log4j.Logger;
6 4
7 import org.jfree.chart.plot.XYPlot;
8 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
9 import org.jfree.data.xy.XYSeries; 5 import org.jfree.data.xy.XYSeries;
10 6
11 import org.w3c.dom.Document; 7 import org.w3c.dom.Document;
12 8
13 import de.intevation.artifacts.Artifact; 9 import de.intevation.artifacts.Artifact;
36 super(); 32 super();
37 } 33 }
38 34
39 35
40 @Override 36 @Override
41 protected void adjustPlot(XYPlot plot) {
42 super.adjustPlot(plot);
43
44 //// TODO REMOVE THIS CODE, IF WE HAVE INTRODUCED THEMES!
45 //XYLineAndShapeRenderer rw = (XYLineAndShapeRenderer)
46 // plot.getRendererForDataset(w);
47
48 //XYLineAndShapeRenderer rcw = null;
49 //try {
50 // rcw = (XYLineAndShapeRenderer) rw.clone();
51 //}
52 //catch (Exception e) {
53 // logger.error(e, e);
54 //}
55
56 //int cwNum = cw.getSeriesCount();
57
58 //for (int i = 0; i < cwNum; i++) {
59 // rcw.setSeriesPaint(i, Color.RED);
60 //}
61
62 //plot.setRenderer(2, rcw);
63 }
64
65
66 @Override
67 public void doOut(Artifact artifact, Facet facet, Document attr) { 37 public void doOut(Artifact artifact, Facet facet, Document attr) {
68 logger.debug("DischargeLongitudinalSectionGenerator.doOut"); 38 logger.debug("DischargeLongitudinalSectionGenerator.doOut");
69 39
70 if (facet == null) { 40 if (facet == null) {
71 return; 41 return;
79 49
80 FLYSArtifact flys = (FLYSArtifact) artifact; 50 FLYSArtifact flys = (FLYSArtifact) artifact;
81 Facet f = flys.getNativeFacet(facet); 51 Facet f = flys.getNativeFacet(facet);
82 52
83 if (name.equals(DISCHARGE_LONGITUDINAL_W)) { 53 if (name.equals(DISCHARGE_LONGITUDINAL_W)) {
84 doWOut((WQKms) f.getData(artifact, context)); 54 doWOut((WQKms) f.getData(artifact, context), attr);
85 } 55 }
86 else if (name.equals(DISCHARGE_LONGITUDINAL_Q)) { 56 else if (name.equals(DISCHARGE_LONGITUDINAL_Q)) {
87 doQOut((WQKms) f.getData(artifact, context)); 57 doQOut((WQKms) f.getData(artifact, context), attr);
88 } 58 }
89 else if (name.equals(DISCHARGE_LONGITUDINAL_C)) { 59 else if (name.equals(DISCHARGE_LONGITUDINAL_C)) {
90 doCorrectedWOut((WQCKms) f.getData(artifact, context)); 60 doCorrectedWOut((WQCKms) f.getData(artifact, context), attr);
91 } 61 }
92 else { 62 else {
93 logger.warn("Unknown facet name: " + name); 63 logger.warn("Unknown facet name: " + name);
94 } 64 }
95 } 65 }
97 67
98 /** 68 /**
99 * Adds a new series for the corrected W curve. 69 * Adds a new series for the corrected W curve.
100 * 70 *
101 * @param wqckms The object that contains the corrected W values. 71 * @param wqckms The object that contains the corrected W values.
72 * @param theme The theme that contains styling information.
102 */ 73 */
103 protected void doCorrectedWOut(WQCKms wqckms) { 74 protected void doCorrectedWOut(WQCKms wqckms, Document theme) {
104 logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut"); 75 logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut");
105 76
106 int size = wqckms.size(); 77 int size = wqckms.size();
107 78
108 if (size > 0) { 79 if (size > 0) {
109 XYSeries series = new XYSeries(getSeriesNameForCorrected(wqckms, "W")); 80 XYSeries series = new StyledXYSeries(
81 getSeriesNameForCorrected(wqckms, "W"),
82 theme);
83
110 for (int i = 0; i < size; i++) { 84 for (int i = 0; i < size; i++) {
111 series.add(wqckms.getKms(i), wqckms.getC(i)); 85 series.add(wqckms.getKms(i), wqckms.getC(i));
112 } 86 }
113 87
114 addFirstAxisSeries(series); 88 addFirstAxisSeries(series);

http://dive4elements.wald.intevation.org