use of java.time.YearMonth in project JFoenix by jfoenixadmin.
the class JFXDatePickerContent method forward.
protected void forward(int offset, ChronoUnit unit, boolean focusDayCell, boolean withAnimation) {
if (withAnimation) {
if (tempImageTransition == null || tempImageTransition.getStatus().equals(Status.STOPPED)) {
Pane monthContent = (Pane) calendarPlaceHolder.getChildren().get(0);
this.getParent().setManaged(false);
SnapshotParameters snapShotparams = new SnapshotParameters();
snapShotparams.setFill(Color.TRANSPARENT);
WritableImage temp = monthContent.snapshot(snapShotparams, new WritableImage((int) monthContent.getWidth(), (int) monthContent.getHeight()));
ImageView tempImage = new ImageView(temp);
calendarPlaceHolder.getChildren().add(calendarPlaceHolder.getChildren().size() - 2, tempImage);
TranslateTransition imageTransition = new TranslateTransition(Duration.millis(160), tempImage);
imageTransition.setToX(-offset * calendarPlaceHolder.getWidth());
imageTransition.setOnFinished((finish) -> calendarPlaceHolder.getChildren().remove(tempImage));
monthContent.setTranslateX(offset * calendarPlaceHolder.getWidth());
TranslateTransition contentTransition = new TranslateTransition(Duration.millis(160), monthContent);
contentTransition.setToX(0);
tempImageTransition = new ParallelTransition(imageTransition, contentTransition);
tempImageTransition.setOnFinished((finish) -> {
calendarPlaceHolder.getChildren().remove(tempImage);
this.getParent().setManaged(true);
});
tempImageTransition.play();
}
}
YearMonth yearMonth = selectedYearMonth.get();
DateCell dateCell = currentFocusedDayCell;
if (dateCell == null || !dayCellDate(dateCell).getMonth().equals(yearMonth.getMonth()))
dateCell = findDayCellOfDate(yearMonth.atDay(1));
goToDayCell(dateCell, offset, unit, focusDayCell);
}
use of java.time.YearMonth in project JFoenix by jfoenixadmin.
the class JFXDatePickerContent method updateDayCells.
void updateDayCells() {
Locale locale = getLocale();
Chronology chrono = getPrimaryChronology();
// get the index of the first day of the month
int firstDayOfWeek = WeekFields.of(getLocale()).getFirstDayOfWeek().getValue();
int firstOfMonthIndex = selectedYearMonth.get().atDay(1).getDayOfWeek().getValue() - firstDayOfWeek;
firstOfMonthIndex += firstOfMonthIndex < 0 ? daysPerWeek : 0;
YearMonth currentYearMonth = selectedYearMonth.get();
int daysInCurMonth = -1;
for (int i = 0; i < 6 * daysPerWeek; i++) {
DateCell dayCell = dayCells.get(i);
dayCell.getStyleClass().setAll("cell", "date-cell", "day-cell");
dayCell.setPrefSize(40, 42);
dayCell.setDisable(false);
dayCell.setStyle(null);
dayCell.setGraphic(null);
dayCell.setTooltip(null);
dayCell.setTextFill(Color.valueOf("#313131"));
dayCell.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
try {
if (daysInCurMonth == -1)
daysInCurMonth = currentYearMonth.lengthOfMonth();
YearMonth month = currentYearMonth;
int dayIndex = i - firstOfMonthIndex + 1;
LocalDate date = month.atDay(dayIndex);
dayCellDates[i] = date;
// if it's today
if (date.equals(LocalDate.now())) {
dayCell.setTextFill(this.datePicker.getDefaultColor());
dayCell.getStyleClass().add("today");
}
// if it's the current selected value
if (date.equals(datePicker.getValue())) {
dayCell.getStyleClass().add("selected");
dayCell.setTextFill(Color.WHITE);
dayCell.setBackground(new Background(new BackgroundFill(this.datePicker.getDefaultColor(), new CornerRadii(40), Insets.EMPTY)));
}
ChronoLocalDate cDate = chrono.date(date);
String cellText = dayCellFormatter.withLocale(locale).withChronology(chrono).withDecimalStyle(DecimalStyle.of(locale)).format(cDate);
dayCell.setText(cellText);
if (i < firstOfMonthIndex) {
dayCell.getStyleClass().add("previous-month");
dayCell.setText("");
} else if (i >= firstOfMonthIndex + daysInCurMonth) {
dayCell.getStyleClass().add("next-month");
dayCell.setText("");
}
// update cell item
dayCell.updateItem(date, false);
} catch (DateTimeException ex) {
// Disable day cell if its date is out of range
dayCell.setText("");
dayCell.setDisable(true);
}
}
}
use of java.time.YearMonth in project jdk8u_jdk by JetBrains.
the class TCKYearMonth method factory_ints.
//-----------------------------------------------------------------------
@Test
public void factory_ints() {
YearMonth test = YearMonth.of(2008, 2);
check(test, 2008, 2);
}
use of java.time.YearMonth in project jdk8u_jdk by JetBrains.
the class TCKYearMonth method test_minusMonths_long_invalidTooLargeMaxSubtractMax.
@Test(expectedExceptions = DateTimeException.class)
public void test_minusMonths_long_invalidTooLargeMaxSubtractMax() {
YearMonth test = YearMonth.of(Year.MAX_VALUE, 12);
test.minusMonths(Long.MAX_VALUE);
}
use of java.time.YearMonth in project jdk8u_jdk by JetBrains.
the class TCKYearMonth method test_plus_TemporalAmount.
@Test(dataProvider = "plus_TemporalAmount")
public void test_plus_TemporalAmount(YearMonth base, TemporalAmount temporalAmount, YearMonth expectedYearMonth, Class<?> expectedEx) {
if (expectedEx == null) {
assertEquals(base.plus(temporalAmount), expectedYearMonth);
} else {
try {
YearMonth result = base.plus(temporalAmount);
fail();
} catch (Exception ex) {
assertTrue(expectedEx.isInstance(ex));
}
}
}
Aggregations