1:
87:
88: package ;
89:
90: import ;
91: import ;
92: import ;
93: import ;
94: import ;
95: import ;
96: import ;
97: import ;
98: import ;
99: import ;
100:
101: import ;
102: import ;
103: import ;
104: import ;
105: import ;
106: import ;
107: import ;
108: import ;
109: import ;
110: import ;
111: import ;
112: import ;
113: import ;
114: import ;
115: import ;
116: import ;
117: import ;
118: import ;
119: import ;
120: import ;
121: import ;
122: import ;
123: import ;
124: import ;
125: import ;
126: import ;
127: import ;
128: import ;
129: import ;
130: import ;
131: import ;
132: import ;
133: import ;
134:
135:
141: public abstract class AbstractCategoryItemRenderer extends AbstractRenderer
142: implements CategoryItemRenderer, Cloneable, PublicCloneable, Serializable {
143:
144:
145: private static final long serialVersionUID = 1247553218442497391L;
146:
147:
148: private CategoryPlot plot;
149:
150:
151: private CategoryItemLabelGenerator itemLabelGenerator;
152:
153:
154: private ObjectList itemLabelGeneratorList;
155:
156:
157: private CategoryItemLabelGenerator baseItemLabelGenerator;
158:
159:
160: private CategoryToolTipGenerator toolTipGenerator;
161:
162:
163: private ObjectList toolTipGeneratorList;
164:
165:
166: private CategoryToolTipGenerator baseToolTipGenerator;
167:
168:
169: private CategoryURLGenerator itemURLGenerator;
170:
171:
172: private ObjectList itemURLGeneratorList;
173:
174:
175: private CategoryURLGenerator baseItemURLGenerator;
176:
177:
178: private CategorySeriesLabelGenerator legendItemLabelGenerator;
179:
180:
181: private CategorySeriesLabelGenerator legendItemToolTipGenerator;
182:
183:
184: private CategorySeriesLabelGenerator legendItemURLGenerator;
185:
186:
187: private transient int rowCount;
188:
189:
190: private transient int columnCount;
191:
192:
199: protected AbstractCategoryItemRenderer() {
200: this.itemLabelGenerator = null;
201: this.itemLabelGeneratorList = new ObjectList();
202: this.toolTipGenerator = null;
203: this.toolTipGeneratorList = new ObjectList();
204: this.itemURLGenerator = null;
205: this.itemURLGeneratorList = new ObjectList();
206: this.legendItemLabelGenerator
207: = new StandardCategorySeriesLabelGenerator();
208: }
209:
210:
217: public int getPassCount() {
218: return 1;
219: }
220:
221:
228: public CategoryPlot getPlot() {
229: return this.plot;
230: }
231:
232:
239: public void setPlot(CategoryPlot plot) {
240: if (plot == null) {
241: throw new IllegalArgumentException("Null 'plot' argument.");
242: }
243: this.plot = plot;
244: }
245:
246:
247:
248:
259: public CategoryItemLabelGenerator getItemLabelGenerator(int row,
260: int column) {
261: return getSeriesItemLabelGenerator(row);
262: }
263:
264:
271: public CategoryItemLabelGenerator getSeriesItemLabelGenerator(int series) {
272:
273:
274: if (this.itemLabelGenerator != null) {
275: return this.itemLabelGenerator;
276: }
277:
278:
279: CategoryItemLabelGenerator generator = (CategoryItemLabelGenerator)
280: this.itemLabelGeneratorList.get(series);
281: if (generator == null) {
282: generator = this.baseItemLabelGenerator;
283: }
284: return generator;
285:
286: }
287:
288:
294: public void setItemLabelGenerator(CategoryItemLabelGenerator generator) {
295: this.itemLabelGenerator = generator;
296: notifyListeners(new RendererChangeEvent(this));
297: }
298:
299:
306: public void setSeriesItemLabelGenerator(int series,
307: CategoryItemLabelGenerator generator) {
308: this.itemLabelGeneratorList.set(series, generator);
309: notifyListeners(new RendererChangeEvent(this));
310: }
311:
312:
317: public CategoryItemLabelGenerator getBaseItemLabelGenerator() {
318: return this.baseItemLabelGenerator;
319: }
320:
321:
327: public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator)
328: {
329: this.baseItemLabelGenerator = generator;
330: notifyListeners(new RendererChangeEvent(this));
331: }
332:
333:
334:
335:
347: public CategoryToolTipGenerator getToolTipGenerator(int row, int column) {
348:
349: CategoryToolTipGenerator result = null;
350: if (this.toolTipGenerator != null) {
351: result = this.toolTipGenerator;
352: }
353: else {
354: result = getSeriesToolTipGenerator(row);
355: if (result == null) {
356: result = this.baseToolTipGenerator;
357: }
358: }
359: return result;
360: }
361:
362:
368: public CategoryToolTipGenerator getToolTipGenerator() {
369: return this.toolTipGenerator;
370: }
371:
372:
379: public void setToolTipGenerator(CategoryToolTipGenerator generator) {
380: this.toolTipGenerator = generator;
381: notifyListeners(new RendererChangeEvent(this));
382: }
383:
384:
392: public CategoryToolTipGenerator getSeriesToolTipGenerator(int series) {
393: return (CategoryToolTipGenerator) this.toolTipGeneratorList.get(series);
394: }
395:
396:
404: public void setSeriesToolTipGenerator(int series,
405: CategoryToolTipGenerator generator) {
406: this.toolTipGeneratorList.set(series, generator);
407: notifyListeners(new RendererChangeEvent(this));
408: }
409:
410:
415: public CategoryToolTipGenerator getBaseToolTipGenerator() {
416: return this.baseToolTipGenerator;
417: }
418:
419:
426: public void setBaseToolTipGenerator(CategoryToolTipGenerator generator) {
427: this.baseToolTipGenerator = generator;
428: notifyListeners(new RendererChangeEvent(this));
429: }
430:
431:
432:
433:
443: public CategoryURLGenerator getItemURLGenerator(int row, int column) {
444: return getSeriesItemURLGenerator(row);
445: }
446:
447:
454: public CategoryURLGenerator getSeriesItemURLGenerator(int series) {
455:
456:
457: if (this.itemURLGenerator != null) {
458: return this.itemURLGenerator;
459: }
460:
461:
462: CategoryURLGenerator generator
463: = (CategoryURLGenerator) this.itemURLGeneratorList.get(series);
464: if (generator == null) {
465: generator = this.baseItemURLGenerator;
466: }
467: return generator;
468:
469: }
470:
471:
476: public void setItemURLGenerator(CategoryURLGenerator generator) {
477: this.itemURLGenerator = generator;
478: }
479:
480:
486: public void setSeriesItemURLGenerator(int series,
487: CategoryURLGenerator generator) {
488: this.itemURLGeneratorList.set(series, generator);
489: }
490:
491:
496: public CategoryURLGenerator getBaseItemURLGenerator() {
497: return this.baseItemURLGenerator;
498: }
499:
500:
505: public void setBaseItemURLGenerator(CategoryURLGenerator generator) {
506: this.baseItemURLGenerator = generator;
507: }
508:
509:
515: public int getRowCount() {
516: return this.rowCount;
517: }
518:
519:
525: public int getColumnCount() {
526: return this.columnCount;
527: }
528:
529:
550: public CategoryItemRendererState initialise(Graphics2D g2,
551: Rectangle2D dataArea,
552: CategoryPlot plot,
553: int rendererIndex,
554: PlotRenderingInfo info) {
555:
556: setPlot(plot);
557: CategoryDataset data = plot.getDataset(rendererIndex);
558: if (data != null) {
559: this.rowCount = data.getRowCount();
560: this.columnCount = data.getColumnCount();
561: }
562: else {
563: this.rowCount = 0;
564: this.columnCount = 0;
565: }
566: return new CategoryItemRendererState(info);
567:
568: }
569:
570:
579: public Range findRangeBounds(CategoryDataset dataset) {
580: return DatasetUtilities.findRangeBounds(dataset);
581: }
582:
583:
592: public void drawBackground(Graphics2D g2,
593: CategoryPlot plot,
594: Rectangle2D dataArea) {
595:
596: plot.drawBackground(g2, dataArea);
597:
598: }
599:
600:
609: public void drawOutline(Graphics2D g2,
610: CategoryPlot plot,
611: Rectangle2D dataArea) {
612:
613: plot.drawOutline(g2, dataArea);
614:
615: }
616:
617:
630: public void drawDomainGridline(Graphics2D g2,
631: CategoryPlot plot,
632: Rectangle2D dataArea,
633: double value) {
634:
635: Line2D line = null;
636: PlotOrientation orientation = plot.getOrientation();
637:
638: if (orientation == PlotOrientation.HORIZONTAL) {
639: line = new Line2D.Double(dataArea.getMinX(), value,
640: dataArea.getMaxX(), value);
641: }
642: else if (orientation == PlotOrientation.VERTICAL) {
643: line = new Line2D.Double(value, dataArea.getMinY(), value,
644: dataArea.getMaxY());
645: }
646:
647: Paint paint = plot.getDomainGridlinePaint();
648: if (paint == null) {
649: paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
650: }
651: g2.setPaint(paint);
652:
653: Stroke stroke = plot.getDomainGridlineStroke();
654: if (stroke == null) {
655: stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
656: }
657: g2.setStroke(stroke);
658:
659: g2.draw(line);
660:
661: }
662:
663:
674: public void drawRangeGridline(Graphics2D g2,
675: CategoryPlot plot,
676: ValueAxis axis,
677: Rectangle2D dataArea,
678: double value) {
679:
680: Range range = axis.getRange();
681: if (!range.contains(value)) {
682: return;
683: }
684:
685: PlotOrientation orientation = plot.getOrientation();
686: double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
687: Line2D line = null;
688: if (orientation == PlotOrientation.HORIZONTAL) {
689: line = new Line2D.Double(v, dataArea.getMinY(), v,
690: dataArea.getMaxY());
691: }
692: else if (orientation == PlotOrientation.VERTICAL) {
693: line = new Line2D.Double(dataArea.getMinX(), v,
694: dataArea.getMaxX(), v);
695: }
696:
697: Paint paint = plot.getRangeGridlinePaint();
698: if (paint == null) {
699: paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
700: }
701: g2.setPaint(paint);
702:
703: Stroke stroke = plot.getRangeGridlineStroke();
704: if (stroke == null) {
705: stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
706: }
707: g2.setStroke(stroke);
708:
709: g2.draw(line);
710:
711: }
712:
713:
722: public void drawDomainMarker(Graphics2D g2,
723: CategoryPlot plot,
724: CategoryAxis axis,
725: CategoryMarker marker,
726: Rectangle2D dataArea) {
727:
728: Comparable category = marker.getKey();
729: CategoryDataset dataset = plot.getDataset(plot.getIndexOf(this));
730: int columnIndex = dataset.getColumnIndex(category);
731: if (columnIndex < 0) {
732: return;
733: }
734: PlotOrientation orientation = plot.getOrientation();
735: Rectangle2D bounds = null;
736: if (marker.getDrawAsLine()) {
737: double v = axis.getCategoryMiddle(columnIndex,
738: dataset.getColumnCount(), dataArea,
739: plot.getDomainAxisEdge());
740: Line2D line = null;
741: if (orientation == PlotOrientation.HORIZONTAL) {
742: line = new Line2D.Double(dataArea.getMinX(), v,
743: dataArea.getMaxX(), v);
744: }
745: else if (orientation == PlotOrientation.VERTICAL) {
746: line = new Line2D.Double(v, dataArea.getMinY(), v,
747: dataArea.getMaxY());
748: }
749:
750: g2.setPaint(marker.getPaint());
751: g2.setStroke(marker.getStroke());
752: g2.draw(line);
753: bounds = line.getBounds2D();
754: }
755: else {
756: double v0 = axis.getCategoryStart(columnIndex,
757: dataset.getColumnCount(), dataArea,
758: plot.getDomainAxisEdge());
759: double v1 = axis.getCategoryEnd(columnIndex,
760: dataset.getColumnCount(), dataArea,
761: plot.getDomainAxisEdge());
762: Rectangle2D area = null;
763: if (orientation == PlotOrientation.HORIZONTAL) {
764: area = new Rectangle2D.Double(dataArea.getMinX(), v0,
765: dataArea.getWidth(), (v1 - v0));
766: }
767: else if (orientation == PlotOrientation.VERTICAL) {
768: area = new Rectangle2D.Double(v0, dataArea.getMinY(),
769: (v1 - v0), dataArea.getHeight());
770: }
771: g2.setPaint(marker.getPaint());
772: g2.fill(area);
773: bounds = area;
774: }
775:
776: String label = marker.getLabel();
777: RectangleAnchor anchor = marker.getLabelAnchor();
778: if (label != null) {
779: Font labelFont = marker.getLabelFont();
780: g2.setFont(labelFont);
781: g2.setPaint(marker.getLabelPaint());
782: Point2D coordinates = calculateDomainMarkerTextAnchorPoint(
783: g2, orientation, dataArea, bounds, marker.getLabelOffset(),
784: marker.getLabelOffsetType(), anchor);
785: TextUtilities.drawAlignedString(label, g2,
786: (float) coordinates.getX(), (float) coordinates.getY(),
787: marker.getLabelTextAnchor());
788: }
789: }
790:
791:
800: public void drawRangeMarker(Graphics2D g2,
801: CategoryPlot plot,
802: ValueAxis axis,
803: Marker marker,
804: Rectangle2D dataArea) {
805:
806: if (marker instanceof ValueMarker) {
807: ValueMarker vm = (ValueMarker) marker;
808: double value = vm.getValue();
809: Range range = axis.getRange();
810:
811: if (!range.contains(value)) {
812: return;
813: }
814:
815: PlotOrientation orientation = plot.getOrientation();
816: double v = axis.valueToJava2D(value, dataArea,
817: plot.getRangeAxisEdge());
818: Line2D line = null;
819: if (orientation == PlotOrientation.HORIZONTAL) {
820: line = new Line2D.Double(v, dataArea.getMinY(), v,
821: dataArea.getMaxY());
822: }
823: else if (orientation == PlotOrientation.VERTICAL) {
824: line = new Line2D.Double(dataArea.getMinX(), v,
825: dataArea.getMaxX(), v);
826: }
827:
828: g2.setPaint(marker.getPaint());
829: g2.setStroke(marker.getStroke());
830: g2.draw(line);
831:
832: String label = marker.getLabel();
833: RectangleAnchor anchor = marker.getLabelAnchor();
834: if (label != null) {
835: Font labelFont = marker.getLabelFont();
836: g2.setFont(labelFont);
837: g2.setPaint(marker.getLabelPaint());
838: Point2D coordinates = calculateRangeMarkerTextAnchorPoint(
839: g2, orientation, dataArea, line.getBounds2D(),
840: marker.getLabelOffset(), LengthAdjustmentType.EXPAND,
841: anchor);
842: TextUtilities.drawAlignedString(label, g2,
843: (float) coordinates.getX(), (float) coordinates.getY(),
844: marker.getLabelTextAnchor());
845: }
846: }
847: else if (marker instanceof IntervalMarker) {
848:
849: IntervalMarker im = (IntervalMarker) marker;
850: double start = im.getStartValue();
851: double end = im.getEndValue();
852: Range range = axis.getRange();
853: if (!(range.intersects(start, end))) {
854: return;
855: }
856:
857:
858: start = range.constrain(start);
859: end = range.constrain(end);
860:
861: double v0 = axis.valueToJava2D(start, dataArea,
862: plot.getRangeAxisEdge());
863: double v1 = axis.valueToJava2D(end, dataArea,
864: plot.getRangeAxisEdge());
865:
866: PlotOrientation orientation = plot.getOrientation();
867: Rectangle2D rect = null;
868: if (orientation == PlotOrientation.HORIZONTAL) {
869: rect = new Rectangle2D.Double(v0, dataArea.getMinY(), v1 - v0,
870: dataArea.getHeight());
871: }
872: else if (orientation == PlotOrientation.VERTICAL) {
873: rect = new Rectangle2D.Double(dataArea.getMinX(),
874: Math.min(v0, v1), dataArea.getWidth(),
875: Math.abs(v1 - v0));
876: }
877: Paint p = marker.getPaint();
878: if (p instanceof GradientPaint) {
879: GradientPaint gp = (GradientPaint) p;
880: GradientPaintTransformer t = im.getGradientPaintTransformer();
881: if (t != null) {
882: gp = t.transform(gp, rect);
883: }
884: g2.setPaint(gp);
885: }
886: else {
887: g2.setPaint(p);
888: }
889: g2.fill(rect);
890:
891: String label = marker.getLabel();
892: RectangleAnchor anchor = marker.getLabelAnchor();
893: if (label != null) {
894: Font labelFont = marker.getLabelFont();
895: g2.setFont(labelFont);
896: g2.setPaint(marker.getLabelPaint());
897: Point2D coordinates = calculateRangeMarkerTextAnchorPoint(
898: g2, orientation, dataArea, rect,
899: marker.getLabelOffset(), marker.getLabelOffsetType(),
900: anchor);
901: TextUtilities.drawAlignedString(label, g2,
902: (float) coordinates.getX(), (float) coordinates.getY(),
903: marker.getLabelTextAnchor());
904: }
905:
906: }
907:
908: }
909:
910:
924: protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2,
925: PlotOrientation orientation,
926: Rectangle2D dataArea,
927: Rectangle2D markerArea,
928: RectangleInsets markerOffset,
929: LengthAdjustmentType labelOffsetType,
930: RectangleAnchor anchor) {
931:
932: Rectangle2D anchorRect = null;
933: if (orientation == PlotOrientation.HORIZONTAL) {
934: anchorRect = markerOffset.createAdjustedRectangle(markerArea,
935: LengthAdjustmentType.CONTRACT, labelOffsetType);
936: }
937: else if (orientation == PlotOrientation.VERTICAL) {
938: anchorRect = markerOffset.createAdjustedRectangle(markerArea,
939: labelOffsetType, LengthAdjustmentType.CONTRACT);
940: }
941: return RectangleAnchor.coordinates(anchorRect, anchor);
942:
943: }
944:
945:
958: protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2,
959: PlotOrientation orientation,
960: Rectangle2D dataArea,
961: Rectangle2D markerArea,
962: RectangleInsets markerOffset,
963: LengthAdjustmentType labelOffsetType,
964: RectangleAnchor anchor) {
965:
966: Rectangle2D anchorRect = null;
967: if (orientation == PlotOrientation.HORIZONTAL) {
968: anchorRect = markerOffset.createAdjustedRectangle(markerArea,
969: labelOffsetType, LengthAdjustmentType.CONTRACT);
970: }
971: else if (orientation == PlotOrientation.VERTICAL) {
972: anchorRect = markerOffset.createAdjustedRectangle(markerArea,
973: LengthAdjustmentType.CONTRACT, labelOffsetType);
974: }
975: return RectangleAnchor.coordinates(anchorRect, anchor);
976:
977: }
978:
979:
987: public LegendItem getLegendItem(int datasetIndex, int series) {
988:
989: CategoryPlot p = getPlot();
990: if (p == null) {
991: return null;
992: }
993:
994: CategoryDataset dataset;
995: dataset = p.getDataset(datasetIndex);
996: String label = this.legendItemLabelGenerator.generateLabel(dataset,
997: series);
998: String description = label;
999: String toolTipText = null;
1000: if (this.legendItemToolTipGenerator != null) {
1001: toolTipText = this.legendItemToolTipGenerator.generateLabel(
1002: dataset, series);
1003: }
1004: String urlText = null;
1005: if (this.legendItemURLGenerator != null) {
1006: urlText = this.legendItemURLGenerator.generateLabel(dataset,
1007: series);
1008: }
1009: Shape shape = getSeriesShape(series);
1010: Paint paint = getSeriesPaint(series);
1011: Paint outlinePaint = getSeriesOutlinePaint(series);
1012: Stroke outlineStroke = getSeriesOutlineStroke(series);
1013:
1014: LegendItem item = new LegendItem(label, description, toolTipText,
1015: urlText, shape, paint, outlineStroke, outlinePaint);
1016: item.setSeriesIndex(series);
1017: item.setDatasetIndex(datasetIndex);
1018: return item;
1019: }
1020:
1021:
1028: public boolean equals(Object obj) {
1029:
1030: if (obj == this) {
1031: return true;
1032: }
1033: if (!(obj instanceof AbstractCategoryItemRenderer)) {
1034: return false;
1035: }
1036: if (!super.equals(obj)) {
1037: return false;
1038: }
1039:
1040: AbstractCategoryItemRenderer that = (AbstractCategoryItemRenderer) obj;
1041:
1042: if (!ObjectUtilities.equal(this.itemLabelGenerator,
1043: that.itemLabelGenerator)) {
1044: return false;
1045: }
1046: if (!ObjectUtilities.equal(this.itemLabelGeneratorList,
1047: that.itemLabelGeneratorList)) {
1048: return false;
1049: }
1050: if (!ObjectUtilities.equal(this.baseItemLabelGenerator,
1051: that.baseItemLabelGenerator)) {
1052: return false;
1053: }
1054: if (!ObjectUtilities.equal(this.toolTipGenerator,
1055: that.toolTipGenerator)) {
1056: return false;
1057: }
1058: if (!ObjectUtilities.equal(this.toolTipGeneratorList,
1059: that.toolTipGeneratorList)) {
1060: return false;
1061: }
1062: if (!ObjectUtilities.equal(this.baseToolTipGenerator,
1063: that.baseToolTipGenerator)) {
1064: return false;
1065: }
1066: if (!ObjectUtilities.equal(this.itemURLGenerator,
1067: that.itemURLGenerator)) {
1068: return false;
1069: }
1070: if (!ObjectUtilities.equal(this.itemURLGeneratorList,
1071: that.itemURLGeneratorList)) {
1072: return false;
1073: }
1074: if (!ObjectUtilities.equal(this.baseItemURLGenerator,
1075: that.baseItemURLGenerator)) {
1076: return false;
1077: }
1078:
1079: return true;
1080:
1081: }
1082:
1083:
1088: public int hashCode() {
1089: int result = super.hashCode();
1090: return result;
1091: }
1092:
1093:
1098: public DrawingSupplier getDrawingSupplier() {
1099: DrawingSupplier result = null;
1100: CategoryPlot cp = getPlot();
1101: if (cp != null) {
1102: result = cp.getDrawingSupplier();
1103: }
1104: return result;
1105: }
1106:
1107:
1120: protected void drawItemLabel(Graphics2D g2,
1121: PlotOrientation orientation,
1122: CategoryDataset dataset,
1123: int row, int column,
1124: double x, double y,
1125: boolean negative) {
1126:
1127: CategoryItemLabelGenerator generator
1128: = getItemLabelGenerator(row, column);
1129: if (generator != null) {
1130: Font labelFont = getItemLabelFont(row, column);
1131: Paint paint = getItemLabelPaint(row, column);
1132: g2.setFont(labelFont);
1133: g2.setPaint(paint);
1134: String label = generator.generateLabel(dataset, row, column);
1135: ItemLabelPosition position = null;
1136: if (!negative) {
1137: position = getPositiveItemLabelPosition(row, column);
1138: }
1139: else {
1140: position = getNegativeItemLabelPosition(row, column);
1141: }
1142: Point2D anchorPoint = calculateLabelAnchorPoint(
1143: position.getItemLabelAnchor(), x, y, orientation);
1144: TextUtilities.drawRotatedString(label, g2,
1145: (float) anchorPoint.getX(), (float) anchorPoint.getY(),
1146: position.getTextAnchor(),
1147: position.getAngle(), position.getRotationAnchor());
1148: }
1149:
1150: }
1151:
1152:
1162: public Object clone() throws CloneNotSupportedException {
1163:
1164: AbstractCategoryItemRenderer clone
1165: = (AbstractCategoryItemRenderer) super.clone();
1166:
1167: if (this.itemLabelGenerator != null) {
1168: if (this.itemLabelGenerator instanceof PublicCloneable) {
1169: PublicCloneable pc = (PublicCloneable) this.itemLabelGenerator;
1170: clone.itemLabelGenerator
1171: = (CategoryItemLabelGenerator) pc.clone();
1172: }
1173: else {
1174: throw new CloneNotSupportedException(
1175: "ItemLabelGenerator not cloneable."
1176: );
1177: }
1178: }
1179:
1180: if (this.itemLabelGeneratorList != null) {
1181: clone.itemLabelGeneratorList
1182: = (ObjectList) this.itemLabelGeneratorList.clone();
1183: }
1184:
1185: if (this.baseItemLabelGenerator != null) {
1186: if (this.baseItemLabelGenerator instanceof PublicCloneable) {
1187: PublicCloneable pc
1188: = (PublicCloneable) this.baseItemLabelGenerator;
1189: clone.baseItemLabelGenerator
1190: = (CategoryItemLabelGenerator) pc.clone();
1191: }
1192: else {
1193: throw new CloneNotSupportedException(
1194: "ItemLabelGenerator not cloneable."
1195: );
1196: }
1197: }
1198:
1199: if (this.toolTipGenerator != null) {
1200: if (this.toolTipGenerator instanceof PublicCloneable) {
1201: PublicCloneable pc = (PublicCloneable) this.toolTipGenerator;
1202: clone.toolTipGenerator = (CategoryToolTipGenerator) pc.clone();
1203: }
1204: else {
1205: throw new CloneNotSupportedException(
1206: "Tool tip generator not cloneable.");
1207: }
1208: }
1209:
1210: if (this.toolTipGeneratorList != null) {
1211: clone.toolTipGeneratorList
1212: = (ObjectList) this.toolTipGeneratorList.clone();
1213: }
1214:
1215: if (this.baseToolTipGenerator != null) {
1216: if (this.baseToolTipGenerator instanceof PublicCloneable) {
1217: PublicCloneable pc
1218: = (PublicCloneable) this.baseToolTipGenerator;
1219: clone.baseToolTipGenerator
1220: = (CategoryToolTipGenerator) pc.clone();
1221: }
1222: else {
1223: throw new CloneNotSupportedException(
1224: "Base tool tip generator not cloneable.");
1225: }
1226: }
1227:
1228: if (this.itemURLGenerator != null) {
1229: if (this.itemURLGenerator instanceof PublicCloneable) {
1230: PublicCloneable pc = (PublicCloneable) this.itemURLGenerator;
1231: clone.itemURLGenerator = (CategoryURLGenerator) pc.clone();
1232: }
1233: else {
1234: throw new CloneNotSupportedException(
1235: "Item URL generator not cloneable.");
1236: }
1237: }
1238:
1239: if (this.itemURLGeneratorList != null) {
1240: clone.itemURLGeneratorList
1241: = (ObjectList) this.itemURLGeneratorList.clone();
1242: }
1243:
1244: if (this.baseItemURLGenerator != null) {
1245: if (this.baseItemURLGenerator instanceof PublicCloneable) {
1246: PublicCloneable pc
1247: = (PublicCloneable) this.baseItemURLGenerator;
1248: clone.baseItemURLGenerator = (CategoryURLGenerator) pc.clone();
1249: }
1250: else {
1251: throw new CloneNotSupportedException(
1252: "Base item URL generator not cloneable.");
1253: }
1254: }
1255:
1256: return clone;
1257: }
1258:
1259:
1267: protected CategoryAxis getDomainAxis(CategoryPlot plot, int index) {
1268: CategoryAxis result = plot.getDomainAxis(index);
1269: if (result == null) {
1270: result = plot.getDomainAxis();
1271: }
1272: return result;
1273: }
1274:
1275:
1283: protected ValueAxis getRangeAxis(CategoryPlot plot, int index) {
1284: ValueAxis result = plot.getRangeAxis(index);
1285: if (result == null) {
1286: result = plot.getRangeAxis();
1287: }
1288: return result;
1289: }
1290:
1291:
1297: public LegendItemCollection getLegendItems() {
1298: if (this.plot == null) {
1299: return new LegendItemCollection();
1300: }
1301: LegendItemCollection result = new LegendItemCollection();
1302: int index = this.plot.getIndexOf(this);
1303: CategoryDataset dataset = this.plot.getDataset(index);
1304: if (dataset != null) {
1305: int seriesCount = dataset.getRowCount();
1306: for (int i = 0; i < seriesCount; i++) {
1307: if (isSeriesVisibleInLegend(i)) {
1308: LegendItem item = getLegendItem(index, i);
1309: if (item != null) {
1310: result.add(item);
1311: }
1312: }
1313: }
1314:
1315: }
1316: return result;
1317: }
1318:
1319:
1324: public CategorySeriesLabelGenerator getLegendItemLabelGenerator() {
1325: return this.legendItemLabelGenerator;
1326: }
1327:
1328:
1333: public void setLegendItemLabelGenerator(
1334: CategorySeriesLabelGenerator generator) {
1335: if (generator == null) {
1336: throw new IllegalArgumentException("Null 'generator' argument.");
1337: }
1338: this.legendItemLabelGenerator = generator;
1339: }
1340:
1341:
1346: public CategorySeriesLabelGenerator getLegendItemToolTipGenerator() {
1347: return this.legendItemToolTipGenerator;
1348: }
1349:
1350:
1355: public void setLegendItemToolTipGenerator(
1356: CategorySeriesLabelGenerator generator) {
1357: this.legendItemToolTipGenerator = generator;
1358: }
1359:
1360:
1365: public CategorySeriesLabelGenerator getLegendItemURLGenerator() {
1366: return this.legendItemURLGenerator;
1367: }
1368:
1369:
1374: public void setLegendItemURLGenerator(
1375: CategorySeriesLabelGenerator generator) {
1376: this.legendItemURLGenerator = generator;
1377: }
1378:
1379:
1389: protected void addItemEntity(EntityCollection entities,
1390: CategoryDataset dataset, int row, int column,
1391: Shape hotspot) {
1392:
1393: String tip = null;
1394: CategoryToolTipGenerator tipster = getToolTipGenerator(row, column);
1395: if (tipster != null) {
1396: tip = tipster.generateToolTip(dataset, row, column);
1397: }
1398: String url = null;
1399: CategoryURLGenerator urlster = getItemURLGenerator(row, column);
1400: if (urlster != null) {
1401: url = urlster.generateURL(dataset, row, column);
1402: }
1403: CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url,
1404: dataset, row, dataset.getColumnKey(column), column);
1405: entities.add(entity);
1406:
1407: }
1408:
1409: }