1:
188:
189: package ;
190:
191: import ;
192: import ;
193: import ;
194: import ;
195: import ;
196: import ;
197: import ;
198: import ;
199: import ;
200: import ;
201: import ;
202: import ;
203: import ;
204: import ;
205: import ;
206: import ;
207: import ;
208: import ;
209: import ;
210: import ;
211: import ;
212: import ;
213: import ;
214: import ;
215: import ;
216:
217: import ;
218: import ;
219: import ;
220: import ;
221: import ;
222: import ;
223: import ;
224: import ;
225: import ;
226: import ;
227: import ;
228: import ;
229: import ;
230: import ;
231: import ;
232: import ;
233: import ;
234: import ;
235: import ;
236: import ;
237: import ;
238: import ;
239: import ;
240: import ;
241: import ;
242: import ;
243: import ;
244: import ;
245: import ;
246: import ;
247:
248:
259: public class XYPlot extends Plot implements ValueAxisPlot,
260: Zoomable,
261: RendererChangeListener,
262: Cloneable, PublicCloneable,
263: Serializable {
264:
265:
266: private static final long serialVersionUID = 7044148245716569264L;
267:
268:
269: public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f,
270: BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f,
271: new float[] {2.0f, 2.0f}, 0.0f);
272:
273:
274: public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray;
275:
276:
277: public static final boolean DEFAULT_CROSSHAIR_VISIBLE = false;
278:
279:
280: public static final Stroke DEFAULT_CROSSHAIR_STROKE
281: = DEFAULT_GRIDLINE_STROKE;
282:
283:
284: public static final Paint DEFAULT_CROSSHAIR_PAINT = Color.blue;
285:
286:
287: protected static ResourceBundle localizationResources
288: = ResourceBundle.getBundle(
289: "org.jfree.chart.plot.LocalizationBundle");
290:
291:
292: private PlotOrientation orientation;
293:
294:
295: private RectangleInsets axisOffset;
296:
297:
298: private ObjectList domainAxes;
299:
300:
301: private ObjectList domainAxisLocations;
302:
303:
304: private ObjectList rangeAxes;
305:
306:
307: private ObjectList rangeAxisLocations;
308:
309:
310: private ObjectList datasets;
311:
312:
313: private ObjectList renderers;
314:
315:
320: private Map datasetToDomainAxisMap;
321:
322:
327: private Map datasetToRangeAxisMap;
328:
329:
330: private transient Point2D quadrantOrigin = new Point2D.Double(0.0, 0.0);
331:
332:
333: private transient Paint[] quadrantPaint
334: = new Paint[] {null, null, null, null};
335:
336:
337: private boolean domainGridlinesVisible;
338:
339:
340: private transient Stroke domainGridlineStroke;
341:
342:
343: private transient Paint domainGridlinePaint;
344:
345:
346: private boolean rangeGridlinesVisible;
347:
348:
349: private transient Stroke rangeGridlineStroke;
350:
351:
352: private transient Paint rangeGridlinePaint;
353:
354:
360: private boolean domainZeroBaselineVisible;
361:
362:
367: private transient Stroke domainZeroBaselineStroke;
368:
369:
374: private transient Paint domainZeroBaselinePaint;
375:
376:
380: private boolean rangeZeroBaselineVisible;
381:
382:
383: private transient Stroke rangeZeroBaselineStroke;
384:
385:
386: private transient Paint rangeZeroBaselinePaint;
387:
388:
389: private boolean domainCrosshairVisible;
390:
391:
392: private double domainCrosshairValue;
393:
394:
395: private transient Stroke domainCrosshairStroke;
396:
397:
398: private transient Paint domainCrosshairPaint;
399:
400:
404: private boolean domainCrosshairLockedOnData = true;
405:
406:
407: private boolean rangeCrosshairVisible;
408:
409:
410: private double rangeCrosshairValue;
411:
412:
413: private transient Stroke rangeCrosshairStroke;
414:
415:
416: private transient Paint rangeCrosshairPaint;
417:
418:
422: private boolean rangeCrosshairLockedOnData = true;
423:
424:
425: private Map foregroundDomainMarkers;
426:
427:
428: private Map backgroundDomainMarkers;
429:
430:
431: private Map foregroundRangeMarkers;
432:
433:
434: private Map backgroundRangeMarkers;
435:
436:
441: private List annotations;
442:
443:
444: private transient Paint domainTickBandPaint;
445:
446:
447: private transient Paint rangeTickBandPaint;
448:
449:
450: private AxisSpace fixedDomainAxisSpace;
451:
452:
453: private AxisSpace fixedRangeAxisSpace;
454:
455:
459: private DatasetRenderingOrder datasetRenderingOrder
460: = DatasetRenderingOrder.REVERSE;
461:
462:
466: private SeriesRenderingOrder seriesRenderingOrder
467: = SeriesRenderingOrder.REVERSE;
468:
469:
473: private int weight;
474:
475:
479: private LegendItemCollection fixedLegendItems;
480:
481:
485: public XYPlot() {
486: this(null, null, null, null);
487: }
488:
489:
500: public XYPlot(XYDataset dataset,
501: ValueAxis domainAxis,
502: ValueAxis rangeAxis,
503: XYItemRenderer renderer) {
504:
505: super();
506:
507: this.orientation = PlotOrientation.VERTICAL;
508: this.weight = 1;
509: this.axisOffset = RectangleInsets.ZERO_INSETS;
510:
511:
512: this.domainAxes = new ObjectList();
513: this.domainAxisLocations = new ObjectList();
514: this.foregroundDomainMarkers = new HashMap();
515: this.backgroundDomainMarkers = new HashMap();
516:
517: this.rangeAxes = new ObjectList();
518: this.rangeAxisLocations = new ObjectList();
519: this.foregroundRangeMarkers = new HashMap();
520: this.backgroundRangeMarkers = new HashMap();
521:
522: this.datasets = new ObjectList();
523: this.renderers = new ObjectList();
524:
525: this.datasetToDomainAxisMap = new TreeMap();
526: this.datasetToRangeAxisMap = new TreeMap();
527:
528: this.datasets.set(0, dataset);
529: if (dataset != null) {
530: dataset.addChangeListener(this);
531: }
532:
533: this.renderers.set(0, renderer);
534: if (renderer != null) {
535: renderer.setPlot(this);
536: renderer.addChangeListener(this);
537: }
538:
539: this.domainAxes.set(0, domainAxis);
540: this.mapDatasetToDomainAxis(0, 0);
541: if (domainAxis != null) {
542: domainAxis.setPlot(this);
543: domainAxis.addChangeListener(this);
544: }
545: this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT);
546:
547: this.rangeAxes.set(0, rangeAxis);
548: this.mapDatasetToRangeAxis(0, 0);
549: if (rangeAxis != null) {
550: rangeAxis.setPlot(this);
551: rangeAxis.addChangeListener(this);
552: }
553: this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT);
554:
555: configureDomainAxes();
556: configureRangeAxes();
557:
558: this.domainGridlinesVisible = true;
559: this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE;
560: this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT;
561:
562: this.domainZeroBaselineVisible = false;
563: this.domainZeroBaselinePaint = Color.black;
564: this.domainZeroBaselineStroke = new BasicStroke(0.5f);
565:
566: this.rangeGridlinesVisible = true;
567: this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE;
568: this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT;
569:
570: this.rangeZeroBaselineVisible = false;
571: this.rangeZeroBaselinePaint = Color.black;
572: this.rangeZeroBaselineStroke = new BasicStroke(0.5f);
573:
574: this.domainCrosshairVisible = false;
575: this.domainCrosshairValue = 0.0;
576: this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
577: this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;
578:
579: this.rangeCrosshairVisible = false;
580: this.rangeCrosshairValue = 0.0;
581: this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
582: this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;
583:
584: this.annotations = new java.util.ArrayList();
585:
586: }
587:
588:
593: public String getPlotType() {
594: return localizationResources.getString("XY_Plot");
595: }
596:
597:
604: public PlotOrientation getOrientation() {
605: return this.orientation;
606: }
607:
608:
616: public void setOrientation(PlotOrientation orientation) {
617: if (orientation == null) {
618: throw new IllegalArgumentException("Null 'orientation' argument.");
619: }
620: if (orientation != this.orientation) {
621: this.orientation = orientation;
622: notifyListeners(new PlotChangeEvent(this));
623: }
624: }
625:
626:
633: public RectangleInsets getAxisOffset() {
634: return this.axisOffset;
635: }
636:
637:
645: public void setAxisOffset(RectangleInsets offset) {
646: if (offset == null) {
647: throw new IllegalArgumentException("Null 'offset' argument.");
648: }
649: this.axisOffset = offset;
650: notifyListeners(new PlotChangeEvent(this));
651: }
652:
653:
663: public ValueAxis getDomainAxis() {
664: return getDomainAxis(0);
665: }
666:
667:
676: public ValueAxis getDomainAxis(int index) {
677: ValueAxis result = null;
678: if (index < this.domainAxes.size()) {
679: result = (ValueAxis) this.domainAxes.get(index);
680: }
681: if (result == null) {
682: Plot parent = getParent();
683: if (parent instanceof XYPlot) {
684: XYPlot xy = (XYPlot) parent;
685: result = xy.getDomainAxis(index);
686: }
687: }
688: return result;
689: }
690:
691:
700: public void setDomainAxis(ValueAxis axis) {
701: setDomainAxis(0, axis);
702: }
703:
704:
714: public void setDomainAxis(int index, ValueAxis axis) {
715: setDomainAxis(index, axis, true);
716: }
717:
718:
728: public void setDomainAxis(int index, ValueAxis axis, boolean notify) {
729: ValueAxis existing = getDomainAxis(index);
730: if (existing != null) {
731: existing.removeChangeListener(this);
732: }
733: if (axis != null) {
734: axis.setPlot(this);
735: }
736: this.domainAxes.set(index, axis);
737: if (axis != null) {
738: axis.configure();
739: axis.addChangeListener(this);
740: }
741: if (notify) {
742: notifyListeners(new PlotChangeEvent(this));
743: }
744: }
745:
746:
754: public void setDomainAxes(ValueAxis[] axes) {
755: for (int i = 0; i < axes.length; i++) {
756: setDomainAxis(i, axes[i], false);
757: }
758: notifyListeners(new PlotChangeEvent(this));
759: }
760:
761:
768: public AxisLocation getDomainAxisLocation() {
769: return (AxisLocation) this.domainAxisLocations.get(0);
770: }
771:
772:
780: public void setDomainAxisLocation(AxisLocation location) {
781:
782: setDomainAxisLocation(0, location, true);
783: }
784:
785:
794: public void setDomainAxisLocation(AxisLocation location, boolean notify) {
795:
796: setDomainAxisLocation(0, location, notify);
797: }
798:
799:
808: public RectangleEdge getDomainAxisEdge() {
809: return Plot.resolveDomainAxisLocation(getDomainAxisLocation(),
810: this.orientation);
811: }
812:
813:
820: public int getDomainAxisCount() {
821: return this.domainAxes.size();
822: }
823:
824:
830: public void clearDomainAxes() {
831: for (int i = 0; i < this.domainAxes.size(); i++) {
832: ValueAxis axis = (ValueAxis) this.domainAxes.get(i);
833: if (axis != null) {
834: axis.removeChangeListener(this);
835: }
836: }
837: this.domainAxes.clear();
838: notifyListeners(new PlotChangeEvent(this));
839: }
840:
841:
844: public void configureDomainAxes() {
845: for (int i = 0; i < this.domainAxes.size(); i++) {
846: ValueAxis axis = (ValueAxis) this.domainAxes.get(i);
847: if (axis != null) {
848: axis.configure();
849: }
850: }
851: }
852:
853:
864: public AxisLocation getDomainAxisLocation(int index) {
865: AxisLocation result = null;
866: if (index < this.domainAxisLocations.size()) {
867: result = (AxisLocation) this.domainAxisLocations.get(index);
868: }
869: if (result == null) {
870: result = AxisLocation.getOpposite(getDomainAxisLocation());
871: }
872: return result;
873: }
874:
875:
885: public void setDomainAxisLocation(int index, AxisLocation location) {
886:
887: setDomainAxisLocation(index, location, true);
888: }
889:
890:
904: public void setDomainAxisLocation(int index, AxisLocation location,
905: boolean notify) {
906:
907: if (index == 0 && location == null) {
908: throw new IllegalArgumentException(
909: "Null 'location' for index 0 not permitted.");
910: }
911: this.domainAxisLocations.set(index, location);
912: if (notify) {
913: notifyListeners(new PlotChangeEvent(this));
914: }
915: }
916:
917:
926: public RectangleEdge getDomainAxisEdge(int index) {
927: AxisLocation location = getDomainAxisLocation(index);
928: RectangleEdge result = Plot.resolveDomainAxisLocation(location,
929: this.orientation);
930: if (result == null) {
931: result = RectangleEdge.opposite(getDomainAxisEdge());
932: }
933: return result;
934: }
935:
936:
946: public ValueAxis getRangeAxis() {
947: return getRangeAxis(0);
948: }
949:
950:
959: public void setRangeAxis(ValueAxis axis) {
960:
961: if (axis != null) {
962: axis.setPlot(this);
963: }
964:
965:
966: ValueAxis existing = getRangeAxis();
967: if (existing != null) {
968: existing.removeChangeListener(this);
969: }
970:
971: this.rangeAxes.set(0, axis);
972: if (axis != null) {
973: axis.configure();
974: axis.addChangeListener(this);
975: }
976: notifyListeners(new PlotChangeEvent(this));
977:
978: }
979:
980:
987: public AxisLocation getRangeAxisLocation() {
988: return (AxisLocation) this.rangeAxisLocations.get(0);
989: }
990:
991:
999: public void setRangeAxisLocation(AxisLocation location) {
1000:
1001: setRangeAxisLocation(0, location, true);
1002: }
1003:
1004:
1013: public void setRangeAxisLocation(AxisLocation location, boolean notify) {
1014:
1015: setRangeAxisLocation(0, location, notify);
1016: }
1017:
1018:
1026: public RectangleEdge getRangeAxisEdge() {
1027: return Plot.resolveRangeAxisLocation(getRangeAxisLocation(),
1028: this.orientation);
1029: }
1030:
1031:
1040: public ValueAxis getRangeAxis(int index) {
1041: ValueAxis result = null;
1042: if (index < this.rangeAxes.size()) {
1043: result = (ValueAxis) this.rangeAxes.get(index);
1044: }
1045: if (result == null) {
1046: Plot parent = getParent();
1047: if (parent instanceof XYPlot) {
1048: XYPlot xy = (XYPlot) parent;
1049: result = xy.getRangeAxis(index);
1050: }
1051: }
1052: return result;
1053: }
1054:
1055:
1064: public void setRangeAxis(int index, ValueAxis axis) {
1065: setRangeAxis(index, axis, true);
1066: }
1067:
1068:
1078: public void setRangeAxis(int index, ValueAxis axis, boolean notify) {
1079: ValueAxis existing = getRangeAxis(index);
1080: if (existing != null) {
1081: existing.removeChangeListener(this);
1082: }
1083: if (axis != null) {
1084: axis.setPlot(this);
1085: }
1086: this.rangeAxes.set(index, axis);
1087: if (axis != null) {
1088: axis.configure();
1089: axis.addChangeListener(this);
1090: }
1091: if (notify) {
1092: notifyListeners(new PlotChangeEvent(this));
1093: }
1094: }
1095:
1096:
1104: public void setRangeAxes(ValueAxis[] axes) {
1105: for (int i = 0; i < axes.length; i++) {
1106: setRangeAxis(i, axes[i], false);
1107: }
1108: notifyListeners(new PlotChangeEvent(this));
1109: }
1110:
1111:
1118: public int getRangeAxisCount() {
1119: return this.rangeAxes.size();
1120: }
1121:
1122:
1128: public void clearRangeAxes() {
1129: for (int i = 0; i < this.rangeAxes.size(); i++) {
1130: ValueAxis axis = (ValueAxis) this.rangeAxes.get(i);
1131: if (axis != null) {
1132: axis.removeChangeListener(this);
1133: }
1134: }
1135: this.rangeAxes.clear();
1136: notifyListeners(new PlotChangeEvent(this));
1137: }
1138:
1139:
1144: public void configureRangeAxes() {
1145: for (int i = 0; i < this.rangeAxes.size(); i++) {
1146: ValueAxis axis = (ValueAxis) this.rangeAxes.get(i);
1147: if (axis != null) {
1148: axis.configure();
1149: }
1150: }
1151: }
1152:
1153:
1164: public AxisLocation getRangeAxisLocation(int index) {
1165: AxisLocation result = null;
1166: if (index < this.rangeAxisLocations.size()) {
1167: result = (AxisLocation) this.rangeAxisLocations.get(index);
1168: }
1169: if (result == null) {
1170: result = AxisLocation.getOpposite(getRangeAxisLocation());
1171: }
1172: return result;
1173: }
1174:
1175:
1184: public void setRangeAxisLocation(int index, AxisLocation location) {
1185:
1186: setRangeAxisLocation(index, location, true);
1187: }
1188:
1189:
1203: public void setRangeAxisLocation(int index, AxisLocation location,
1204: boolean notify) {
1205:
1206: if (index == 0 && location == null) {
1207: throw new IllegalArgumentException(
1208: "Null 'location' for index 0 not permitted.");
1209: }
1210: this.rangeAxisLocations.set(index, location);
1211: if (notify) {
1212: notifyListeners(new PlotChangeEvent(this));
1213: }
1214: }
1215:
1216:
1226: public RectangleEdge getRangeAxisEdge(int index) {
1227: AxisLocation location = getRangeAxisLocation(index);
1228: RectangleEdge result = Plot.resolveRangeAxisLocation(location,
1229: this.orientation);
1230: if (result == null) {
1231: result = RectangleEdge.opposite(getRangeAxisEdge());
1232: }
1233: return result;
1234: }
1235:
1236:
1244: public XYDataset getDataset() {
1245: return getDataset(0);
1246: }
1247:
1248:
1257: public XYDataset getDataset(int index) {
1258: XYDataset result = null;
1259: if (this.datasets.size() > index) {
1260: result = (XYDataset) this.datasets.get(index);
1261: }
1262: return result;
1263: }
1264:
1265:
1274: public void setDataset(XYDataset dataset) {
1275: setDataset(0, dataset);
1276: }
1277:
1278:
1286: public void setDataset(int index, XYDataset dataset) {
1287: XYDataset existing = getDataset(index);
1288: if (existing != null) {
1289: existing.removeChangeListener(this);
1290: }
1291: this.datasets.set(index, dataset);
1292: if (dataset != null) {
1293: dataset.addChangeListener(this);
1294: }
1295:
1296:
1297: DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
1298: datasetChanged(event);
1299: }
1300:
1301:
1306: public int getDatasetCount() {
1307: return this.datasets.size();
1308: }
1309:
1310:
1318: public int indexOf(XYDataset dataset) {
1319: int result = -1;
1320: for (int i = 0; i < this.datasets.size(); i++) {
1321: if (dataset == this.datasets.get(i)) {
1322: result = i;
1323: break;
1324: }
1325: }
1326: return result;
1327: }
1328:
1329:
1338: public void mapDatasetToDomainAxis(int index, int axisIndex) {
1339: this.datasetToDomainAxisMap.put(new Integer(index),
1340: new Integer(axisIndex));
1341:
1342: datasetChanged(new DatasetChangeEvent(this, getDataset(index)));
1343: }
1344:
1345:
1354: public void mapDatasetToRangeAxis(int index, int axisIndex) {
1355: this.datasetToRangeAxisMap.put(new Integer(index),
1356: new Integer(axisIndex));
1357:
1358: datasetChanged(new DatasetChangeEvent(this, getDataset(index)));
1359: }
1360:
1361:
1368: public XYItemRenderer getRenderer() {
1369: return getRenderer(0);
1370: }
1371:
1372:
1381: public XYItemRenderer getRenderer(int index) {
1382: XYItemRenderer result = null;
1383: if (this.renderers.size() > index) {
1384: result = (XYItemRenderer) this.renderers.get(index);
1385: }
1386: return result;
1387:
1388: }
1389:
1390:
1399: public void setRenderer(XYItemRenderer renderer) {
1400: setRenderer(0, renderer);
1401: }
1402:
1403:
1412: public void setRenderer(int index, XYItemRenderer renderer) {
1413: setRenderer(index, renderer, true);
1414: }
1415:
1416:
1426: public void setRenderer(int index, XYItemRenderer renderer,
1427: boolean notify) {
1428: XYItemRenderer existing = getRenderer(index);
1429: if (existing != null) {
1430: existing.removeChangeListener(this);
1431: }
1432: this.renderers.set(index, renderer);
1433: if (renderer != null) {
1434: renderer.setPlot(this);
1435: renderer.addChangeListener(this);
1436: }
1437: configureDomainAxes();
1438: configureRangeAxes();
1439: if (notify) {
1440: notifyListeners(new PlotChangeEvent(this));
1441: }
1442: }
1443:
1444:
1450: public void setRenderers(XYItemRenderer[] renderers) {
1451: for (int i = 0; i < renderers.length; i++) {
1452: setRenderer(i, renderers[i], false);
1453: }
1454: notifyListeners(new PlotChangeEvent(this));
1455: }
1456:
1457:
1464: public DatasetRenderingOrder getDatasetRenderingOrder() {
1465: return this.datasetRenderingOrder;
1466: }
1467:
1468:
1478: public void setDatasetRenderingOrder(DatasetRenderingOrder order) {
1479: if (order == null) {
1480: throw new IllegalArgumentException("Null 'order' argument.");
1481: }
1482: this.datasetRenderingOrder = order;
1483: notifyListeners(new PlotChangeEvent(this));
1484: }
1485:
1486:
1493: public SeriesRenderingOrder getSeriesRenderingOrder() {
1494: return this.seriesRenderingOrder;
1495: }
1496:
1497:
1507: public void setSeriesRenderingOrder(SeriesRenderingOrder order) {
1508: if (order == null) {
1509: throw new IllegalArgumentException("Null 'order' argument.");
1510: }
1511: this.seriesRenderingOrder = order;
1512: notifyListeners(new PlotChangeEvent(this));
1513: }
1514:
1515:
1523: public int getIndexOf(XYItemRenderer renderer) {
1524: return this.renderers.indexOf(renderer);
1525: }
1526:
1527:
1536: public XYItemRenderer getRendererForDataset(XYDataset dataset) {
1537: XYItemRenderer result = null;
1538: for (int i = 0; i < this.datasets.size(); i++) {
1539: if (this.datasets.get(i) == dataset) {
1540: result = (XYItemRenderer) this.renderers.get(i);
1541: if (result == null) {
1542: result = getRenderer();
1543: }
1544: break;
1545: }
1546: }
1547: return result;
1548: }
1549:
1550:
1558: public int getWeight() {
1559: return this.weight;
1560: }
1561:
1562:
1570: public void setWeight(int weight) {
1571: this.weight = weight;
1572: notifyListeners(new PlotChangeEvent(this));
1573: }
1574:
1575:
1583: public boolean isDomainGridlinesVisible() {
1584: return this.domainGridlinesVisible;
1585: }
1586:
1587:
1598: public void setDomainGridlinesVisible(boolean visible) {
1599: if (this.domainGridlinesVisible != visible) {
1600: this.domainGridlinesVisible = visible;
1601: notifyListeners(new PlotChangeEvent(this));
1602: }
1603: }
1604:
1605:
1613: public Stroke getDomainGridlineStroke() {
1614: return this.domainGridlineStroke;
1615: }
1616:
1617:
1630: public void setDomainGridlineStroke(Stroke stroke) {
1631: if (stroke == null) {
1632: throw new IllegalArgumentException("Null 'stroke' argument.");
1633: }
1634: this.domainGridlineStroke = stroke;
1635: notifyListeners(new PlotChangeEvent(this));
1636: }
1637:
1638:
1646: public Paint getDomainGridlinePaint() {
1647: return this.domainGridlinePaint;
1648: }
1649:
1650:
1661: public void setDomainGridlinePaint(Paint paint) {
1662: if (paint == null) {
1663: throw new IllegalArgumentException("Null 'paint' argument.");
1664: }
1665: this.domainGridlinePaint = paint;
1666: notifyListeners(new PlotChangeEvent(this));
1667: }
1668:
1669:
1677: public boolean isRangeGridlinesVisible() {
1678: return this.rangeGridlinesVisible;
1679: }
1680:
1681:
1692: public void setRangeGridlinesVisible(boolean visible) {
1693: if (this.rangeGridlinesVisible != visible) {
1694: this.rangeGridlinesVisible = visible;
1695: notifyListeners(new PlotChangeEvent(this));
1696: }
1697: }
1698:
1699:
1707: public Stroke getRangeGridlineStroke() {
1708: return this.rangeGridlineStroke;
1709: }
1710:
1711:
1719: public void setRangeGridlineStroke(Stroke stroke) {
1720: if (stroke == null) {
1721: throw new IllegalArgumentException("Null 'stroke' argument.");
1722: }
1723: this.rangeGridlineStroke = stroke;
1724: notifyListeners(new PlotChangeEvent(this));
1725: }
1726:
1727:
1735: public Paint getRangeGridlinePaint() {
1736: return this.rangeGridlinePaint;
1737: }
1738:
1739:
1747: public void setRangeGridlinePaint(Paint paint) {
1748: if (paint == null) {
1749: throw new IllegalArgumentException("Null 'paint' argument.");
1750: }
1751: this.rangeGridlinePaint = paint;
1752: notifyListeners(new PlotChangeEvent(this));
1753: }
1754:
1755:
1765: public boolean isDomainZeroBaselineVisible() {
1766: return this.domainZeroBaselineVisible;
1767: }
1768:
1769:
1780: public void setDomainZeroBaselineVisible(boolean visible) {
1781: this.domainZeroBaselineVisible = visible;
1782: notifyListeners(new PlotChangeEvent(this));
1783: }
1784:
1785:
1794: public Stroke getDomainZeroBaselineStroke() {
1795: return this.domainZeroBaselineStroke;
1796: }
1797:
1798:
1808: public void setDomainZeroBaselineStroke(Stroke stroke) {
1809: if (stroke == null) {
1810: throw new IllegalArgumentException("Null 'stroke' argument.");
1811: }
1812: this.domainZeroBaselineStroke = stroke;
1813: notifyListeners(new PlotChangeEvent(this));
1814: }
1815:
1816:
1826: public Paint getDomainZeroBaselinePaint() {
1827: return this.domainZeroBaselinePaint;
1828: }
1829:
1830:
1840: public void setDomainZeroBaselinePaint(Paint paint) {
1841: if (paint == null) {
1842: throw new IllegalArgumentException("Null 'paint' argument.");
1843: }
1844: this.domainZeroBaselinePaint = paint;
1845: notifyListeners(new PlotChangeEvent(this));
1846: }
1847:
1848:
1856: public boolean isRangeZeroBaselineVisible() {
1857: return this.rangeZeroBaselineVisible;
1858: }
1859:
1860:
1869: public void setRangeZeroBaselineVisible(boolean visible) {
1870: this.rangeZeroBaselineVisible = visible;
1871: notifyListeners(new PlotChangeEvent(this));
1872: }
1873:
1874:
1881: public Stroke getRangeZeroBaselineStroke() {
1882: return this.rangeZeroBaselineStroke;
1883: }
1884:
1885:
1893: public void setRangeZeroBaselineStroke(Stroke stroke) {
1894: if (stroke == null) {
1895: throw new IllegalArgumentException("Null 'stroke' argument.");
1896: }
1897: this.rangeZeroBaselineStroke = stroke;
1898: notifyListeners(new PlotChangeEvent(this));
1899: }
1900:
1901:
1909: public Paint getRangeZeroBaselinePaint() {
1910: return this.rangeZeroBaselinePaint;
1911: }
1912:
1913:
1921: public void setRangeZeroBaselinePaint(Paint paint) {
1922: if (paint == null) {
1923: throw new IllegalArgumentException("Null 'paint' argument.");
1924: }
1925: this.rangeZeroBaselinePaint = paint;
1926: notifyListeners(new PlotChangeEvent(this));
1927: }
1928:
1929:
1937: public Paint getDomainTickBandPaint() {
1938: return this.domainTickBandPaint;
1939: }
1940:
1941:
1948: public void setDomainTickBandPaint(Paint paint) {
1949: this.domainTickBandPaint = paint;
1950: notifyListeners(new PlotChangeEvent(this));
1951: }
1952:
1953:
1961: public Paint getRangeTickBandPaint() {
1962: return this.rangeTickBandPaint;
1963: }
1964:
1965:
1972: public void setRangeTickBandPaint(Paint paint) {
1973: this.rangeTickBandPaint = paint;
1974: notifyListeners(new PlotChangeEvent(this));
1975: }
1976:
1977:
1985: public Point2D getQuadrantOrigin() {
1986: return this.quadrantOrigin;
1987: }
1988:
1989:
1997: public void setQuadrantOrigin(Point2D origin) {
1998: if (origin == null) {
1999: throw new IllegalArgumentException("Null 'origin' argument.");
2000: }
2001: this.quadrantOrigin = origin;
2002: notifyListeners(new PlotChangeEvent(this));
2003: }
2004:
2005:
2014: public Paint getQuadrantPaint(int index) {
2015: if (index < 0 || index > 3) {
2016: throw new IllegalArgumentException(
2017: "The index should be in the range 0 to 3.");
2018: }
2019: return this.quadrantPaint[index];
2020: }
2021:
2022:
2031: public void setQuadrantPaint(int index, Paint paint) {
2032: if (index < 0 || index > 3) {
2033: throw new IllegalArgumentException(
2034: "The index should be in the range 0 to 3.");
2035: }
2036: this.quadrantPaint[index] = paint;
2037: notifyListeners(new PlotChangeEvent(this));
2038: }
2039:
2040:
2052: public void addDomainMarker(Marker marker) {
2053:
2054: addDomainMarker(marker, Layer.FOREGROUND);
2055: }
2056:
2057:
2069: public void addDomainMarker(Marker marker, Layer layer) {
2070: addDomainMarker(0, marker, layer);
2071: }
2072:
2073:
2079: public void clearDomainMarkers() {
2080: if (this.backgroundDomainMarkers != null) {
2081: Set keys = this.backgroundDomainMarkers.keySet();
2082: Iterator iterator = keys.iterator();
2083: while (iterator.hasNext()) {
2084: Integer key = (Integer) iterator.next();
2085: clearDomainMarkers(key.intValue());
2086: }
2087: this.backgroundDomainMarkers.clear();
2088: }
2089: if (this.foregroundDomainMarkers != null) {
2090: Set keys = this.foregroundDomainMarkers.keySet();
2091: Iterator iterator = keys.iterator();
2092: while (iterator.hasNext()) {
2093: Integer key = (Integer) iterator.next();
2094: clearDomainMarkers(key.intValue());
2095: }
2096: this.foregroundDomainMarkers.clear();
2097: }
2098: notifyListeners(new PlotChangeEvent(this));
2099: }
2100:
2101:
2109: public void clearDomainMarkers(int index) {
2110: Integer key = new Integer(index);
2111: if (this.backgroundDomainMarkers != null) {
2112: Collection markers
2113: = (Collection) this.backgroundDomainMarkers.get(key);
2114: if (markers != null) {
2115: Iterator iterator = markers.iterator();
2116: while (iterator.hasNext()) {
2117: Marker m = (Marker) iterator.next();
2118: m.removeChangeListener(this);
2119: }
2120: markers.clear();
2121: }
2122: }
2123: if (this.foregroundRangeMarkers != null) {
2124: Collection markers
2125: = (Collection) this.foregroundDomainMarkers.get(key);
2126: if (markers != null) {
2127: Iterator iterator = markers.iterator();
2128: while (iterator.hasNext()) {
2129: Marker m = (Marker) iterator.next();
2130: m.removeChangeListener(this);
2131: }
2132: markers.clear();
2133: }
2134: }
2135: notifyListeners(new PlotChangeEvent(this));
2136: }
2137:
2138:
2153: public void addDomainMarker(int index, Marker marker, Layer layer) {
2154: if (marker == null) {
2155: throw new IllegalArgumentException("Null 'marker' not permitted.");
2156: }
2157: if (layer == null) {
2158: throw new IllegalArgumentException("Null 'layer' not permitted.");
2159: }
2160: Collection markers;
2161: if (layer == Layer.FOREGROUND) {
2162: markers = (Collection) this.foregroundDomainMarkers.get(
2163: new Integer(index));
2164: if (markers == null) {
2165: markers = new java.util.ArrayList();
2166: this.foregroundDomainMarkers.put(new Integer(index), markers);
2167: }
2168: markers.add(marker);
2169: }
2170: else if (layer == Layer.BACKGROUND) {
2171: markers = (Collection) this.backgroundDomainMarkers.get(
2172: new Integer(index));
2173: if (markers == null) {
2174: markers = new java.util.ArrayList();
2175: this.backgroundDomainMarkers.put(new Integer(index), markers);
2176: }
2177: markers.add(marker);
2178: }
2179: marker.addChangeListener(this);
2180: notifyListeners(new PlotChangeEvent(this));
2181: }
2182:
2183:
2194: public void addRangeMarker(Marker marker) {
2195: addRangeMarker(marker, Layer.FOREGROUND);
2196: }
2197:
2198:
2210: public void addRangeMarker(Marker marker, Layer layer) {
2211: addRangeMarker(0, marker, layer);
2212: }
2213:
2214:
2220: public void clearRangeMarkers() {
2221: if (this.backgroundRangeMarkers != null) {
2222: Set keys = this.backgroundRangeMarkers.keySet();
2223: Iterator iterator = keys.iterator();
2224: while (iterator.hasNext()) {
2225: Integer key = (Integer) iterator.next();
2226: clearRangeMarkers(key.intValue());
2227: }
2228: this.backgroundRangeMarkers.clear();
2229: }
2230: if (this.foregroundRangeMarkers != null) {
2231: Set keys = this.foregroundRangeMarkers.keySet();
2232: Iterator iterator = keys.iterator();
2233: while (iterator.hasNext()) {
2234: Integer key = (Integer) iterator.next();
2235: clearRangeMarkers(key.intValue());
2236: }
2237: this.foregroundRangeMarkers.clear();
2238: }
2239: notifyListeners(new PlotChangeEvent(this));
2240: }
2241:
2242:
2256: public void addRangeMarker(int index, Marker marker, Layer layer) {
2257: Collection markers;
2258: if (layer == Layer.FOREGROUND) {
2259: markers = (Collection) this.foregroundRangeMarkers.get(
2260: new Integer(index));
2261: if (markers == null) {
2262: markers = new java.util.ArrayList();
2263: this.foregroundRangeMarkers.put(new Integer(index), markers);
2264: }
2265: markers.add(marker);
2266: }
2267: else if (layer == Layer.BACKGROUND) {
2268: markers = (Collection) this.backgroundRangeMarkers.get(
2269: new Integer(index));
2270: if (markers == null) {
2271: markers = new java.util.ArrayList();
2272: this.backgroundRangeMarkers.put(new Integer(index), markers);
2273: }
2274: markers.add(marker);
2275: }
2276: marker.addChangeListener(this);
2277: notifyListeners(new PlotChangeEvent(this));
2278: }
2279:
2280:
2286: public void clearRangeMarkers(int index) {
2287: Integer key = new Integer(index);
2288: if (this.backgroundRangeMarkers != null) {
2289: Collection markers
2290: = (Collection) this.backgroundRangeMarkers.get(key);
2291: if (markers != null) {
2292: Iterator iterator = markers.iterator();
2293: while (iterator.hasNext()) {
2294: Marker m = (Marker) iterator.next();
2295: m.removeChangeListener(this);
2296: }
2297: markers.clear();
2298: }
2299: }
2300: if (this.foregroundRangeMarkers != null) {
2301: Collection markers
2302: = (Collection) this.foregroundRangeMarkers.get(key);
2303: if (markers != null) {
2304: Iterator iterator = markers.iterator();
2305: while (iterator.hasNext()) {
2306: Marker m = (Marker) iterator.next();
2307: m.removeChangeListener(this);
2308: }
2309: markers.clear();
2310: }
2311: }
2312: notifyListeners(new PlotChangeEvent(this));
2313: }
2314:
2315:
2324: public void addAnnotation(XYAnnotation annotation) {
2325: if (annotation == null) {
2326: throw new IllegalArgumentException("Null 'annotation' argument.");
2327: }
2328: this.annotations.add(annotation);
2329: notifyListeners(new PlotChangeEvent(this));
2330: }
2331:
2332:
2343: public boolean removeAnnotation(XYAnnotation annotation) {
2344: if (annotation == null) {
2345: throw new IllegalArgumentException("Null 'annotation' argument.");
2346: }
2347: boolean removed = this.annotations.remove(annotation);
2348: if (removed) {
2349: notifyListeners(new PlotChangeEvent(this));
2350: }
2351: return removed;
2352: }
2353:
2354:
2363: public List getAnnotations() {
2364: return new ArrayList(this.annotations);
2365: }
2366:
2367:
2373: public void clearAnnotations() {
2374: this.annotations.clear();
2375: notifyListeners(new PlotChangeEvent(this));
2376: }
2377:
2378:
2386: protected AxisSpace calculateAxisSpace(Graphics2D g2,
2387: Rectangle2D plotArea) {
2388: AxisSpace space = new AxisSpace();
2389: space = calculateDomainAxisSpace(g2, plotArea, space);
2390: space = calculateRangeAxisSpace(g2, plotArea, space);
2391: return space;
2392: }
2393:
2394:
2403: protected AxisSpace calculateDomainAxisSpace(Graphics2D g2,
2404: Rectangle2D plotArea,
2405: AxisSpace space) {
2406:
2407: if (space == null) {
2408: space = new AxisSpace();
2409: }
2410:
2411:
2412: if (this.fixedDomainAxisSpace != null) {
2413: if (this.orientation == PlotOrientation.HORIZONTAL) {
2414: space.ensureAtLeast(this.fixedDomainAxisSpace.getLeft(),
2415: RectangleEdge.LEFT);
2416: space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(),
2417: RectangleEdge.RIGHT);
2418: }
2419: else if (this.orientation == PlotOrientation.VERTICAL) {
2420: space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(),
2421: RectangleEdge.TOP);
2422: space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(),
2423: RectangleEdge.BOTTOM);
2424: }
2425: }
2426: else {
2427:
2428: for (int i = 0; i < this.domainAxes.size(); i++) {
2429: Axis axis = (Axis) this.domainAxes.get(i);
2430: if (axis != null) {
2431: RectangleEdge edge = getDomainAxisEdge(i);
2432: space = axis.reserveSpace(g2, this, plotArea, edge, space);
2433: }
2434: }
2435: }
2436:
2437: return space;
2438:
2439: }
2440:
2441:
2450: protected AxisSpace calculateRangeAxisSpace(Graphics2D g2,
2451: Rectangle2D plotArea,
2452: AxisSpace space) {
2453:
2454: if (space == null) {
2455: space = new AxisSpace();
2456: }
2457:
2458:
2459: if (this.fixedRangeAxisSpace != null) {
2460: if (this.orientation == PlotOrientation.HORIZONTAL) {
2461: space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(),
2462: RectangleEdge.TOP);
2463: space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(),
2464: RectangleEdge.BOTTOM);
2465: }
2466: else if (this.orientation == PlotOrientation.VERTICAL) {
2467: space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(),
2468: RectangleEdge.LEFT);
2469: space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(),
2470: RectangleEdge.RIGHT);
2471: }
2472: }
2473: else {
2474:
2475: for (int i = 0; i < this.rangeAxes.size(); i++) {
2476: Axis axis = (Axis) this.rangeAxes.get(i);
2477: if (axis != null) {
2478: RectangleEdge edge = getRangeAxisEdge(i);
2479: space = axis.reserveSpace(g2, this, plotArea, edge, space);
2480: }
2481: }
2482: }
2483: return space;
2484:
2485: }
2486:
2487:
2499: public void draw(Graphics2D g2,
2500: Rectangle2D area,
2501: Point2D anchor,
2502: PlotState parentState,
2503: PlotRenderingInfo info) {
2504:
2505:
2506: boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
2507: boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
2508: if (b1 || b2) {
2509: return;
2510: }
2511:
2512:
2513: if (info != null) {
2514: info.setPlotArea(area);
2515: }
2516:
2517:
2518: RectangleInsets insets = getInsets();
2519: insets.trim(area);
2520:
2521: AxisSpace space = calculateAxisSpace(g2, area);
2522: Rectangle2D dataArea = space.shrink(area, null);
2523: this.axisOffset.trim(dataArea);
2524:
2525: if (info != null) {
2526: info.setDataArea(dataArea);
2527: }
2528:
2529:
2530: drawBackground(g2, dataArea);
2531: Map axisStateMap = drawAxes(g2, area, dataArea, info);
2532:
2533: PlotOrientation orient = getOrientation();
2534:
2535:
2536:
2537: if (anchor != null && !dataArea.contains(anchor)) {
2538: anchor = null;
2539: }
2540: CrosshairState crosshairState = new CrosshairState();
2541: crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY);
2542: crosshairState.setAnchor(anchor);
2543:
2544: crosshairState.setAnchorX(Double.NaN);
2545: crosshairState.setAnchorY(Double.NaN);
2546: if (anchor != null) {
2547: ValueAxis domainAxis = getDomainAxis();
2548: if (domainAxis != null) {
2549: double x;
2550: if (orient == PlotOrientation.VERTICAL) {
2551: x = domainAxis.java2DToValue(anchor.getX(), dataArea,
2552: getDomainAxisEdge());
2553: }
2554: else {
2555: x = domainAxis.java2DToValue(anchor.getY(), dataArea,
2556: getDomainAxisEdge());
2557: }
2558: crosshairState.setAnchorX(x);
2559: }
2560: ValueAxis rangeAxis = getRangeAxis();
2561: if (rangeAxis != null) {
2562: double y;
2563: if (orient == PlotOrientation.VERTICAL) {
2564: y = rangeAxis.java2DToValue(anchor.getY(), dataArea,
2565: getRangeAxisEdge());
2566: }
2567: else {
2568: y = rangeAxis.java2DToValue(anchor.getX(), dataArea,
2569: getRangeAxisEdge());
2570: }
2571: crosshairState.setAnchorY(y);
2572: }
2573: }
2574: crosshairState.setCrosshairX(getDomainCrosshairValue());
2575: crosshairState.setCrosshairY(getRangeCrosshairValue());
2576: Shape originalClip = g2.getClip();
2577: Composite originalComposite = g2.getComposite();
2578:
2579: g2.clip(dataArea);
2580: g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
2581: getForegroundAlpha()));
2582:
2583: AxisState domainAxisState = (AxisState) axisStateMap.get(
2584: getDomainAxis());
2585: if (domainAxisState == null) {
2586: if (parentState != null) {
2587: domainAxisState = (AxisState) parentState.getSharedAxisStates()
2588: .get(getDomainAxis());
2589: }
2590: }
2591:
2592: AxisState rangeAxisState = (AxisState) axisStateMap.get(getRangeAxis());
2593: if (rangeAxisState == null) {
2594: if (parentState != null) {
2595: rangeAxisState = (AxisState) parentState.getSharedAxisStates()
2596: .get(getRangeAxis());
2597: }
2598: }
2599: if (domainAxisState != null) {
2600: drawDomainTickBands(g2, dataArea, domainAxisState.getTicks());
2601: }
2602: if (rangeAxisState != null) {
2603: drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks());
2604: }
2605: if (domainAxisState != null) {
2606: drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
2607: drawZeroDomainBaseline(g2, dataArea);
2608: }
2609: if (rangeAxisState != null) {
2610: drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());
2611: drawZeroRangeBaseline(g2, dataArea);
2612: }
2613:
2614:
2615: for (int i = 0; i < this.renderers.size(); i++) {
2616: drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND);
2617: }
2618: for (int i = 0; i < this.renderers.size(); i++) {
2619: drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND);
2620: }
2621:
2622:
2623: boolean foundData = false;
2624: DatasetRenderingOrder order = getDatasetRenderingOrder();
2625: if (order == DatasetRenderingOrder.FORWARD) {
2626:
2627:
2628: int rendererCount = this.renderers.size();
2629: for (int i = 0; i < rendererCount; i++) {
2630: XYItemRenderer r = getRenderer(i);
2631: if (r != null) {
2632: ValueAxis domainAxis = getDomainAxisForDataset(i);
2633: ValueAxis rangeAxis = getRangeAxisForDataset(i);
2634: r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis,
2635: Layer.BACKGROUND, info);
2636: }
2637: }
2638:
2639:
2640: for (int i = 0; i < getDatasetCount(); i++) {
2641: foundData = render(g2, dataArea, i, info, crosshairState)
2642: || foundData;
2643: }
2644:
2645:
2646: for (int i = 0; i < rendererCount; i++) {
2647: XYItemRenderer r = getRenderer(i);
2648: if (r != null) {
2649: ValueAxis domainAxis = getDomainAxisForDataset(i);
2650: ValueAxis rangeAxis = getRangeAxisForDataset(i);
2651: r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis,
2652: Layer.FOREGROUND, info);
2653: }
2654: }
2655:
2656: }
2657: else if (order == DatasetRenderingOrder.REVERSE) {
2658:
2659:
2660: int rendererCount = this.renderers.size();
2661: for (int i = rendererCount - 1; i >= 0; i--) {
2662: XYItemRenderer r = getRenderer(i);
2663: if (i >= getDatasetCount()) {
2664: continue;
2665: }
2666: if (r != null) {
2667: ValueAxis domainAxis = getDomainAxisForDataset(i);
2668: ValueAxis rangeAxis = getRangeAxisForDataset(i);
2669: r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis,
2670: Layer.BACKGROUND, info);
2671: }
2672: }
2673:
2674: for (int i = getDatasetCount() - 1; i >= 0; i--) {
2675: foundData = render(g2, dataArea, i, info, crosshairState)
2676: || foundData;
2677: }
2678:
2679:
2680: for (int i = rendererCount - 1; i >= 0; i--) {
2681: XYItemRenderer r = getRenderer(i);
2682: if (i >= getDatasetCount()) {
2683: continue;
2684: }
2685: if (r != null) {
2686: ValueAxis domainAxis = getDomainAxisForDataset(i);
2687: ValueAxis rangeAxis = getRangeAxisForDataset(i);
2688: r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis,
2689: Layer.FOREGROUND, info);
2690: }
2691: }
2692:
2693: }
2694:
2695:
2696: int xAxisIndex = crosshairState.getDomainAxisIndex();
2697: ValueAxis xAxis = getDomainAxis(xAxisIndex);
2698: RectangleEdge xAxisEdge = getDomainAxisEdge(xAxisIndex);
2699: if (!this.domainCrosshairLockedOnData && anchor != null) {
2700: double xx;
2701: if (orient == PlotOrientation.VERTICAL) {
2702: xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge);
2703: }
2704: else {
2705: xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge);
2706: }
2707: crosshairState.setCrosshairX(xx);
2708: }
2709: setDomainCrosshairValue(crosshairState.getCrosshairX(), false);
2710: if (isDomainCrosshairVisible()) {
2711: double x = getDomainCrosshairValue();
2712: Paint paint = getDomainCrosshairPaint();
2713: Stroke stroke = getDomainCrosshairStroke();
2714: drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint);
2715: }
2716:
2717:
2718: int yAxisIndex = crosshairState.getRangeAxisIndex();
2719: ValueAxis yAxis = getRangeAxis(yAxisIndex);
2720: RectangleEdge yAxisEdge = getRangeAxisEdge(yAxisIndex);
2721: if (!this.rangeCrosshairLockedOnData && anchor != null) {
2722: double yy;
2723: if (orient == PlotOrientation.VERTICAL) {
2724: yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge);
2725: } else {
2726: yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge);
2727: }
2728: crosshairState.setCrosshairY(yy);
2729: }
2730: setRangeCrosshairValue(crosshairState.getCrosshairY(), false);
2731: if (isRangeCrosshairVisible()) {
2732: double y = getRangeCrosshairValue();
2733: Paint paint = getRangeCrosshairPaint();
2734: Stroke stroke = getRangeCrosshairStroke();
2735: drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint);
2736: }
2737:
2738: if (!foundData) {
2739: drawNoDataMessage(g2, dataArea);
2740: }
2741:
2742: for (int i = 0; i < this.renderers.size(); i++) {
2743: drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND);
2744: }
2745: for (int i = 0; i < this.renderers.size(); i++) {
2746: drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND);
2747: }
2748:
2749: drawAnnotations(g2, dataArea, info);
2750: g2.setClip(originalClip);
2751: g2.setComposite(originalComposite);
2752:
2753: drawOutline(g2, dataArea);
2754:
2755: }
2756:
2757:
2763: public void drawBackground(Graphics2D g2, Rectangle2D area) {
2764: fillBackground(g2, area);
2765: drawQuadrants(g2, area);
2766: drawBackgroundImage(g2, area);
2767: }
2768:
2769:
2778: protected void drawQuadrants(Graphics2D g2, Rectangle2D area) {
2779:
2780:
2781:
2782: boolean somethingToDraw = false;
2783:
2784: ValueAxis xAxis = getDomainAxis();
2785: double x = this.quadrantOrigin.getX();
2786: double xx = xAxis.valueToJava2D(x, area, getDomainAxisEdge());
2787:
2788: ValueAxis yAxis = getRangeAxis();
2789: double y = this.quadrantOrigin.getY();
2790: double yy = yAxis.valueToJava2D(y, area, getRangeAxisEdge());
2791:
2792: double xmin = xAxis.getLowerBound();
2793: double xxmin = xAxis.valueToJava2D(xmin, area, getDomainAxisEdge());
2794:
2795: double xmax = xAxis.getUpperBound();
2796: double xxmax = xAxis.valueToJava2D(xmax, area, getDomainAxisEdge());
2797:
2798: double ymin = yAxis.getLowerBound();
2799: double yymin = yAxis.valueToJava2D(ymin, area, getRangeAxisEdge());
2800:
2801: double ymax = yAxis.getUpperBound();
2802: double yymax = yAxis.valueToJava2D(ymax, area, getRangeAxisEdge());
2803:
2804: Rectangle2D[] r = new Rectangle2D[] {null, null, null, null};
2805: if (this.quadrantPaint[0] != null) {
2806: if (x > xmin && y < ymax) {
2807: if (this.orientation == PlotOrientation.HORIZONTAL) {
2808: r[0] = new Rectangle2D.Double(Math.min(yymax, yy),
2809: Math.min(xxmin, xx), Math.abs(yy - yymax),
2810: Math.abs(xx - xxmin)
2811: );
2812: }
2813: else {
2814: r[0] = new Rectangle2D.Double(Math.min(xxmin, xx),
2815: Math.min(yymax, yy), Math.abs(xx - xxmin),
2816: Math.abs(yy - yymax));
2817: }
2818: somethingToDraw = true;
2819: }
2820: }
2821: if (this.quadrantPaint[1] != null) {
2822: if (x < xmax && y < ymax) {
2823: if (this.orientation == PlotOrientation.HORIZONTAL) {
2824: r[1] = new Rectangle2D.Double(Math.min(yymax, yy),
2825: Math.min(xxmax, xx), Math.abs(yy - yymax),
2826: Math.abs(xx - xxmax));
2827: }
2828: else {
2829: r[1] = new Rectangle2D.Double(Math.min(xx, xxmax),
2830: Math.min(yymax, yy), Math.abs(xx - xxmax),
2831: Math.abs(yy - yymax));
2832: }
2833: somethingToDraw = true;
2834: }
2835: }
2836: if (this.quadrantPaint[2] != null) {
2837: if (x > xmin && y > ymin) {
2838: if (this.orientation == PlotOrientation.HORIZONTAL) {
2839: r[2] = new Rectangle2D.Double(Math.min(yymin, yy),
2840: Math.min(xxmin, xx), Math.abs(yy - yymin),
2841: Math.abs(xx - xxmin));
2842: }
2843: else {
2844: r[2] = new Rectangle2D.Double(Math.min(xxmin, xx),
2845: Math.min(yymin, yy), Math.abs(xx - xxmin),
2846: Math.abs(yy - yymin));
2847: }
2848: somethingToDraw = true;
2849: }
2850: }
2851: if (this.quadrantPaint[3] != null) {
2852: if (x < xmax && y > ymin) {
2853: if (this.orientation == PlotOrientation.HORIZONTAL) {
2854: r[3] = new Rectangle2D.Double(Math.min(yymin, yy),
2855: Math.min(xxmax, xx), Math.abs(yy - yymin),
2856: Math.abs(xx - xxmax));
2857: }
2858: else {
2859: r[3] = new Rectangle2D.Double(Math.min(xx, xxmax),
2860: Math.min(yymin, yy), Math.abs(xx - xxmax),
2861: Math.abs(yy - yymin));
2862: }
2863: somethingToDraw = true;
2864: }
2865: }
2866: if (somethingToDraw) {
2867: Composite originalComposite = g2.getComposite();
2868: g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
2869: getBackgroundAlpha()));
2870: for (int i = 0; i < 4; i++) {
2871: if (this.quadrantPaint[i] != null && r[i] != null) {
2872: g2.setPaint(this.quadrantPaint[i]);
2873: g2.fill(r[i]);
2874: }
2875: }
2876: g2.setComposite(originalComposite);
2877: }
2878: }
2879:
2880:
2889: public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea,
2890: List ticks) {
2891:
2892: Paint bandPaint = getDomainTickBandPaint();
2893: if (bandPaint != null) {
2894: boolean fillBand = false;
2895: ValueAxis xAxis = getDomainAxis();
2896: double previous = xAxis.getLowerBound();
2897: Iterator iterator = ticks.iterator();
2898: while (iterator.hasNext()) {
2899: ValueTick tick = (ValueTick) iterator.next();
2900: double current = tick.getValue();
2901: if (fillBand) {
2902: getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea,
2903: previous, current);
2904: }
2905: previous = current;
2906: fillBand = !fillBand;
2907: }
2908: double end = xAxis.getUpperBound();
2909: if (fillBand) {
2910: getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea,
2911: previous, end);
2912: }
2913: }
2914: }
2915:
2916:
2925: public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
2926: List ticks) {
2927:
2928:
2929: Paint bandPaint = getRangeTickBandPaint();
2930: if (bandPaint != null) {
2931: boolean fillBand = false;
2932: ValueAxis axis = getRangeAxis();
2933: double previous = axis.getLowerBound();
2934: Iterator iterator = ticks.iterator();
2935: while (iterator.hasNext()) {
2936: ValueTick tick = (ValueTick) iterator.next();
2937: double current = tick.getValue();
2938: if (fillBand) {
2939: getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
2940: previous, current);
2941: }
2942: previous = current;
2943: fillBand = !fillBand;
2944: }
2945: double end = axis.getUpperBound();
2946: if (fillBand) {
2947: getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
2948: previous, end);
2949: }
2950: }
2951: }
2952:
2953:
2964: protected Map drawAxes(Graphics2D g2,
2965: Rectangle2D plotArea,
2966: Rectangle2D dataArea,
2967: PlotRenderingInfo plotState) {
2968:
2969: AxisCollection axisCollection = new AxisCollection();
2970:
2971:
2972: for (int index = 0; index < this.domainAxes.size(); index++) {
2973: ValueAxis axis = (ValueAxis) this.domainAxes.get(index);
2974: if (axis != null) {
2975: axisCollection.add(axis, getDomainAxisEdge(index));
2976: }
2977: }
2978:
2979:
2980: for (int index = 0; index < this.rangeAxes.size(); index++) {
2981: ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(index);
2982: if (yAxis != null) {
2983: axisCollection.add(yAxis, getRangeAxisEdge(index));
2984: }
2985: }
2986:
2987: Map axisStateMap = new HashMap();
2988:
2989:
2990: double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset(
2991: dataArea.getHeight());
2992: Iterator iterator = axisCollection.getAxesAtTop().iterator();
2993: while (iterator.hasNext()) {
2994: ValueAxis axis = (ValueAxis) iterator.next();
2995: AxisState info = axis.draw(g2, cursor, plotArea, dataArea,
2996: RectangleEdge.TOP, plotState);
2997: cursor = info.getCursor();
2998: axisStateMap.put(axis, info);
2999: }
3000:
3001:
3002: cursor = dataArea.getMaxY()
3003: + this.axisOffset.calculateBottomOutset(dataArea.getHeight());
3004: iterator = axisCollection.getAxesAtBottom().iterator();
3005: while (iterator.hasNext()) {
3006: ValueAxis axis = (ValueAxis) iterator.next();
3007: AxisState info = axis.draw(g2, cursor, plotArea, dataArea,
3008: RectangleEdge.BOTTOM, plotState);
3009: cursor = info.getCursor();
3010: axisStateMap.put(axis, info);
3011: }
3012:
3013:
3014: cursor = dataArea.getMinX()
3015: - this.axisOffset.calculateLeftOutset(dataArea.getWidth());
3016: iterator = axisCollection.getAxesAtLeft().iterator();
3017: while (iterator.hasNext()) {
3018: ValueAxis axis = (ValueAxis) iterator.next();
3019: AxisState info = axis.draw(g2, cursor, plotArea, dataArea,
3020: RectangleEdge.LEFT, plotState);
3021: cursor = info.getCursor();
3022: axisStateMap.put(axis, info);
3023: }
3024:
3025:
3026: cursor = dataArea.getMaxX()
3027: + this.axisOffset.calculateRightOutset(dataArea.getWidth());
3028: iterator = axisCollection.getAxesAtRight().iterator();
3029: while (iterator.hasNext()) {
3030: ValueAxis axis = (ValueAxis) iterator.next();
3031: AxisState info = axis.draw(g2, cursor, plotArea, dataArea,
3032: RectangleEdge.RIGHT, plotState);
3033: cursor = info.getCursor();
3034: axisStateMap.put(axis, info);
3035: }
3036:
3037: return axisStateMap;
3038: }
3039:
3040:
3056: public boolean render(Graphics2D g2,
3057: Rectangle2D dataArea,
3058: int index,
3059: PlotRenderingInfo info,
3060: CrosshairState crosshairState) {
3061:
3062: boolean foundData = false;
3063: XYDataset dataset = getDataset(index);
3064: if (!DatasetUtilities.isEmptyOrNull(dataset)) {
3065: foundData = true;
3066: ValueAxis xAxis = getDomainAxisForDataset(index);
3067: ValueAxis yAxis = getRangeAxisForDataset(index);
3068: XYItemRenderer renderer = getRenderer(index);
3069: if (renderer == null) {
3070: renderer = getRenderer();
3071: if (renderer == null) {
3072: return foundData;
3073: }
3074: }
3075:
3076: XYItemRendererState state = renderer.initialise(g2, dataArea, this,
3077: dataset, info);
3078: int passCount = renderer.getPassCount();
3079:
3080: SeriesRenderingOrder seriesOrder = getSeriesRenderingOrder();
3081: if (seriesOrder == SeriesRenderingOrder.REVERSE) {
3082:
3083: for (int pass = 0; pass < passCount; pass++) {
3084: int seriesCount = dataset.getSeriesCount();
3085: for (int series = seriesCount - 1; series >= 0; series--) {
3086: int itemCount = dataset.getItemCount(series);
3087: for (int item = 0; item < itemCount; item++) {
3088: renderer.drawItem(g2, state, dataArea, info,
3089: this, xAxis, yAxis, dataset, series, item,
3090: crosshairState, pass);
3091: }
3092: }
3093: }
3094: }
3095: else {
3096:
3097: for (int pass = 0; pass < passCount; pass++) {
3098: int seriesCount = dataset.getSeriesCount();
3099: for (int series = 0; series < seriesCount; series++) {
3100: int itemCount = dataset.getItemCount(series);
3101: for (int item = 0; item < itemCount; item++) {
3102: renderer.drawItem(g2, state, dataArea, info,
3103: this, xAxis, yAxis, dataset, series, item,
3104: crosshairState, pass);
3105: }
3106: }
3107: }
3108: }
3109: }
3110: return foundData;
3111: }
3112:
3113:
3120: public ValueAxis getDomainAxisForDataset(int index) {
3121:
3122: if (index < 0 || index >= getDatasetCount()) {
3123: throw new IllegalArgumentException("Index 'index' out of bounds.");
3124: }
3125:
3126: ValueAxis valueAxis = null;
3127: Integer axisIndex = (Integer) this.datasetToDomainAxisMap.get(
3128: new Integer(index));
3129: if (axisIndex != null) {
3130: valueAxis = getDomainAxis(axisIndex.intValue());
3131: }
3132: else {
3133: valueAxis = getDomainAxis(0);
3134: }
3135: return valueAxis;
3136:
3137: }
3138:
3139:
3146: public ValueAxis getRangeAxisForDataset(int index) {
3147:
3148: if (index < 0 || index >= getDatasetCount()) {
3149: throw new IllegalArgumentException("Index 'index' out of bounds.");
3150: }
3151:
3152: ValueAxis valueAxis = null;
3153: Integer axisIndex
3154: = (Integer) this.datasetToRangeAxisMap.get(new Integer(index));
3155: if (axisIndex != null) {
3156: valueAxis = getRangeAxis(axisIndex.intValue());
3157: }
3158: else {
3159: valueAxis = getRangeAxis(0);
3160: }
3161: return valueAxis;
3162:
3163: }
3164:
3165:
3172: protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea,
3173: List ticks) {
3174:
3175:
3176: if (getRenderer() == null) {
3177: return;
3178: }
3179:
3180:
3181: if (isDomainGridlinesVisible()) {
3182: Stroke gridStroke = getDomainGridlineStroke();
3183: Paint gridPaint = getDomainGridlinePaint();
3184: if ((gridStroke != null) && (gridPaint != null)) {
3185: Iterator iterator = ticks.iterator();
3186: while (iterator.hasNext()) {
3187: ValueTick tick = (ValueTick) iterator.next();
3188: getRenderer().drawDomainGridLine(g2, this, getDomainAxis(),
3189: dataArea, tick.getValue());
3190: }
3191: }
3192: }
3193: }
3194:
3195:
3203: protected void drawRangeGridlines(Graphics2D g2, Rectangle2D area,
3204: List ticks) {
3205:
3206:
3207: if (getRenderer() == null) {
3208: return;
3209: }
3210:
3211:
3212: if (isRangeGridlinesVisible()) {
3213: Stroke gridStroke = getRangeGridlineStroke();
3214: Paint gridPaint = getRangeGridlinePaint();
3215: ValueAxis axis = getRangeAxis();
3216: if (axis != null) {
3217: Iterator iterator = ticks.iterator();
3218: while (iterator.hasNext()) {
3219: ValueTick tick = (ValueTick) iterator.next();
3220: if (tick.getValue() != 0.0
3221: || !isRangeZeroBaselineVisible()) {
3222: getRenderer().drawRangeLine(g2, this, getRangeAxis(),
3223: area, tick.getValue(), gridPaint, gridStroke);
3224: }
3225: }
3226: }
3227: }
3228: }
3229:
3230:
3240: protected void drawZeroDomainBaseline(Graphics2D g2, Rectangle2D area) {
3241: if (isDomainZeroBaselineVisible()) {
3242: XYItemRenderer r = getRenderer();
3243:
3244:
3245:
3246: if (r instanceof AbstractXYItemRenderer) {
3247: AbstractXYItemRenderer renderer = (AbstractXYItemRenderer) r;
3248: renderer.drawDomainLine(g2, this, getDomainAxis(), area, 0.0,
3249: this.domainZeroBaselinePaint,
3250: this.domainZeroBaselineStroke);
3251: }
3252: }
3253: }
3254:
3255:
3263: protected void drawZeroRangeBaseline(Graphics2D g2, Rectangle2D area) {
3264: if (isRangeZeroBaselineVisible()) {
3265: getRenderer().drawRangeLine(g2, this, getRangeAxis(), area, 0.0,
3266: this.rangeZeroBaselinePaint, this.rangeZeroBaselineStroke);
3267: }
3268: }
3269:
3270:
3277: public void drawAnnotations(Graphics2D g2,
3278: Rectangle2D dataArea,
3279: PlotRenderingInfo info) {
3280:
3281: Iterator iterator = this.annotations.iterator();
3282: while (iterator.hasNext()) {
3283: XYAnnotation annotation = (XYAnnotation) iterator.next();
3284: ValueAxis xAxis = getDomainAxis();
3285: ValueAxis yAxis = getRangeAxis();
3286: annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info);
3287: }
3288:
3289: }
3290:
3291:
3300: protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
3301: int index, Layer layer) {
3302:
3303: XYItemRenderer r = getRenderer(index);
3304: if (r == null) {
3305: return;
3306: }
3307:
3308:
3309: if (index >= getDatasetCount()) {
3310: return;
3311: }
3312: Collection markers = getDomainMarkers(index, layer);
3313: ValueAxis axis = getDomainAxisForDataset(index);
3314: if (markers != null && axis != null) {
3315: Iterator iterator = markers.iterator();
3316: while (iterator.hasNext()) {
3317: Marker marker = (Marker) iterator.next();
3318: r.drawDomainMarker(g2, this, axis, marker, dataArea);
3319: }
3320: }
3321:
3322: }
3323:
3324:
3333: protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea,
3334: int index, Layer layer) {
3335:
3336: XYItemRenderer r = getRenderer(index);
3337: if (r == null) {
3338: return;
3339: }
3340:
3341:
3342: if (index >= getDatasetCount()) {
3343: return;
3344: }
3345: Collection markers = getRangeMarkers(index, layer);
3346: ValueAxis axis = getRangeAxisForDataset(index);
3347: if (markers != null && axis != null) {
3348: Iterator iterator = markers.iterator();
3349: while (iterator.hasNext()) {
3350: Marker marker = (Marker) iterator.next();
3351: r.drawRangeMarker(g2, this, axis, marker, dataArea);
3352: }
3353: }
3354: }
3355:
3356:
3365: public Collection getDomainMarkers(Layer layer) {
3366: return getDomainMarkers(0, layer);
3367: }
3368:
3369:
3378: public Collection getRangeMarkers(Layer layer) {
3379: return getRangeMarkers(0, layer);
3380: }
3381:
3382:
3393: public Collection getDomainMarkers(int index, Layer layer) {
3394: Collection result = null;
3395: Integer key = new Integer(index);
3396: if (layer == Layer.FOREGROUND) {
3397: result = (Collection) this.foregroundDomainMarkers.get(key);
3398: }
3399: else if (layer == Layer.BACKGROUND) {
3400: result = (Collection) this.backgroundDomainMarkers.get(key);
3401: }
3402: if (result != null) {
3403: result = Collections.unmodifiableCollection(result);
3404: }
3405: return result;
3406: }
3407:
3408:
3419: public Collection getRangeMarkers(int index, Layer layer) {
3420: Collection result = null;
3421: Integer key = new Integer(index);
3422: if (layer == Layer.FOREGROUND) {
3423: result = (Collection) this.foregroundRangeMarkers.get(key);
3424: }
3425: else if (layer == Layer.BACKGROUND) {
3426: result = (Collection) this.backgroundRangeMarkers.get(key);
3427: }
3428: if (result != null) {
3429: result = Collections.unmodifiableCollection(result);
3430: }
3431: return result;
3432: }
3433:
3434:
3444: protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea,
3445: double value, Stroke stroke,
3446: Paint paint) {
3447:
3448: ValueAxis axis = getRangeAxis();
3449: if (getOrientation() == PlotOrientation.HORIZONTAL) {
3450: axis = getDomainAxis();
3451: }
3452: if (axis.getRange().contains(value)) {
3453: double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
3454: Line2D line = new Line2D.Double(dataArea.getMinX(), yy,
3455: dataArea.getMaxX(), yy);
3456: g2.setStroke(stroke);
3457: g2.setPaint(paint);
3458: g2.draw(line);
3459: }
3460:
3461: }
3462:
3463:
3476: protected void drawDomainCrosshair(Graphics2D g2, Rectangle2D dataArea,
3477: PlotOrientation orientation, double value, ValueAxis axis,
3478: Stroke stroke, Paint paint) {
3479:
3480: if (axis.getRange().contains(value)) {
3481: Line2D line = null;
3482: if (orientation == PlotOrientation.VERTICAL) {
3483: double xx = axis.valueToJava2D(value, dataArea,
3484: RectangleEdge.BOTTOM);
3485: line = new Line2D.Double(xx, dataArea.getMinY(), xx,
3486: dataArea.getMaxY());
3487: }
3488: else {
3489: double yy = axis.valueToJava2D(value, dataArea,
3490: RectangleEdge.LEFT);
3491: line = new Line2D.Double(dataArea.getMinX(), yy,
3492: dataArea.getMaxX(), yy);
3493: }
3494: g2.setStroke(stroke);
3495: g2.setPaint(paint);
3496: g2.draw(line);
3497: }
3498:
3499: }
3500:
3501:
3510: protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea,
3511: double value, Stroke stroke, Paint paint) {
3512:
3513: ValueAxis axis = getDomainAxis();
3514: if (getOrientation() == PlotOrientation.HORIZONTAL) {
3515: axis = getRangeAxis();
3516: }
3517: if (axis.getRange().contains(value)) {
3518: double xx = axis.valueToJava2D(value, dataArea,
3519: RectangleEdge.BOTTOM);
3520: Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx,
3521: dataArea.getMaxY());
3522: g2.setStroke(stroke);
3523: g2.setPaint(paint);
3524: g2.draw(line);
3525: }
3526:
3527: }
3528:
3529:
3542: protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea,
3543: PlotOrientation orientation, double value, ValueAxis axis,
3544: Stroke stroke, Paint paint) {
3545:
3546: if (axis.getRange().contains(value)) {
3547: Line2D line = null;
3548: if (orientation == PlotOrientation.HORIZONTAL) {
3549: double xx = axis.valueToJava2D(value, dataArea,
3550: RectangleEdge.BOTTOM);
3551: line = new Line2D.Double(xx, dataArea.getMinY(), xx,
3552: dataArea.getMaxY());
3553: }
3554: else {
3555: double yy = axis.valueToJava2D(value, dataArea,
3556: RectangleEdge.LEFT);
3557: line = new Line2D.Double(dataArea.getMinX(), yy,
3558: dataArea.getMaxX(), yy);
3559: }
3560: g2.setStroke(stroke);
3561: g2.setPaint(paint);
3562: g2.draw(line);
3563: }
3564:
3565: }
3566:
3567:
3574: public void handleClick(int x, int y, PlotRenderingInfo info) {
3575:
3576: Rectangle2D dataArea = info.getDataArea();
3577: if (dataArea.contains(x, y)) {
3578:
3579: ValueAxis da = getDomainAxis();
3580: if (da != null) {
3581: double hvalue = da.java2DToValue(x, info.getDataArea(),
3582: getDomainAxisEdge());
3583: setDomainCrosshairValue(hvalue);
3584: }
3585:
3586:
3587: ValueAxis ra = getRangeAxis();
3588: if (ra != null) {
3589: double vvalue = ra.java2DToValue(y, info.getDataArea(),
3590: getRangeAxisEdge());
3591: setRangeCrosshairValue(vvalue);
3592: }
3593: }
3594: }
3595:
3596:
3604: private List getDatasetsMappedToDomainAxis(Integer axisIndex) {
3605: if (axisIndex == null) {
3606: throw new IllegalArgumentException("Null 'axisIndex' argument.");
3607: }
3608: List result = new ArrayList();
3609: for (int i = 0; i < this.datasets.size(); i++) {
3610: Integer mappedAxis = (Integer) this.datasetToDomainAxisMap.get(
3611: new Integer(i));
3612: if (mappedAxis == null) {
3613: if (axisIndex.equals(ZERO)) {
3614: result.add(this.datasets.get(i));
3615: }
3616: }
3617: else {
3618: if (mappedAxis.equals(axisIndex)) {
3619: result.add(this.datasets.get(i));
3620: }
3621: }
3622: }
3623: return result;
3624: }
3625:
3626:
3634: private List getDatasetsMappedToRangeAxis(Integer axisIndex) {
3635: if (axisIndex == null) {
3636: throw new IllegalArgumentException("Null 'axisIndex' argument.");
3637: }
3638: List result = new ArrayList();
3639: for (int i = 0; i < this.datasets.size(); i++) {
3640: Integer mappedAxis = (Integer) this.datasetToRangeAxisMap.get(
3641: new Integer(i));
3642: if (mappedAxis == null) {
3643: if (axisIndex.equals(ZERO)) {
3644: result.add(this.datasets.get(i));
3645: }
3646: }
3647: else {
3648: if (mappedAxis.equals(axisIndex)) {
3649: result.add(this.datasets.get(i));
3650: }
3651: }
3652: }
3653: return result;
3654: }
3655:
3656:
3665: public int getDomainAxisIndex(ValueAxis axis) {
3666: int result = this.domainAxes.indexOf(axis);
3667: if (result < 0) {
3668:
3669: Plot parent = getParent();
3670: if (parent instanceof XYPlot) {
3671: XYPlot p = (XYPlot) parent;
3672: result = p.getDomainAxisIndex(axis);
3673: }
3674: }
3675: return result;
3676: }
3677:
3678:
3687: public int getRangeAxisIndex(ValueAxis axis) {
3688: int result = this.rangeAxes.indexOf(axis);
3689: if (result < 0) {
3690:
3691: Plot parent = getParent();
3692: if (parent instanceof XYPlot) {
3693: XYPlot p = (XYPlot) parent;
3694: result = p.getRangeAxisIndex(axis);
3695: }
3696: }
3697: return result;
3698: }
3699:
3700:
3707: public Range getDataRange(ValueAxis axis) {
3708:
3709: Range result = null;
3710: List mappedDatasets = new ArrayList();
3711: boolean isDomainAxis = true;
3712:
3713:
3714: int domainIndex = getDomainAxisIndex(axis);
3715: if (domainIndex >= 0) {
3716: isDomainAxis = true;
3717: mappedDatasets.addAll(getDatasetsMappedToDomainAxis(
3718: new Integer(domainIndex)));
3719: }
3720:
3721:
3722: int rangeIndex = getRangeAxisIndex(axis);
3723: if (rangeIndex >= 0) {
3724: isDomainAxis = false;
3725: mappedDatasets.addAll(getDatasetsMappedToRangeAxis(
3726: new Integer(rangeIndex)));
3727: }
3728:
3729:
3730:
3731: Iterator iterator = mappedDatasets.iterator();
3732: while (iterator.hasNext()) {
3733: XYDataset d = (XYDataset) iterator.next();
3734: if (d != null) {
3735: XYItemRenderer r = getRendererForDataset(d);
3736: if (isDomainAxis) {
3737: if (r != null) {
3738: result = Range.combine(result, r.findDomainBounds(d));
3739: }
3740: else {
3741: result = Range.combine(result,
3742: DatasetUtilities.findDomainBounds(d));
3743: }
3744: }
3745: else {
3746: if (r != null) {
3747: result = Range.combine(result, r.findRangeBounds(d));
3748: }
3749: else {
3750: result = Range.combine(result,
3751: DatasetUtilities.findRangeBounds(d));
3752: }
3753: }
3754: }
3755: }
3756: return result;
3757:
3758: }
3759:
3760:
3767: public void datasetChanged(DatasetChangeEvent event) {
3768: configureDomainAxes();
3769: configureRangeAxes();
3770: if (getParent() != null) {
3771: getParent().datasetChanged(event);
3772: }
3773: else {
3774: PlotChangeEvent e = new PlotChangeEvent(this);
3775: e.setType(ChartChangeEventType.DATASET_UPDATED);
3776: notifyListeners(e);
3777: }
3778: }
3779:
3780:
3785: public void rendererChanged(RendererChangeEvent event) {
3786: notifyListeners(new PlotChangeEvent(this));
3787: }
3788:
3789:
3796: public boolean isDomainCrosshairVisible() {
3797: return this.domainCrosshairVisible;
3798: }
3799:
3800:
3809: public void setDomainCrosshairVisible(boolean flag) {
3810: if (this.domainCrosshairVisible != flag) {
3811: this.domainCrosshairVisible = flag;
3812: notifyListeners(new PlotChangeEvent(this));
3813: }
3814: }
3815:
3816:
3824: public boolean isDomainCrosshairLockedOnData() {
3825: return this.domainCrosshairLockedOnData;
3826: }
3827:
3828:
3837: public void setDomainCrosshairLockedOnData(boolean flag) {
3838: if (this.domainCrosshairLockedOnData != flag) {
3839: this.domainCrosshairLockedOnData = flag;
3840: notifyListeners(new PlotChangeEvent(this));
3841: }
3842: }
3843:
3844:
3851: public double getDomainCrosshairValue() {
3852: return this.domainCrosshairValue;
3853: }
3854:
3855:
3863: public void setDomainCrosshairValue(double value) {
3864: setDomainCrosshairValue(value, true);
3865: }
3866:
3867:
3877: public void setDomainCrosshairValue(double value, boolean notify) {
3878: this.domainCrosshairValue = value;
3879: if (isDomainCrosshairVisible() && notify) {
3880: notifyListeners(new PlotChangeEvent(this));
3881: }
3882: }
3883:
3884:
3893: public Stroke getDomainCrosshairStroke() {
3894: return this.domainCrosshairStroke;
3895: }
3896:
3897:
3906: public void setDomainCrosshairStroke(Stroke stroke) {
3907: if (stroke == null) {
3908: throw new IllegalArgumentException("Null 'stroke' argument.");
3909: }
3910: this.domainCrosshairStroke = stroke;
3911: notifyListeners(new PlotChangeEvent(this));
3912: }
3913:
3914:
3923: public Paint getDomainCrosshairPaint() {
3924: return this.domainCrosshairPaint;
3925: }
3926:
3927:
3935: public void setDomainCrosshairPaint(Paint paint) {
3936: if (paint == null) {
3937: throw new IllegalArgumentException("Null 'paint' argument.");
3938: }
3939: this.domainCrosshairPaint = paint;
3940: notifyListeners(new PlotChangeEvent(this));
3941: }
3942:
3943:
3951: public boolean isRangeCrosshairVisible() {
3952: return this.rangeCrosshairVisible;
3953: }
3954:
3955:
3964: public void setRangeCrosshairVisible(boolean flag) {
3965: if (this.rangeCrosshairVisible != flag) {
3966: this.rangeCrosshairVisible = flag;
3967: notifyListeners(new PlotChangeEvent(this));
3968: }
3969: }
3970:
3971:
3979: public boolean isRangeCrosshairLockedOnData() {
3980: return this.rangeCrosshairLockedOnData;
3981: }
3982:
3983:
3992: public void setRangeCrosshairLockedOnData(boolean flag) {
3993: if (this.rangeCrosshairLockedOnData != flag) {
3994: this.rangeCrosshairLockedOnData = flag;
3995: notifyListeners(new PlotChangeEvent(this));
3996: }
3997: }
3998:
3999:
4006: public double getRangeCrosshairValue() {
4007: return this.rangeCrosshairValue;
4008: }
4009:
4010:
4020: public void setRangeCrosshairValue(double value) {
4021: setRangeCrosshairValue(value, true);
4022: }
4023:
4024:
4034: public void setRangeCrosshairValue(double value, boolean notify) {
4035: this.rangeCrosshairValue = value;
4036: if (isRangeCrosshairVisible() && notify) {
4037: notifyListeners(new PlotChangeEvent(this));
4038: }
4039: }
4040:
4041:
4050: public Stroke getRangeCrosshairStroke() {
4051: return this.rangeCrosshairStroke;
4052: }
4053:
4054:
4063: public void setRangeCrosshairStroke(Stroke stroke) {
4064: if (stroke == null) {
4065: throw new IllegalArgumentException("Null 'stroke' argument.");
4066: }
4067: this.rangeCrosshairStroke = stroke;
4068: notifyListeners(new PlotChangeEvent(this));
4069: }
4070:
4071:
4080: public Paint getRangeCrosshairPaint() {
4081: return this.rangeCrosshairPaint;
4082: }
4083:
4084:
4092: public void setRangeCrosshairPaint(Paint paint) {
4093: if (paint == null) {
4094: throw new IllegalArgumentException("Null 'paint' argument.");
4095: }
4096: this.rangeCrosshairPaint = paint;
4097: notifyListeners(new PlotChangeEvent(this));
4098: }
4099:
4100:
4107: public AxisSpace getFixedDomainAxisSpace() {
4108: return this.fixedDomainAxisSpace;
4109: }
4110:
4111:
4118: public void setFixedDomainAxisSpace(AxisSpace space) {
4119: this.fixedDomainAxisSpace = space;
4120:
4121: }
4122:
4123:
4130: public AxisSpace getFixedRangeAxisSpace() {
4131: return this.fixedRangeAxisSpace;
4132: }
4133:
4134:
4141: public void setFixedRangeAxisSpace(AxisSpace space) {
4142: this.fixedRangeAxisSpace = space;
4143:
4144: }
4145:
4146:
4153: public void zoomDomainAxes(double factor, PlotRenderingInfo info,
4154: Point2D source) {
4155: for (int i = 0; i < this.domainAxes.size(); i++) {
4156: ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i);
4157: if (domainAxis != null) {
4158: domainAxis.resizeRange(factor);
4159: }
4160: }
4161: }
4162:
4163:
4175: public void zoomDomainAxes(double lowerPercent, double upperPercent,
4176: PlotRenderingInfo info, Point2D source) {
4177: for (int i = 0; i < this.domainAxes.size(); i++) {
4178: ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i);
4179: if (domainAxis != null) {
4180: domainAxis.zoomRange(lowerPercent, upperPercent);
4181: }
4182: }
4183: }
4184:
4185:
4192: public void zoomRangeAxes(double factor, PlotRenderingInfo info,
4193: Point2D source) {
4194: for (int i = 0; i < this.rangeAxes.size(); i++) {
4195: ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i);
4196: if (rangeAxis != null) {
4197: rangeAxis.resizeRange(factor);
4198: }
4199: }
4200: }
4201:
4202:
4210: public void zoomRangeAxes(double lowerPercent, double upperPercent,
4211: PlotRenderingInfo info, Point2D source) {
4212: for (int i = 0; i < this.rangeAxes.size(); i++) {
4213: ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i);
4214: if (rangeAxis != null) {
4215: rangeAxis.zoomRange(lowerPercent, upperPercent);
4216: }
4217: }
4218: }
4219:
4220:
4228: public boolean isDomainZoomable() {
4229: return true;
4230: }
4231:
4232:
4240: public boolean isRangeZoomable() {
4241: return true;
4242: }
4243:
4244:
4250: public int getSeriesCount() {
4251: int result = 0;
4252: XYDataset dataset = getDataset();
4253: if (dataset != null) {
4254: result = dataset.getSeriesCount();
4255: }
4256: return result;
4257: }
4258:
4259:
4266: public LegendItemCollection getFixedLegendItems() {
4267: return this.fixedLegendItems;
4268: }
4269:
4270:
4279: public void setFixedLegendItems(LegendItemCollection items) {
4280: this.fixedLegendItems = items;
4281: notifyListeners(new PlotChangeEvent(this));
4282: }
4283:
4284:
4291: public LegendItemCollection getLegendItems() {
4292: if (this.fixedLegendItems != null) {
4293: return this.fixedLegendItems;
4294: }
4295: LegendItemCollection result = new LegendItemCollection();
4296: int count = this.datasets.size();
4297: for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) {
4298: XYDataset dataset = getDataset(datasetIndex);
4299: if (dataset != null) {
4300: XYItemRenderer renderer = getRenderer(datasetIndex);
4301: if (renderer == null) {
4302: renderer = getRenderer(0);
4303: }
4304: if (renderer != null) {
4305: int seriesCount = dataset.getSeriesCount();
4306: for (int i = 0; i < seriesCount; i++) {
4307: if (renderer.isSeriesVisible(i)
4308: && renderer.isSeriesVisibleInLegend(i)) {
4309: LegendItem item = renderer.getLegendItem(
4310: datasetIndex, i);
4311: if (item != null) {
4312: result.add(item);
4313: }
4314: }
4315: }
4316: }
4317: }
4318: }
4319: return result;
4320: }
4321:
4322:
4329: public boolean equals(Object obj) {
4330:
4331: if (obj == this) {
4332: return true;
4333: }
4334: if (!(obj instanceof XYPlot)) {
4335: return false;
4336: }
4337: if (!super.equals(obj)) {
4338: return false;
4339: }
4340:
4341: XYPlot that = (XYPlot) obj;
4342: if (this.weight != that.weight) {
4343: return false;
4344: }
4345: if (this.orientation != that.orientation) {
4346: return false;
4347: }
4348: if (!this.domainAxes.equals(that.domainAxes)) {
4349: return false;
4350: }
4351: if (!this.domainAxisLocations.equals(that.domainAxisLocations)) {
4352: return false;
4353: }
4354: if (this.rangeCrosshairLockedOnData
4355: != that.rangeCrosshairLockedOnData) {
4356: return false;
4357: }
4358: if (this.domainGridlinesVisible != that.domainGridlinesVisible) {
4359: return false;
4360: }
4361: if (this.rangeGridlinesVisible != that.rangeGridlinesVisible) {
4362: return false;
4363: }
4364: if (this.domainZeroBaselineVisible != that.domainZeroBaselineVisible) {
4365: return false;
4366: }
4367: if (this.rangeZeroBaselineVisible != that.rangeZeroBaselineVisible) {
4368: return false;
4369: }
4370: if (this.domainCrosshairVisible != that.domainCrosshairVisible) {
4371: return false;
4372: }
4373: if (this.domainCrosshairValue != that.domainCrosshairValue) {
4374: return false;
4375: }
4376: if (this.domainCrosshairLockedOnData
4377: != that.domainCrosshairLockedOnData) {
4378: return false;
4379: }
4380: if (this.rangeCrosshairVisible != that.rangeCrosshairVisible) {
4381: return false;
4382: }
4383: if (this.rangeCrosshairValue != that.rangeCrosshairValue) {
4384: return false;
4385: }
4386: if (!ObjectUtilities.equal(this.axisOffset, that.axisOffset)) {
4387: return false;
4388: }
4389: if (!ObjectUtilities.equal(this.renderers, that.renderers)) {
4390: return false;
4391: }
4392: if (!ObjectUtilities.equal(this.rangeAxes, that.rangeAxes)) {
4393: return false;
4394: }
4395: if (!this.rangeAxisLocations.equals(that.rangeAxisLocations)) {
4396: return false;
4397: }
4398: if (!ObjectUtilities.equal(this.datasetToDomainAxisMap,
4399: that.datasetToDomainAxisMap)) {
4400: return false;
4401: }
4402: if (!ObjectUtilities.equal(this.datasetToRangeAxisMap,
4403: that.datasetToRangeAxisMap)) {
4404: return false;
4405: }
4406: if (!ObjectUtilities.equal(this.domainGridlineStroke,
4407: that.domainGridlineStroke)) {
4408: return false;
4409: }
4410: if (!PaintUtilities.equal(this.domainGridlinePaint,
4411: that.domainGridlinePaint)) {
4412: return false;
4413: }
4414: if (!ObjectUtilities.equal(this.rangeGridlineStroke,
4415: that.rangeGridlineStroke)) {
4416: return false;
4417: }
4418: if (!PaintUtilities.equal(this.rangeGridlinePaint,
4419: that.rangeGridlinePaint)) {
4420: return false;
4421: }
4422: if (!PaintUtilities.equal(this.domainZeroBaselinePaint,
4423: that.domainZeroBaselinePaint)) {
4424: return false;
4425: }
4426: if (!ObjectUtilities.equal(this.domainZeroBaselineStroke,
4427: that.domainZeroBaselineStroke)) {
4428: return false;
4429: }
4430: if (!PaintUtilities.equal(this.rangeZeroBaselinePaint,
4431: that.rangeZeroBaselinePaint)) {
4432: return false;
4433: }
4434: if (!ObjectUtilities.equal(this.rangeZeroBaselineStroke,
4435: that.rangeZeroBaselineStroke)) {
4436: return false;
4437: }
4438: if (!ObjectUtilities.equal(this.domainCrosshairStroke,
4439: that.domainCrosshairStroke)) {
4440: return false;
4441: }
4442: if (!PaintUtilities.equal(this.domainCrosshairPaint,
4443: that.domainCrosshairPaint)) {
4444: return false;
4445: }
4446: if (!ObjectUtilities.equal(this.rangeCrosshairStroke,
4447: that.rangeCrosshairStroke)) {
4448: return false;
4449: }
4450: if (!PaintUtilities.equal(this.rangeCrosshairPaint,
4451: that.rangeCrosshairPaint)) {
4452: return false;
4453: }
4454: if (!ObjectUtilities.equal(this.foregroundDomainMarkers,
4455: that.foregroundDomainMarkers)) {
4456: return false;
4457: }
4458: if (!ObjectUtilities.equal(this.backgroundDomainMarkers,
4459: that.backgroundDomainMarkers)) {
4460: return false;
4461: }
4462: if (!ObjectUtilities.equal(this.foregroundRangeMarkers,
4463: that.foregroundRangeMarkers)) {
4464: return false;
4465: }
4466: if (!ObjectUtilities.equal(this.backgroundRangeMarkers,
4467: that.backgroundRangeMarkers)) {
4468: return false;
4469: }
4470: if (!ObjectUtilities.equal(this.foregroundDomainMarkers,
4471: that.foregroundDomainMarkers)) {
4472: return false;
4473: }
4474: if (!ObjectUtilities.equal(this.backgroundDomainMarkers,
4475: that.backgroundDomainMarkers)) {
4476: return false;
4477: }
4478: if (!ObjectUtilities.equal(this.foregroundRangeMarkers,
4479: that.foregroundRangeMarkers)) {
4480: return false;
4481: }
4482: if (!ObjectUtilities.equal(this.backgroundRangeMarkers,
4483: that.backgroundRangeMarkers)) {
4484: return false;
4485: }
4486: if (!ObjectUtilities.equal(this.annotations, that.annotations)) {
4487: return false;
4488: }
4489: if (!this.quadrantOrigin.equals(that.quadrantOrigin)) {
4490: return false;
4491: }
4492: for (int i = 0; i < 4; i++) {
4493: if (!PaintUtilities.equal(this.quadrantPaint[i],
4494: that.quadrantPaint[i])) {
4495: return false;
4496: }
4497: }
4498: return true;
4499: }
4500:
4501:
4509: public Object clone() throws CloneNotSupportedException {
4510:
4511: XYPlot clone = (XYPlot) super.clone();
4512: clone.domainAxes = (ObjectList) ObjectUtilities.clone(this.domainAxes);
4513: for (int i = 0; i < this.domainAxes.size(); i++) {
4514: ValueAxis axis = (ValueAxis) this.domainAxes.get(i);
4515: if (axis != null) {
4516: ValueAxis clonedAxis = (ValueAxis) axis.clone();
4517: clone.domainAxes.set(i, clonedAxis);
4518: clonedAxis.setPlot(clone);
4519: clonedAxis.addChangeListener(clone);
4520: }
4521: }
4522: clone.domainAxisLocations
4523: = (ObjectList) this.domainAxisLocations.clone();
4524:
4525: clone.rangeAxes = (ObjectList) ObjectUtilities.clone(this.rangeAxes);
4526: for (int i = 0; i < this.rangeAxes.size(); i++) {
4527: ValueAxis axis = (ValueAxis) this.rangeAxes.get(i);
4528: if (axis != null) {
4529: ValueAxis clonedAxis = (ValueAxis) axis.clone();
4530: clone.rangeAxes.set(i, clonedAxis);
4531: clonedAxis.setPlot(clone);
4532: clonedAxis.addChangeListener(clone);
4533: }
4534: }
4535: clone.rangeAxisLocations
4536: = (ObjectList) ObjectUtilities.clone(this.rangeAxisLocations);
4537:
4538:
4539: clone.datasets = (ObjectList) ObjectUtilities.clone(this.datasets);
4540: for (int i = 0; i < clone.datasets.size(); ++i) {
4541: XYDataset d = getDataset(i);
4542: if (d != null) {
4543: d.addChangeListener(clone);
4544: }
4545: }
4546:
4547: clone.datasetToDomainAxisMap = new TreeMap();
4548: clone.datasetToDomainAxisMap.putAll(this.datasetToDomainAxisMap);
4549: clone.datasetToRangeAxisMap = new TreeMap();
4550: clone.datasetToRangeAxisMap.putAll(this.datasetToRangeAxisMap);
4551:
4552: clone.renderers = (ObjectList) ObjectUtilities.clone(this.renderers);
4553: for (int i = 0; i < this.renderers.size(); i++) {
4554: XYItemRenderer renderer2 = (XYItemRenderer) this.renderers.get(i);
4555: if (renderer2 instanceof PublicCloneable) {
4556: PublicCloneable pc = (PublicCloneable) renderer2;
4557: clone.renderers.set(i, pc.clone());
4558: }
4559: }
4560: clone.foregroundDomainMarkers = (Map) ObjectUtilities.clone(
4561: this.foregroundDomainMarkers);
4562: clone.backgroundDomainMarkers = (Map) ObjectUtilities.clone(
4563: this.backgroundDomainMarkers);
4564: clone.foregroundRangeMarkers = (Map) ObjectUtilities.clone(
4565: this.foregroundRangeMarkers);
4566: clone.backgroundRangeMarkers = (Map) ObjectUtilities.clone(
4567: this.backgroundRangeMarkers);
4568: clone.annotations = (List) ObjectUtilities.deepClone(this.annotations);
4569: if (this.fixedDomainAxisSpace != null) {
4570: clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone(
4571: this.fixedDomainAxisSpace);
4572: }
4573: if (this.fixedRangeAxisSpace != null) {
4574: clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone(
4575: this.fixedRangeAxisSpace);
4576: }
4577:
4578: clone.quadrantOrigin = (Point2D) ObjectUtilities.clone(
4579: this.quadrantOrigin);
4580: clone.quadrantPaint = (Paint[]) this.quadrantPaint.clone();
4581: return clone;
4582:
4583: }
4584:
4585:
4592: private void writeObject(ObjectOutputStream stream) throws IOException {
4593: stream.defaultWriteObject();
4594: SerialUtilities.writeStroke(this.domainGridlineStroke, stream);
4595: SerialUtilities.writePaint(this.domainGridlinePaint, stream);
4596: SerialUtilities.writeStroke(this.rangeGridlineStroke, stream);
4597: SerialUtilities.writePaint(this.rangeGridlinePaint, stream);
4598: SerialUtilities.writeStroke(this.rangeZeroBaselineStroke, stream);
4599: SerialUtilities.writePaint(this.rangeZeroBaselinePaint, stream);
4600: SerialUtilities.writeStroke(this.domainCrosshairStroke, stream);
4601: SerialUtilities.writePaint(this.domainCrosshairPaint, stream);
4602: SerialUtilities.writeStroke(this.rangeCrosshairStroke, stream);
4603: SerialUtilities.writePaint(this.rangeCrosshairPaint, stream);
4604: SerialUtilities.writePaint(this.domainTickBandPaint, stream);
4605: SerialUtilities.writePaint(this.rangeTickBandPaint, stream);
4606: SerialUtilities.writePoint2D(this.quadrantOrigin, stream);
4607: for (int i = 0; i < 4; i++) {
4608: SerialUtilities.writePaint(this.quadrantPaint[i], stream);
4609: }
4610: SerialUtilities.writeStroke(this.domainZeroBaselineStroke, stream);
4611: SerialUtilities.writePaint(this.domainZeroBaselinePaint, stream);
4612: }
4613:
4614:
4622: private void readObject(ObjectInputStream stream)
4623: throws IOException, ClassNotFoundException {
4624:
4625: stream.defaultReadObject();
4626: this.domainGridlineStroke = SerialUtilities.readStroke(stream);
4627: this.domainGridlinePaint = SerialUtilities.readPaint(stream);
4628: this.rangeGridlineStroke = SerialUtilities.readStroke(stream);
4629: this.rangeGridlinePaint = SerialUtilities.readPaint(stream);
4630: this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream);
4631: this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream);
4632: this.domainCrosshairStroke = SerialUtilities.readStroke(stream);
4633: this.domainCrosshairPaint = SerialUtilities.readPaint(stream);
4634: this.rangeCrosshairStroke = SerialUtilities.readStroke(stream);
4635: this.rangeCrosshairPaint = SerialUtilities.readPaint(stream);
4636: this.domainTickBandPaint = SerialUtilities.readPaint(stream);
4637: this.rangeTickBandPaint = SerialUtilities.readPaint(stream);
4638: this.quadrantOrigin = SerialUtilities.readPoint2D(stream);
4639: this.quadrantPaint = new Paint[4];
4640: for (int i = 0; i < 4; i++) {
4641: this.quadrantPaint[i] = SerialUtilities.readPaint(stream);
4642: }
4643:
4644: this.domainZeroBaselineStroke = SerialUtilities.readStroke(stream);
4645: this.domainZeroBaselinePaint = SerialUtilities.readPaint(stream);
4646:
4647:
4648:
4649: int domainAxisCount = this.domainAxes.size();
4650: for (int i = 0; i < domainAxisCount; i++) {
4651: Axis axis = (Axis) this.domainAxes.get(i);
4652: if (axis != null) {
4653: axis.setPlot(this);
4654: axis.addChangeListener(this);
4655: }
4656: }
4657: int rangeAxisCount = this.rangeAxes.size();
4658: for (int i = 0; i < rangeAxisCount; i++) {
4659: Axis axis = (Axis) this.rangeAxes.get(i);
4660: if (axis != null) {
4661: axis.setPlot(this);
4662: axis.addChangeListener(this);
4663: }
4664: }
4665: int datasetCount = this.datasets.size();
4666: for (int i = 0; i < datasetCount; i++) {
4667: Dataset dataset = (Dataset) this.datasets.get(i);
4668: if (dataset != null) {
4669: dataset.addChangeListener(this);
4670: }
4671: }
4672: int rendererCount = this.renderers.size();
4673: for (int i = 0; i < rendererCount; i++) {
4674: XYItemRenderer renderer = (XYItemRenderer) this.renderers.get(i);
4675: if (renderer != null) {
4676: renderer.addChangeListener(this);
4677: }
4678: }
4679:
4680: }
4681:
4682: }