List of usage examples for org.joda.time LocalDateTime withField
public LocalDateTime withField(DateTimeFieldType fieldType, int value)
From source file:view.schema.AssignedAllRoomsRow.java
public AssignedAllRoomsRow(String shiftName, LocalDateTime startTime, ArrayList<TimeInvestment> shifts, int startHour, int startMinute, int periodLengthHour, int periodLengthMinute) { this.shifts = shifts; this.startTime = startTime; shiftTypeLabel = new RoomTile(shiftName); this.setOrientation(Orientation.HORIZONTAL); this.getChildren().add(shiftTypeLabel); //Tilfj vagter til dagene p ugen. i0 = mandag, i4 = fredag. for (int i = 0; i < 5; i++) { LocalDateTime date = startTime.plusDays(i); date = date.withField(DateTimeFieldType.hourOfDay(), startHour); date = date.withField(DateTimeFieldType.minuteOfHour(), startMinute); //Nulstil sekunder og millisekunder (vigtigt). date = date.withSecondOfMinute(0); date = date.withMillisOfSecond(0); LocalDateTime endDate = new LocalDateTime(date); endDate = endDate.plusHours(periodLengthHour).plusMinutes(periodLengthMinute); ShiftTile shiftTile = new ShiftTile( Xray.getInstance().getTimeInvestmentControl().getShiftsInPeriod(shifts, date, endDate)); this.getChildren().add(shiftTile); }/*from ww w .j a v a2s . com*/ }
From source file:view.schema.AssignedRoomRow.java
public AssignedRoomRow(Room room, ArrayList<TimeInvestment> shifts, LocalDateTime startTime, int startHour, int startMinute, int periodLengthHour, int periodLengthMinute) { this.startTime = startTime; this.room = room; this.shifts = shifts; roomLabel = new RoomTile(room.getRoomName()); //Tilfj rumnavn til venstre. this.getChildren().add(roomLabel); //Tilfj vagter til dagene p ugen. i0 = mandag, i4 = fredag. for (int i = 0; i < 5; i++) { LocalDateTime date = startTime.plusDays(i); date = date.withField(DateTimeFieldType.hourOfDay(), startHour); date = date.withField(DateTimeFieldType.minuteOfHour(), startMinute); //Nulstil sekunder og millisekunder (vigtigt). date = date.withSecondOfMinute(0); date = date.withMillisOfSecond(0); LocalDateTime endDate = new LocalDateTime(date); endDate = endDate.plusHours(periodLengthHour).plusMinutes(periodLengthMinute); ShiftTile shiftTile = new ShiftTile( Xray.getInstance().getTimeInvestmentControl().getShiftsInPeriod(shifts, date, endDate)); this.getChildren().add(shiftTile); }/*from w ww.j a v a 2 s .c om*/ }
From source file:view.schema.ShiftTile.java
private Paint getColorOnShiftStart(LocalDateTime shiftTime) { //hours//ww w . ja v a2s .co m LocalDateTime tempShiftEveningStart = shiftTime.withField(DateTimeFieldType.hourOfDay(), ShiftPeriodConstants.EVENING_SHIFT_HOURS_START.getHours()); LocalDateTime tempShiftNightStart = shiftTime.withField(DateTimeFieldType.hourOfDay(), ShiftPeriodConstants.NIGHT_SHIFT_HOURS_START.getHours()); LocalDateTime tempShiftDayStart = shiftTime.withField(DateTimeFieldType.hourOfDay(), ShiftPeriodConstants.DAY_SHIFT_HOURS_START.getHours()); //Minutes. tempShiftEveningStart = tempShiftEveningStart.withField(DateTimeFieldType.minuteOfHour(), ShiftPeriodConstants.EVENING_SHIFT_MINUTES_START.getMinutes()); tempShiftNightStart = tempShiftNightStart.withField(DateTimeFieldType.minuteOfHour(), ShiftPeriodConstants.NIGHT_SHIFT_MINUTES_START.getMinutes()); tempShiftDayStart = tempShiftDayStart.withField(DateTimeFieldType.minuteOfHour(), ShiftPeriodConstants.DAY_SHIFT_MINUTES_START.getMinutes()); if (shiftTime.isEqual(tempShiftDayStart) || (shiftTime.isBefore(tempShiftEveningStart) && shiftTime.isAfter(tempShiftDayStart))) { return BLUE; } else if (shiftTime.isEqual(tempShiftEveningStart) || (shiftTime.isBefore(tempShiftNightStart) && shiftTime.isAfter(tempShiftEveningStart))) { return GREEN; } else { return RED; } }