/
Section.java
219 lines (174 loc) · 7.09 KB
/
Section.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Arc;
import javafx.scene.shape.Shape;
import jfxtras.labs.util.Util;
/**
*
* @author hansolo
*/
public class Section {
private DoubleProperty start;
private DoubleProperty stop;
private ObjectProperty<Color> color;
private StringProperty cssColor;
private ObjectProperty<Color> transparentColor;
private ObjectProperty<Color> highlightColor;
private ObjectProperty<Color> transparentHighlightColor;
private ObjectProperty<Paint> paint;
private ObjectProperty<Shape> sectionArea;
private ObjectProperty<Shape> filledArea;
private StringProperty text;
// ******************** Constructors **************************************
public Section() {
this(-1, -1, Color.RED, "");
}
public Section(final double START, final double STOP, final Color COLOR) {
this(START, STOP, COLOR, "");
}
public Section(final double START, final double STOP, final Color COLOR, final String TEXT) {
this(START, STOP, COLOR, COLOR.brighter().brighter(), null, null, TEXT);
}
public Section(final double START, final double STOP, final Color COLOR, final Color HIGHLIGHT_COLOR) {
this(START, STOP, COLOR, HIGHLIGHT_COLOR, null, null, "");
}
public Section(final double START, final double STOP, final Color COLOR, final Color HIGHLIGHT_COLOR, final String TEXT) {
this(START, STOP, COLOR, HIGHLIGHT_COLOR, null, null, TEXT);
}
public Section(final double START, final double STOP, final Color COLOR, final Arc FILLED_AREA) {
this(START, STOP, COLOR, null, FILLED_AREA);
}
public Section(final double START, final double STOP, final Color COLOR, final Shape SECTION_AREA, final Arc FILLED_AREA) {
this(START, STOP, COLOR, COLOR.brighter().brighter(), SECTION_AREA, FILLED_AREA, "");
}
public Section(final double START, final double STOP, final Color COLOR, final Color HIGHLIGHT_COLOR, final Shape SECTION_AREA, final Shape FILLED_AREA, final String TEXT) {
start = new SimpleDoubleProperty(START);
stop = new SimpleDoubleProperty(STOP);
color = new SimpleObjectProperty<Color>(COLOR);
transparentColor = new SimpleObjectProperty<Color>(Color.color(COLOR.getRed(), COLOR.getGreen(), COLOR.getBlue(), 0.3));
highlightColor = new SimpleObjectProperty<Color>(HIGHLIGHT_COLOR);
transparentHighlightColor = new SimpleObjectProperty<Color>(Color.color(COLOR.getRed(), COLOR.getGreen(), COLOR.getBlue(), 0.5));
sectionArea = new SimpleObjectProperty<Shape>(SECTION_AREA);
filledArea = new SimpleObjectProperty<Shape>(FILLED_AREA);
paint = new SimpleObjectProperty<Paint>(COLOR);
text = new SimpleStringProperty(TEXT);
cssColor = new SimpleStringProperty(Util.createCssColor(COLOR));
}
// ******************** Methods *******************************************
public final double getStart() {
return start.get();
}
public final void setStart(final double START) {
start.set(START);
}
public final DoubleProperty startProperty() {
return start;
}
public final double getStop() {
return stop.get();
}
public final void setStop(final double STOP) {
stop.set(STOP);
}
public final DoubleProperty stopProperty() {
return stop;
}
public final Color getColor() {
return color.get();
}
public final void setColor(final Color COLOR) {
color.set(COLOR);
transparentColor.set(Color.color(COLOR.getRed(), COLOR.getGreen(), COLOR.getBlue(), 0.25));
cssColor.set(Util.createCssColor(COLOR));
}
public final ObjectProperty<Color> colorProperty() {
return color;
}
public final Color getTransparentColor() {
return transparentColor.get();
}
public final ObjectProperty<Color> transparentColorProperty() {
return transparentColor;
}
public final Color getHighlightColor() {
return highlightColor.get();
}
public final void setHighlightColor(final Color COLOR) {
highlightColor.set(COLOR);
transparentHighlightColor.set(Color.color(COLOR.getRed(), COLOR.getGreen(), COLOR.getBlue(), 0.5));
}
public final ObjectProperty<Color> highlightColorProperty() {
return highlightColor;
}
public final Color getTransparentHighlightColor() {
return transparentHighlightColor.get();
}
public final ObjectProperty<Color> transparentHighlightColorProperty() {
return transparentHighlightColor;
}
public final String getCssColor() {
return cssColor.get();
}
public final StringProperty cssColorProperty() {
return cssColor;
}
public final Shape getSectionArea() {
return sectionArea.get();
}
public final void setSectionArea(final Shape SECTION_AREA) {
sectionArea.set(SECTION_AREA);
}
public final ObjectProperty<Shape> sectionAreaProperty() {
return sectionArea;
}
public final Shape getFilledArea() {
return filledArea.get();
}
public final void setFilledArea(final Shape FILLED_AREA) {
filledArea.set(FILLED_AREA);
}
public final ObjectProperty<Shape> filledAreaProperty() {
return filledArea;
}
public final String getText() {
return text.get();
}
public final void setText(final String TEXT) {
text.set(TEXT);
}
public final StringProperty textProperty() {
return text;
}
public final Paint getPaint() {
return paint.get();
}
public final void setPaint(final Paint PAINT) {
paint.set(PAINT);
}
public final ObjectProperty<Paint> paintProperty() {
return paint;
}
public boolean contains(final double VALUE) {
return ((Double.compare(VALUE, start.get()) >= 0 && Double.compare(VALUE, stop.get()) <= 0));
}
public boolean equals(final Section SECTION) {
return (Double.compare(SECTION.getStart(), getStart()) == 0 &&
Double.compare(SECTION.getStop(), getStop()) == 0 &&
SECTION.getColor().equals(getColor()) &&
SECTION.getText().equals(getText()));
}
@Override public String toString() {
final StringBuilder NAME = new StringBuilder();
NAME.append("Section: ").append("\n");
NAME.append("startValue: ").append(start.get()).append("\n");
NAME.append("stopValue : ").append(stop.get()).append("\n");
NAME.append("color : ").append(color.toString());
return NAME.toString();
}
}