OLD | NEW |
1 // | 1 // |
2 // Copyright 2014 Google Inc. All rights reserved. | 2 // Copyright 2014 Google Inc. All rights reserved. |
3 // | 3 // |
4 // Use of this source code is governed by a BSD-style | 4 // Use of this source code is governed by a BSD-style |
5 // license that can be found in the LICENSE file or at | 5 // license that can be found in the LICENSE file or at |
6 // https://developers.google.com/open-source/licenses/bsd | 6 // https://developers.google.com/open-source/licenses/bsd |
7 // | 7 // |
8 | 8 |
9 part of charted.charts; | 9 part of charted.charts; |
10 | 10 |
11 /// | 11 /// |
12 /// Model to provide highlight, selection and visibility in a ChartArea. | 12 /// Model to provide highlight, selection and visibility in a ChartArea. |
13 /// Selection and visibility | 13 /// Selection and visibility |
14 /// | 14 /// |
15 abstract class ChartState implements ChangeNotifier { | 15 abstract class ChartState implements ChangeNotifier { |
16 static int COL_SELECTED = 0x001; | 16 static int COL_SELECTED = 0x001; |
17 static int COL_UNSELECTED = 0x002; | 17 static int COL_UNSELECTED = 0x002; |
18 static int COL_PREVIEW = 0x004; | 18 static int COL_PREVIEW = 0x004; |
19 static int COL_HIDDEN = 0x008; | 19 static int COL_HIDDEN = 0x008; |
20 static int COL_HIGHLIGHTED = 0x010; | 20 static int COL_HIGHLIGHTED = 0x010; |
21 static int COL_UNHIGHLIGHTED = 0x020; | 21 static int COL_UNHIGHLIGHTED = 0x020; |
22 static int COL_HOVERED = 0x040; | 22 static int COL_HOVERED = 0x040; |
23 static int VAL_HIGHLIGHTED = 0x080; | 23 static int VAL_HIGHLIGHTED = 0x080; |
24 static int VAL_UNHIGHLIGHTED = 0x100; | 24 static int VAL_UNHIGHLIGHTED = 0x100; |
25 static int VAL_HOVERED = 0x200; | 25 static int VAL_HOVERED = 0x200; |
26 | 26 |
27 static const COL_SELECTED_CLASS = 'col-selected'; | 27 static const COL_SELECTED_CLASS = 'col-selected'; |
28 static const COL_UNSELECTED_CLASS = 'col-unselected'; | 28 static const COL_UNSELECTED_CLASS = 'col-unselected'; |
29 static const COL_PREVIEW_CLASS = 'col-previewed'; | 29 static const COL_PREVIEW_CLASS = 'col-previewed'; |
30 static const COL_HIDDEN_CLASS = 'col-hidden'; | 30 static const COL_HIDDEN_CLASS = 'col-hidden'; |
31 static const COL_HIGHLIGHTED_CLASS = 'col-highlighted'; | 31 static const COL_HIGHLIGHTED_CLASS = 'col-highlighted'; |
32 static const COL_UNHIGHLIGHTED_CLASS = 'col-unhighlighted'; | 32 static const COL_UNHIGHLIGHTED_CLASS = 'col-unhighlighted'; |
33 static const COL_HOVERED_CLASS = 'col-hovered'; | 33 static const COL_HOVERED_CLASS = 'col-hovered'; |
34 static const VAL_HIGHLIGHTED_CLASS = 'row-highlighted'; | 34 static const VAL_HIGHLIGHTED_CLASS = 'row-highlighted'; |
35 static const VAL_UNHIGHLIGHTED_CLASS = 'row-unhighlighted'; | 35 static const VAL_UNHIGHLIGHTED_CLASS = 'row-unhighlighted'; |
36 static const VAL_HOVERED_CLASS = 'row-hovered'; | 36 static const VAL_HOVERED_CLASS = 'row-hovered'; |
37 | 37 |
38 static const COLUMN_CLASS_NAMES = const[ | 38 static const COLUMN_CLASS_NAMES = const [ |
39 COL_SELECTED_CLASS, COL_UNSELECTED_CLASS, COL_PREVIEW_CLASS, | 39 COL_SELECTED_CLASS, |
40 COL_HIGHLIGHTED_CLASS, COL_UNHIGHLIGHTED_CLASS, COL_HIDDEN_CLASS, | 40 COL_UNSELECTED_CLASS, |
41 COL_HOVERED_CLASS]; | 41 COL_PREVIEW_CLASS, |
| 42 COL_HIGHLIGHTED_CLASS, |
| 43 COL_UNHIGHLIGHTED_CLASS, |
| 44 COL_HIDDEN_CLASS, |
| 45 COL_HOVERED_CLASS |
| 46 ]; |
42 | 47 |
43 static const VALUE_CLASS_NAMES = const[ | 48 static const VALUE_CLASS_NAMES = const [ |
44 COL_SELECTED_CLASS, COL_UNSELECTED_CLASS, COL_PREVIEW_CLASS, | 49 COL_SELECTED_CLASS, |
45 COL_HIGHLIGHTED_CLASS, COL_UNHIGHLIGHTED_CLASS, COL_HIDDEN_CLASS, | 50 COL_UNSELECTED_CLASS, |
46 COL_HOVERED_CLASS, VAL_HIGHLIGHTED_CLASS, VAL_UNHIGHLIGHTED_CLASS, | 51 COL_PREVIEW_CLASS, |
47 VAL_HOVERED_CLASS]; | 52 COL_HIGHLIGHTED_CLASS, |
| 53 COL_UNHIGHLIGHTED_CLASS, |
| 54 COL_HIDDEN_CLASS, |
| 55 COL_HOVERED_CLASS, |
| 56 VAL_HIGHLIGHTED_CLASS, |
| 57 VAL_UNHIGHLIGHTED_CLASS, |
| 58 VAL_HOVERED_CLASS |
| 59 ]; |
48 | 60 |
49 /// List of selected items. | 61 /// List of selected items. |
50 /// - Contains a column on CartesianArea if useRowColoring is false. | 62 /// - Contains a column on CartesianArea if useRowColoring is false. |
51 /// - Row index in all other cases. | 63 /// - Row index in all other cases. |
52 Iterable<int> get selection; | 64 Iterable<int> get selection; |
53 | 65 |
54 /// List of visible items. | 66 /// List of visible items. |
55 /// - Contains a column on CartesianArea if useRowColoring is false. | 67 /// - Contains a column on CartesianArea if useRowColoring is false. |
56 /// - Row index in all other cases. | 68 /// - Row index in all other cases. |
57 Iterable<int> get hidden; | 69 Iterable<int> get hidden; |
58 | 70 |
59 /// Currently previewed row or column. Hidden items can be previewed | 71 /// Currently previewed row or column. Hidden items can be previewed |
60 /// by hovering on the corresponding label in Legend | 72 /// by hovering on the corresponding label in Legend |
61 /// - Contains a column on CartesianArea if useRowColoring is false. | 73 /// - Contains a column on CartesianArea if useRowColoring is false. |
62 /// - Row index in all other cases. | 74 /// - Row index in all other cases. |
63 int preview; | 75 int preview; |
64 | 76 |
65 /// Currently highlighted value, if any, represented as column and row. | 77 /// Currently highlighted value, if any, represented as column and row. |
66 /// Highlight is result of a click on certain value. | 78 /// Highlight is result of a click on certain value. |
67 Iterable<Pair<int,int>> highlights; | 79 Iterable<Pair<int, int>> highlights; |
68 | 80 |
69 /// Currently hovered value, if any, represented as column and row. | 81 /// Currently hovered value, if any, represented as column and row. |
70 /// Hover is result of mouse moving over a certian value in chart. | 82 /// Hover is result of mouse moving over a certian value in chart. |
71 Pair<int,int> hovered; | 83 Pair<int, int> hovered; |
72 | 84 |
73 /// Ensure that a row or column is visible. | 85 /// Ensure that a row or column is visible. |
74 bool unhide(int id); | 86 bool unhide(int id); |
75 | 87 |
76 /// Ensure that a row or column is invisible. | 88 /// Ensure that a row or column is invisible. |
77 bool hide(int id); | 89 bool hide(int id); |
78 | 90 |
79 /// Returns current visibility of a row or column. | 91 /// Returns current visibility of a row or column. |
80 bool isVisible(int id); | 92 bool isVisible(int id); |
81 | 93 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 final int unhide; | 131 final int unhide; |
120 final int hide; | 132 final int hide; |
121 const ChartVisibilityChangeRecord({this.unhide, this.hide}); | 133 const ChartVisibilityChangeRecord({this.unhide, this.hide}); |
122 } | 134 } |
123 | 135 |
124 /// | 136 /// |
125 /// Implementation of [ChangeRecord], that is used to notify changes to | 137 /// Implementation of [ChangeRecord], that is used to notify changes to |
126 /// values in [ChartData]. | 138 /// values in [ChartData]. |
127 /// | 139 /// |
128 class ChartHighlightChangeRecord implements ChangeRecord { | 140 class ChartHighlightChangeRecord implements ChangeRecord { |
129 final Pair<int,int> remove; | 141 final Pair<int, int> remove; |
130 final Pair<int,int> add; | 142 final Pair<int, int> add; |
131 const ChartHighlightChangeRecord({this.add, this.remove}); | 143 const ChartHighlightChangeRecord({this.add, this.remove}); |
132 } | 144 } |
133 | 145 |
134 /// | 146 /// |
135 /// Implementation of [ChangeRecord], that is used to notify changes to | 147 /// Implementation of [ChangeRecord], that is used to notify changes to |
136 /// values in [ChartData]. | 148 /// values in [ChartData]. |
137 /// | 149 /// |
138 class ChartHoverChangeRecord implements ChangeRecord { | 150 class ChartHoverChangeRecord implements ChangeRecord { |
139 final Pair<int,int> hovered; | 151 final Pair<int, int> hovered; |
140 const ChartHoverChangeRecord(this.hovered); | 152 const ChartHoverChangeRecord(this.hovered); |
141 } | 153 } |
142 | 154 |
143 /// | 155 /// |
144 /// Implementation of [ChangeRecord], that is used to notify changes to | 156 /// Implementation of [ChangeRecord], that is used to notify changes to |
145 /// values in [ChartData]. | 157 /// values in [ChartData]. |
146 /// | 158 /// |
147 class ChartPreviewChangeRecord implements ChangeRecord { | 159 class ChartPreviewChangeRecord implements ChangeRecord { |
148 final int previewed; | 160 final int previewed; |
149 const ChartPreviewChangeRecord(this.previewed); | 161 const ChartPreviewChangeRecord(this.previewed); |
150 } | 162 } |
OLD | NEW |