1 | public class IntervalCategoryItemLabelGenerator ↵ | | 1 | public class IntervalCategoryToolTipGenerator ↵
|
2 | extends StandardCategoryItemLabelGenerator↵ | | 2 | extends StandardCategoryToolTipGenerator↵
|
3 | implements CategoryItemLabelGenerator, PublicCloneable, Cloneable,↵ | | 3 | implements CategoryToolTipGenerator, PublicCloneable, Cloneable,↵
|
4 | Serializable {↵ | | 4 | Serializable {↵
|
|
5 | /** For serialization. */↵ | | 5 | /** For serialization. */↵
|
6 | private static final long serialVersionUID = 5056909225610630529L;↵ | | 6 | private static final long serialVersionUID = -3853824986520333437L;↵
|
7 | ↵ | | 7 | ↵
|
8 | /** The default format string. */↵ | | 8 | /** The default format string. */↵
|
9 | public static final String DEFAULT_LABEL_FORMAT_STRING ↵ | | 9 | public static final String DEFAULT_TOOL_TIP_FORMAT_STRING ↵
|
10 | = "({0}, {1}) = {3} - {4}";↵ | | 10 | = "({0}, {1}) = {3} - {4}";↵
|
11 | ↵ | | 11 | ↵
|
12 | /**↵ | | 12 | /**↵
|
13 | * Creates a new generator with a default number formatter.↵ | | 13 | * Creates a new generator with a default number formatter.↵
|
14 | */↵ | | 14 | */↵
|
15 | public IntervalCategoryItemLabelGenerator() {↵ | | 15 | public IntervalCategoryToolTipGenerator() {↵
|
16 | super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance());↵ | | 16 | super(DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance());↵
|
17 | }↵ | | 17 | }↵
|
|
18 | /**↵ | | 18 | /**↵
|
19 | * Creates a new generator with the specified number formatter.↵ | | 19 | * Creates a new generator with the specified number formatter.↵
|
20 | *↵ | | 20 | *↵
|
21 | * @param labelFormat the label format string (<code>null</code> not ↵ | | 21 | * @param labelFormat the label format string (<code>null</code> not ↵
|
22 | * permitted).↵ | | 22 | * permitted).↵
|
23 | * @param formatter the number formatter (<code>null</code> not permitted).↵ | | 23 | * @param formatter the number formatter (<code>null</code> not permitted).↵
|
24 | */↵ | | 24 | */↵
|
25 | public IntervalCategoryItemLabelGenerator(String labelFormat, ↵ | | 25 | public IntervalCategoryToolTipGenerator(String labelFormat, ↵
|
26 | NumberFormat formatter) {↵ | | 26 | NumberFormat formatter) {↵
|
27 | super(labelFormat, formatter);↵ | | 27 | super(labelFormat, formatter);↵
|
28 | }↵ | | 28 | }↵
|
29 | ↵ | | 29 | ↵
|
30 | /**↵ | | 30 | /**↵
|
31 | * Creates a new generator with the specified date formatter.↵ | | 31 | * Creates a new generator with the specified date formatter.↵
|
32 | *↵ | | 32 | *↵
|
33 | * @param labelFormat the label format string (<code>null</code> not ↵ | | 33 | * @param labelFormat the label format string (<code>null</code> not ↵
|
34 | * permitted).↵ | | 34 | * permitted).↵
|
35 | * @param formatter the date formatter (<code>null</code> not permitted).↵ | | 35 | * @param formatter the date formatter (<code>null</code> not permitted).↵
|
36 | */↵ | | 36 | */↵
|
37 | public IntervalCategoryItemLabelGenerator(String labelFormat, ↵ | | 37 | public IntervalCategoryToolTipGenerator(String labelFormat, ↵
|
38 | DateFormat formatter) {↵ | | 38 | DateFormat formatter) {↵
|
39 | super(labelFormat, formatter);↵ | | 39 | super(labelFormat, formatter);↵
|
40 | }↵ | | 40 | }↵
|
41 | ↵ | | 41 | ↵
|
42 | /**↵ | | 42 | /**↵
|
43 | * Creates the array of items that can be passed to the ↵ | | 43 | * Creates the array of items that can be passed to the ↵
|
44 | * <code>MessageFormat</code> class for creating labels.↵ | | 44 | * <code>MessageFormat</code> class for creating labels.↵
|
45 | *↵ | | 45 | *↵
|
46 | * @param dataset the dataset (<code>null</code> not permitted).↵ | | 46 | * @param dataset the dataset (<code>null</code> not permitted).↵
|
47 | * @param row the row index (zero-based).↵ | | 47 | * @param row the row index (zero-based).↵
|
48 | * @param column the column index (zero-based).↵ | | 48 | * @param column the column index (zero-based).↵
|
49 | *↵ | | 49 | *↵
|
50 | * @return The items (never <code>null</code>).↵ | | 50 | * @return The items (never <code>null</code>).↵
|
51 | */↵ | | 51 | */↵
|
52 | protected Object[] createItemArray(CategoryDataset dataset, ↵ | | 52 | protected Object[] createItemArray(CategoryDataset dataset, ↵
|
53 | int row, int column) {↵ | | 53 | int row, int column) {↵
|
54 | Object[] result = new Object[5];↵ | | 54 | Object[] result = new Object[5];↵
|
55 | result[0] = dataset.getRowKey(row).toString();↵ | | 55 | result[0] = dataset.getRowKey(row).toString();↵
|
56 | result[1] = dataset.getColumnKey(column).toString();↵ | | 56 | result[1] = dataset.getColumnKey(column).toString();↵
|
57 | Number value = dataset.getValue(row, column);↵ | | 57 | Number value = dataset.getValue(row, column);↵
|
58 | if (getNumberFormat() != null) {↵ | | 58 | if (getNumberFormat() != null) {↵
|
59 | result[2] = getNumberFormat().format(value); ↵ | | 59 | result[2] = getNumberFormat().format(value); ↵
|
60 | }↵ | | 60 | }↵
|
61 | else if (getDateFormat() != null) {↵ | | 61 | else if (getDateFormat() != null) {↵
|
62 | result[2] = getDateFormat().format(value);↵ | | 62 | result[2] = getDateFormat().format(value);↵
|
63 | }↵ | | 63 | }↵
|
64 | ↵ | | 64 | ↵
|
65 | if (dataset instanceof IntervalCategoryDataset) {↵ | | 65 | if (dataset instanceof IntervalCategoryDataset) {↵
|
66 | IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;↵ | | 66 | IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;↵
|
67 | Number start = icd.getStartValue(row, column);↵ | | 67 | Number start = icd.getStartValue(row, column);↵
|
68 | Number end = icd.getEndValue(row, column);↵ | | 68 | Number end = icd.getEndValue(row, column);↵
|
69 | if (getNumberFormat() != null) {↵ | | 69 | if (getNumberFormat() != null) {↵
|
70 | result[3] = getNumberFormat().format(start); ↵ | | 70 | result[3] = getNumberFormat().format(start); ↵
|
71 | result[4] = getNumberFormat().format(end); ↵ | | 71 | result[4] = getNumberFormat().format(end); ↵
|
72 | }↵ | | 72 | }↵
|
73 | else if (getDateFormat() != null) {↵ | | 73 | else if (getDateFormat() != null) {↵
|
74 | result[3] = getDateFormat().format(start);↵ | | 74 | result[3] = getDateFormat().format(start);↵
|
75 | result[4] = getDateFormat().format(end);↵ | | 75 | result[4] = getDateFormat().format(end);↵
|
76 | }↵ | | 76 | }↵
|
77 | }↵ | | 77 | }↵
|
78 | return result | | 78 | return result
|