comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java @ 1881:0e9c0b49b4ef

CrossSectionApp: draw ground with StableXYDifferenceRenderer flys-artifacts/trunk@3240 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 12 Nov 2011 12:05:37 +0000
parents 982956bde69e
children eb671699fbc2
comparison
equal deleted inserted replaced
1880:ebd16028efa3 1881:0e9c0b49b4ef
86 import java.io.IOException; 86 import java.io.IOException;
87 import java.io.ObjectInputStream; 87 import java.io.ObjectInputStream;
88 import java.io.ObjectOutputStream; 88 import java.io.ObjectOutputStream;
89 import java.util.Collections; 89 import java.util.Collections;
90 import java.util.LinkedList; 90 import java.util.LinkedList;
91 import java.util.Iterator;
92 91
93 import org.jfree.chart.LegendItem; 92 import org.jfree.chart.LegendItem;
94 import org.jfree.chart.axis.ValueAxis; 93 import org.jfree.chart.axis.ValueAxis;
95 import org.jfree.chart.entity.EntityCollection; 94 import org.jfree.chart.entity.EntityCollection;
96 import org.jfree.chart.entity.XYItemEntity; 95 import org.jfree.chart.entity.XYItemEntity;
137 private boolean shapesVisible; 136 private boolean shapesVisible;
138 137
139 /** The shape to display in the legend item. */ 138 /** The shape to display in the legend item. */
140 private transient Shape legendLine; 139 private transient Shape legendLine;
141 140
142 private XYDatasetToZeroMapper mapper; 141 //private XYDatasetToZeroMapper mapper;
143 142
144 /** 143 /**
145 * This flag controls whether or not the x-coordinates (in Java2D space) 144 * This flag controls whether or not the x-coordinates (in Java2D space)
146 * are rounded to integers. When set to true, this can avoid the vertical 145 * are rounded to integers. When set to true, this can avoid the vertical
147 * striping that anti-aliasing can generate. However, the rounding may not 146 * striping that anti-aliasing can generate. However, the rounding may not
154 153
155 /** 154 /**
156 * Creates a new renderer with default attributes. 155 * Creates a new renderer with default attributes.
157 */ 156 */
158 public StableXYDifferenceRenderer() { 157 public StableXYDifferenceRenderer() {
159 this(Color.green, Color.red, false, null); 158 this(Color.green, Color.red, false /*, null */);
160 } 159 }
161 160
162 /** 161 /**
163 * Creates a new renderer. 162 * Creates a new renderer.
164 * 163 *
167 * @param negativePaint the highlight color for negative differences 166 * @param negativePaint the highlight color for negative differences
168 * (<code>null</code> not permitted). 167 * (<code>null</code> not permitted).
169 * @param shapes draw shapes? 168 * @param shapes draw shapes?
170 */ 169 */
171 public StableXYDifferenceRenderer(Paint positivePaint, Paint negativePaint, 170 public StableXYDifferenceRenderer(Paint positivePaint, Paint negativePaint,
172 boolean shapes, 171 boolean shapes) {
173 XYDatasetToZeroMapper mapper) {
174 if (positivePaint == null) { 172 if (positivePaint == null) {
175 throw new IllegalArgumentException( 173 throw new IllegalArgumentException(
176 "Null 'positivePaint' argument."); 174 "Null 'positivePaint' argument.");
177 } 175 }
178 if (negativePaint == null) { 176 if (negativePaint == null) {
182 this.positivePaint = positivePaint; 180 this.positivePaint = positivePaint;
183 this.negativePaint = negativePaint; 181 this.negativePaint = negativePaint;
184 this.shapesVisible = shapes; 182 this.shapesVisible = shapes;
185 this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); 183 this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0);
186 this.roundXCoordinates = false; 184 this.roundXCoordinates = false;
187 this.mapper = mapper;
188 } 185 }
189 186
190 /** 187 /**
191 * Returns the paint used to highlight positive differences. 188 * Returns the paint used to highlight positive differences.
192 * 189 *
390 XYDataset dataset, 387 XYDataset dataset,
391 int series, 388 int series,
392 int item, 389 int item,
393 CrosshairState crosshairState, 390 CrosshairState crosshairState,
394 int pass) { 391 int pass) {
395 392 switch (pass) {
396 if (mapper == null) { 393 case 0:
397 switch (pass) { 394 drawItemPass0(g2, dataArea, info,
398 case 0: 395 plot, domainAxis, rangeAxis,
399 drawItemPass0(g2, dataArea, info, 396 dataset, series, item, crosshairState);
400 plot, domainAxis, rangeAxis, 397 break;
401 dataset, series, item, crosshairState); 398 case 1:
402 break; 399 drawItemPass1(g2, dataArea, info,
403 case 1: 400 plot, domainAxis, rangeAxis,
404 drawItemPass1(g2, dataArea, info, 401 dataset, series, item, crosshairState);
405 plot, domainAxis, rangeAxis, 402 }
406 dataset, series, item, crosshairState);
407 }
408 }
409 else {
410 for (Iterator<XYDataset> iter = mapper.iterator(dataset);
411 iter.hasNext();
412 ) {
413 switch (pass) {
414 case 0:
415 drawItemPass0(g2, dataArea, info,
416 plot, domainAxis, rangeAxis,
417 dataset, series, item, crosshairState);
418 break;
419 case 1:
420 drawItemPass1(g2, dataArea, info,
421 plot, domainAxis, rangeAxis,
422 dataset, series, item, crosshairState);
423 }
424 } // for all segments
425 }
426
427 } 403 }
428 404
429 /** 405 /**
430 * Draws the visual representation of a single data item, first pass. 406 * Draws the visual representation of a single data item, first pass.
431 * 407 *

http://dive4elements.wald.intevation.org