8
8
import comp110 .Employee ;
9
9
import comp110 .Schedule ;
10
10
import comp110 .Week ;
11
+ import javafx .collections .ObservableList ;
11
12
import javafx .geometry .Pos ;
13
+ import javafx .scene .Node ;
12
14
import javafx .scene .Scene ;
13
15
import javafx .scene .control .Label ;
14
16
import javafx .scene .control .ScrollPane ;
18
20
import javafx .scene .layout .GridPane ;
19
21
import javafx .scene .paint .Color ;
20
22
import javafx .scene .text .Font ;
21
- import javafx .scene .text .FontPosture ;
22
- import javafx .scene .text .FontWeight ;
23
23
import javafx .scene .text .Text ;
24
24
import javafx .scene .text .TextFlow ;
25
25
@@ -96,37 +96,58 @@ private void renderScheduleStage(List<Schedule> schedules) {
96
96
}
97
97
98
98
Scene scene = new Scene (tabs );
99
+ scene .getStylesheets ().add ("Borders.css" );
99
100
this .setScene (scene );
100
101
this .sizeToScene ();
101
102
}
102
103
103
104
public GridPane writeSchedule (Schedule schedule ) {
104
105
GridPane schedulePane = new GridPane ();
105
- schedulePane .setAlignment (Pos .CENTER );
106
- schedulePane .setGridLinesVisible (true );
107
- ArrayList <ArrayList <ArrayList <Employee >>> shifts = shiftsAsArray (schedule .getWeek ());
108
-
109
- for (int day = 0 ; day < 7 ; day ++) {
110
- // +1 for hour column
111
- schedulePane .add (new Label (Week .dayString (day )), day + 1 , 0 );
112
- }
113
-
106
+
114
107
//Load the fonts
115
108
InputStream is = getClass ().getResourceAsStream ("segoeui.ttf" );
116
109
Font font = Font .loadFont (is , 12.0 );
117
110
InputStream is2 = getClass ().getResourceAsStream ("segoeuibold.ttf" );
118
111
Font boldFont = Font .loadFont (is2 , 12.0 );
119
112
113
+ schedulePane .setAlignment (Pos .CENTER );
114
+ //schedulePane.setGridLinesVisible(true);
115
+ ArrayList <ArrayList <ArrayList <Employee >>> shifts = shiftsAsArray (schedule .getWeek ());
116
+ TextFlow firstBlock = new TextFlow (new Text ());
117
+ firstBlock .getStyleClass ().add ("newHour" );
118
+ schedulePane .add (firstBlock , 0 , 0 );
119
+ for (int day = 0 ; day < 7 ; day ++) {
120
+ // +1 for hour column
121
+ Text test = new Text (Week .dayString (day ));
122
+ test .setFont (font );
123
+ TextFlow h = new TextFlow (test );
124
+ String style = "newHour" ;
125
+ h .getStyleClass ().add (style );
126
+ schedulePane .add (h , day + 1 , 0 );
127
+ }
120
128
121
129
int hourRow = 0 ;
130
+ int prevHourRow = hourRow ;
122
131
for (int hour = getEarliestHour (schedule .getWeek ()); hour < getLatestHour (schedule .getWeek ()); hour ++) {
123
- Label dayLabel = new Label (
132
+
133
+ Text dayLabel = new Text (
124
134
(hour % 12 == 0 ? 12 : hour % 12 ) + " -- " + ((hour + 1 ) % 12 == 0 ? 12 : (hour + 1 ) % 12 ));
125
- dayLabel .setMaxWidth (Double .MAX_VALUE );
126
- dayLabel .setAlignment (Pos .CENTER );
135
+ //dayLabel.setMaxWidth(Double.MAX_VALUE);
136
+ //dayLabel.setAlignment(Pos.CENTER);
137
+ dayLabel .setFont (font );
127
138
// +1 to account for day row
128
- schedulePane .add (dayLabel , 0 , hourRow + 1 );
129
-
139
+ TextFlow dayLabelWrapper = new TextFlow (dayLabel );
140
+ dayLabelWrapper .getStyleClass ().add ("newHour" );
141
+ schedulePane .add (dayLabelWrapper , 0 , hourRow + 1 );
142
+
143
+ for (int i = prevHourRow + 2 ; i < hourRow + 1 ; i ++){
144
+ Text test = new Text ();
145
+ TextFlow h = new TextFlow (test );
146
+ h .getStyleClass ().add ("notNewHour" );
147
+ schedulePane .add (h , 0 , i );
148
+ }
149
+ prevHourRow = hourRow ;
150
+
130
151
int max = getMaxSize (hour , schedule .getWeek ());
131
152
132
153
for (int i = 0 ; i < max ; i ++) {
@@ -146,12 +167,24 @@ public GridPane writeSchedule(Schedule schedule) {
146
167
scheduledEmployee .setFill (Color .RED );
147
168
}
148
169
// +1 to account for day row
149
- schedulePane .add (new TextFlow (scheduledEmployee ), day + 1 , hourRow + i + 1 );
170
+ TextFlow x = new TextFlow (scheduledEmployee );
171
+ if (i == 0 ) x .getStyleClass ().add ("newHour" );
172
+
173
+ else x .getStyleClass ().add ("notNewHour" );
174
+ schedulePane .add (x , day + 1 , hourRow + i + 1 );
175
+ }
176
+ else {
177
+ Text y = new Text ();
178
+ TextFlow x = new TextFlow (y );
179
+ String style = i == 0 ? "newHour" : "notNewHour" ;
180
+ x .getStyleClass ().add (style );
181
+ schedulePane .add (x , day + 1 , hourRow + i + 1 );
150
182
}
151
183
}
152
184
}
153
185
hourRow += max ;
154
186
}
187
+
155
188
return schedulePane ;
156
189
}
157
190
0 commit comments