comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java @ 719:035c0095b427

Draw correction curve again. flys-artifacts/trunk@2193 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 21 Jun 2011 21:41:49 +0000
parents 708b270dfd30
children f959faaa7c4a
comparison
equal deleted inserted replaced
718:f3fd8c9b7f51 719:035c0095b427
42 42
43 this.cw = new XYSeriesCollection(); 43 this.cw = new XYSeriesCollection();
44 } 44 }
45 45
46 46
47 @Override
47 public void addDatasets(JFreeChart chart) { 48 public void addDatasets(JFreeChart chart) {
48 super.addDatasets(chart); 49 super.addDatasets(chart);
49 50
50 XYPlot plot = (XYPlot) chart.getPlot(); 51 XYPlot plot = (XYPlot) chart.getPlot();
51 52
52 plot.setDataset(2, cw); 53 plot.setDataset(2, cw);
53 } 54 }
54 55
55 56
57 @Override
56 protected void adjustPlot(XYPlot plot) { 58 protected void adjustPlot(XYPlot plot) {
57 super.adjustPlot(plot); 59 super.adjustPlot(plot);
58 60
59 // TODO REMOVE THIS CODE, IF WE HAVE INTRODUCED THEMES! 61 // TODO REMOVE THIS CODE, IF WE HAVE INTRODUCED THEMES!
60 XYLineAndShapeRenderer rw = (XYLineAndShapeRenderer) 62 XYLineAndShapeRenderer rw = (XYLineAndShapeRenderer)
79 81
80 82
81 protected void adjustAxes(XYPlot plot) { 83 protected void adjustAxes(XYPlot plot) {
82 super.adjustAxes(plot); 84 super.adjustAxes(plot);
83 85
84 plot.mapDatasetToRangeAxis(2, 1); 86 plot.mapDatasetToRangeAxis(2, 0);
85 } 87 }
86 88
87 89
88 90
89 @Override 91 @Override
90 public void doOut(Artifact artifact, Facet facet, Document attr) { 92 public void doOut(Artifact artifact, Facet facet, Document attr) {
91 logger.debug("DischargeLongitudinalSectionGenerator.doOut"); 93 logger.debug("DischargeLongitudinalSectionGenerator.doOut");
92 94
93 String name = facet != null ? facet.getName() : null; 95 if (facet == null) {
96 return;
97 }
98
99 String name = facet.getName();
100
101 if (name == null) {
102 return;
103 }
94 104
95 FLYSArtifact flys = (FLYSArtifact) artifact; 105 FLYSArtifact flys = (FLYSArtifact) artifact;
96 Facet f = flys.getNativeFacet(facet); 106 Facet f = flys.getNativeFacet(facet);
97 107
98 if (name != null && name.equals(DISCHARGE_LONGITUDINAL_W)) { 108 if (name.equals(DISCHARGE_LONGITUDINAL_W)) {
99 doWOut((WQKms) f.getData(artifact, context)); 109 doWOut((WQKms) f.getData(artifact, context));
100 } 110 }
101 else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_Q)) { 111 else if (name.equals(DISCHARGE_LONGITUDINAL_Q)) {
102 doQOut((WQKms) f.getData(artifact, context)); 112 doQOut((WQKms) f.getData(artifact, context));
103 } 113 }
104 else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_C)) { 114 else if (name.equals(DISCHARGE_LONGITUDINAL_C)) {
105 doCorrectedWOut((WQCKms) f.getData(artifact, context)); 115 doCorrectedWOut((WQCKms) f.getData(artifact, context));
106 } 116 }
107 else { 117 else {
108 logger.warn("Unknown facet name: " + name); 118 logger.warn("Unknown facet name: " + name);
109 return;
110 } 119 }
111 } 120 }
112 121
113 122
114 /** 123 /**
117 * @param wqckms The object that contains the corrected W values. 126 * @param wqckms The object that contains the corrected W values.
118 */ 127 */
119 protected void doCorrectedWOut(WQCKms wqckms) { 128 protected void doCorrectedWOut(WQCKms wqckms) {
120 logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut"); 129 logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut");
121 130
122 XYSeries series = new XYSeries(getSeriesNameForCorrected(wqckms, "W")); 131 int size = wqckms.size();
123 132
124 double[] target = new double[4]; 133 if (size > 0) {
125 int size = wqckms.size(); 134 XYSeries series = new XYSeries(getSeriesNameForCorrected(wqckms, "W"));
126 135 for (int i = 0; i < size; i++) {
127 for (int i = 0; i < size; i++) { 136 series.add(wqckms.getKms(i), wqckms.getC(i));
128 target = wqckms.get(i, target); 137 }
129
130 series.add(target[2], target[3]);
131 }
132
133 if (series.getItemCount() > 0) {
134 cw.addSeries(series); 138 cw.addSeries(series);
135 } 139 }
136 } 140 }
137 141
138 142
139 protected String getSeriesNameForCorrected(WQKms wqkms, String mode) { 143 protected String getSeriesNameForCorrected(WQKms wqkms, String mode) {
140 String name = wqkms.getName(); 144 String name = wqkms.getName();
141 145
142 name = name.replace( 146 name = name.replace(
143 "Benutzerdefiniert", 147 "benutzerdefiniert",
144 "Benutzerdefiniert [korrigiert]"); 148 "benutzerdefiniert [korrigiert]");
145 149
146 String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode; 150 String prefix = name.indexOf(mode) >= 0 ? null : mode;
147 151
148 return prefix != null && prefix.length() > 0 152 return prefix != null && prefix.length() > 0
149 ? prefix + "(" + name +")" 153 ? prefix + "(" + name + ")"
150 : name; 154 : name;
151 } 155 }
152 } 156 }
153 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 157 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org