88import comp110 .Employee ;
99import comp110 .Schedule ;
1010import comp110 .Week ;
11+ import javafx .collections .ObservableList ;
1112import javafx .geometry .Pos ;
13+ import javafx .scene .Node ;
1214import javafx .scene .Scene ;
1315import javafx .scene .control .Label ;
1416import javafx .scene .control .ScrollPane ;
1820import javafx .scene .layout .GridPane ;
1921import javafx .scene .paint .Color ;
2022import javafx .scene .text .Font ;
21- import javafx .scene .text .FontPosture ;
22- import javafx .scene .text .FontWeight ;
2323import javafx .scene .text .Text ;
2424import javafx .scene .text .TextFlow ;
2525
@@ -96,37 +96,58 @@ private void renderScheduleStage(List<Schedule> schedules) {
9696 }
9797
9898 Scene scene = new Scene (tabs );
99+ scene .getStylesheets ().add ("Borders.css" );
99100 this .setScene (scene );
100101 this .sizeToScene ();
101102 }
102103
103104 public GridPane writeSchedule (Schedule schedule ) {
104105 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+
114107 //Load the fonts
115108 InputStream is = getClass ().getResourceAsStream ("segoeui.ttf" );
116109 Font font = Font .loadFont (is , 12.0 );
117110 InputStream is2 = getClass ().getResourceAsStream ("segoeuibold.ttf" );
118111 Font boldFont = Font .loadFont (is2 , 12.0 );
119112
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+ }
120128
121129 int hourRow = 0 ;
130+ int prevHourRow = hourRow ;
122131 for (int hour = getEarliestHour (schedule .getWeek ()); hour < getLatestHour (schedule .getWeek ()); hour ++) {
123- Label dayLabel = new Label (
132+
133+ Text dayLabel = new Text (
124134 (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 );
127138 // +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+
130151 int max = getMaxSize (hour , schedule .getWeek ());
131152
132153 for (int i = 0 ; i < max ; i ++) {
@@ -146,12 +167,24 @@ public GridPane writeSchedule(Schedule schedule) {
146167 scheduledEmployee .setFill (Color .RED );
147168 }
148169 // +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 );
150182 }
151183 }
152184 }
153185 hourRow += max ;
154186 }
187+
155188 return schedulePane ;
156189 }
157190
0 commit comments