comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java @ 2021:1ae17b100973

Let StableDifferenceRenderer create a rectangular legenditem. flys-artifacts/trunk@3476 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 20 Dec 2011 06:50:06 +0000
parents 110dd067bb8f
children fd95bfbb2ec2
comparison
equal deleted inserted replaced
2020:4f7f781e4481 2021:1ae17b100973
69 * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); 69 * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG);
70 * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); 70 * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG);
71 * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); 71 * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG);
72 * 05-Nov-2007 : Draw item labels if visible (RW); 72 * 05-Nov-2007 : Draw item labels if visible (RW);
73 * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); 73 * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG);
74 * 74 */
75 /*
76 * For further changes within the FLYS project, refer to the ChangeLog.
75 */ 77 */
76 package de.intevation.flys.jfree; 78 package de.intevation.flys.jfree;
77 79
78 import java.awt.Color; 80 import java.awt.Color;
79 import java.awt.Graphics2D; 81 import java.awt.Graphics2D;
141 143
142 /** Display shapes at each point? */ 144 /** Display shapes at each point? */
143 private boolean shapesVisible; 145 private boolean shapesVisible;
144 146
145 /** The shape to display in the legend item. */ 147 /** The shape to display in the legend item. */
146 private transient Shape legendLine; 148 private transient Shape legendShape;
147 149
148 //private XYDatasetToZeroMapper mapper; 150 //private XYDatasetToZeroMapper mapper;
149 151
150 /** 152 /**
151 * This flag controls whether or not the x-coordinates (in Java2D space) 153 * This flag controls whether or not the x-coordinates (in Java2D space)
185 "Null 'negativePaint' argument."); 187 "Null 'negativePaint' argument.");
186 } 188 }
187 this.positivePaint = positivePaint; 189 this.positivePaint = positivePaint;
188 this.negativePaint = negativePaint; 190 this.negativePaint = negativePaint;
189 this.shapesVisible = shapes; 191 this.shapesVisible = shapes;
190 this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); 192 this.legendShape = new Rectangle2D.Double(-3.0, -3.0, 10.0, 10.0);
191 this.roundXCoordinates = false; 193 this.roundXCoordinates = false;
192 } 194 }
193 195
194 /** 196 /**
195 * Returns the paint used to highlight positive differences. 197 * Returns the paint used to highlight positive differences.
276 * @return The legend line (never <code>null</code>). 278 * @return The legend line (never <code>null</code>).
277 * 279 *
278 * @see #setLegendLine(Shape) 280 * @see #setLegendLine(Shape)
279 */ 281 */
280 public Shape getLegendLine() { 282 public Shape getLegendLine() {
281 return this.legendLine; 283 return this.legendShape;
282 } 284 }
283 285
284 /** 286 /**
285 * Sets the shape used as a line in each legend item and sends a 287 * Sets the shape used as a line in each legend item and sends a
286 * {@link RendererChangeEvent} to all registered listeners. 288 * {@link RendererChangeEvent} to all registered listeners.
291 */ 293 */
292 public void setLegendLine(Shape line) { 294 public void setLegendLine(Shape line) {
293 if (line == null) { 295 if (line == null) {
294 throw new IllegalArgumentException("Null 'line' argument."); 296 throw new IllegalArgumentException("Null 'line' argument.");
295 } 297 }
296 this.legendLine = line; 298 this.legendShape = line;
297 fireChangeEvent(); 299 fireChangeEvent();
298 } 300 }
299 301
300 /** 302 /**
301 * Returns the flag that controls whether or not the x-coordinates (in 303 * Returns the flag that controls whether or not the x-coordinates (in
1436 String urlText = null; 1438 String urlText = null;
1437 if (getLegendItemURLGenerator() != null) { 1439 if (getLegendItemURLGenerator() != null) {
1438 urlText = getLegendItemURLGenerator().generateLabel( 1440 urlText = getLegendItemURLGenerator().generateLabel(
1439 dataset, series); 1441 dataset, series);
1440 } 1442 }
1441 Paint paint = lookupSeriesPaint(series); 1443 // Individualized Paints:
1444 //Paint paint = lookupSeriesPaint(series);
1445
1446 // "Area-Style"- Paint.
1447 Paint paint = getPositivePaint();
1442 Stroke stroke = lookupSeriesStroke(series); 1448 Stroke stroke = lookupSeriesStroke(series);
1443 Shape line = getLegendLine(); 1449 Shape line = getLegendLine();
1450 // Not-filled Shape:
1451 //result = new LegendItem(label, description,
1452 // toolTipText, urlText, line, stroke, paint);
1453
1454 // Filled Shape ("Area-Style").
1444 result = new LegendItem(label, description, 1455 result = new LegendItem(label, description,
1445 toolTipText, urlText, line, stroke, paint); 1456 toolTipText, urlText, line, paint);
1446 result.setLabelFont(lookupLegendTextFont(series)); 1457 result.setLabelFont(lookupLegendTextFont(series));
1447 Paint labelPaint = lookupLegendTextPaint(series); 1458 Paint labelPaint = lookupLegendTextPaint(series);
1448 if (labelPaint != null) { 1459 if (labelPaint != null) {
1449 result.setLabelPaint(labelPaint); 1460 result.setLabelPaint(labelPaint);
1450 } 1461 }
1456 } 1467 }
1457 1468
1458 } 1469 }
1459 1470
1460 return result; 1471 return result;
1461
1462 } 1472 }
1463 1473
1464 /** 1474 /**
1465 * Tests this renderer for equality with an arbitrary object. 1475 * Tests this renderer for equality with an arbitrary object.
1466 * 1476 *
1486 return false; 1496 return false;
1487 } 1497 }
1488 if (this.shapesVisible != that.shapesVisible) { 1498 if (this.shapesVisible != that.shapesVisible) {
1489 return false; 1499 return false;
1490 } 1500 }
1491 if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { 1501 if (!ShapeUtilities.equal(this.legendShape, that.legendShape)) {
1492 return false; 1502 return false;
1493 } 1503 }
1494 if (this.roundXCoordinates != that.roundXCoordinates) { 1504 if (this.roundXCoordinates != that.roundXCoordinates) {
1495 return false; 1505 return false;
1496 } 1506 }
1504 * 1514 *
1505 * @throws CloneNotSupportedException if the renderer cannot be cloned. 1515 * @throws CloneNotSupportedException if the renderer cannot be cloned.
1506 */ 1516 */
1507 public Object clone() throws CloneNotSupportedException { 1517 public Object clone() throws CloneNotSupportedException {
1508 StableXYDifferenceRenderer clone = (StableXYDifferenceRenderer) super.clone(); 1518 StableXYDifferenceRenderer clone = (StableXYDifferenceRenderer) super.clone();
1509 clone.legendLine = ShapeUtilities.clone(this.legendLine); 1519 clone.legendShape = ShapeUtilities.clone(this.legendShape);
1510 return clone; 1520 return clone;
1511 } 1521 }
1512 1522
1513 /** 1523 /**
1514 * Provides serialization support. 1524 * Provides serialization support.
1519 */ 1529 */
1520 private void writeObject(ObjectOutputStream stream) throws IOException { 1530 private void writeObject(ObjectOutputStream stream) throws IOException {
1521 stream.defaultWriteObject(); 1531 stream.defaultWriteObject();
1522 SerialUtilities.writePaint(this.positivePaint, stream); 1532 SerialUtilities.writePaint(this.positivePaint, stream);
1523 SerialUtilities.writePaint(this.negativePaint, stream); 1533 SerialUtilities.writePaint(this.negativePaint, stream);
1524 SerialUtilities.writeShape(this.legendLine, stream); 1534 SerialUtilities.writeShape(this.legendShape, stream);
1525 } 1535 }
1526 1536
1527 /** 1537 /**
1528 * Provides serialization support. 1538 * Provides serialization support.
1529 * 1539 *
1535 private void readObject(ObjectInputStream stream) 1545 private void readObject(ObjectInputStream stream)
1536 throws IOException, ClassNotFoundException { 1546 throws IOException, ClassNotFoundException {
1537 stream.defaultReadObject(); 1547 stream.defaultReadObject();
1538 this.positivePaint = SerialUtilities.readPaint(stream); 1548 this.positivePaint = SerialUtilities.readPaint(stream);
1539 this.negativePaint = SerialUtilities.readPaint(stream); 1549 this.negativePaint = SerialUtilities.readPaint(stream);
1540 this.legendLine = SerialUtilities.readShape(stream); 1550 this.legendShape = SerialUtilities.readShape(stream);
1541 } 1551 }
1542 } 1552 }

http://dive4elements.wald.intevation.org