diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java index 72c281a..932520e 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java @@ -1,14 +1,12 @@ package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; import java.io.InputStream; -import java.util.Collection; import java.util.Map; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.calendar.Year; import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; -import net.sf.jasperreports.engine.JasperPrint; public class YearlyCalendarCreator extends CalendarCreator { @@ -33,7 +31,7 @@ public class YearlyCalendarCreator extends CalendarCreator { return CalendarCreator.class.getResourceAsStream("/jasper/calendar_year.jrxml"); } - private static class EmptySource implements JRDataSource { + public static class EmptySource implements JRDataSource { @Override public boolean next() throws JRException { @@ -44,6 +42,6 @@ public class YearlyCalendarCreator extends CalendarCreator { public Object getFieldValue(JRField jrField) throws JRException { return null; } - + } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java index 2b123cd..46ea449 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java @@ -17,44 +17,44 @@ public class Year { public Year(int year) { this(year, Locale.getDefault()); } - + public Year(int year, Locale locale) { - if (year < 1900 || year >2100) { + if (year < 1900 || year > 2100) { throw new IllegalArgumentException("Year value must be between 1900 and 2100"); } this.date = LocalDate.of(year, 1, 1); this.locale = locale; this.monthWeeks = new HashMap<>(); - for (Month m: Month.values()) { + for (Month m : Month.values()) { monthWeeks.put(m, new WeeksOfMonth(m, year)); } } - + public int getYear() { return date.getYear(); } - + public CharSequence getMonth(Month month) { return month.getDisplayName(TextStyle.FULL_STANDALONE, locale); } - + /** * Day of month, numeric for the specified by parameters. - * @param month month of the day - * @param week 1-6th week of the month - * @param dayOfWeek weekday of the week in the month. - * @return numeric value of the day of the month. + * + * @param month month of the day + * @param week 1-6th week of the month + * @param dayOfWeek weekday of the week in the month. + * @return numeric value of the day of the month. */ public String getDay(Month month, short week, DayOfWeek dayOfWeek) { - WeeksOfMonth weeksOfMonth = monthWeeks.get(month); - if (week >= weeksOfMonth.weekCount()) { + if (week > weeksOfMonth.weekCount()) { return ""; } Integer res = weeksOfMonth.getWeek(week - 1).get(dayOfWeek); - - return res == null ? "" : res.toString(); - + + return res == null ? "" : res.toString(); + } - + } diff --git a/src/main/resources/jasper/calendar_year.jrxml b/src/main/resources/jasper/calendar_year.jrxml index 80be2b7..a71fdbf 100644 --- a/src/main/resources/jasper/calendar_year.jrxml +++ b/src/main/resources/jasper/calendar_year.jrxml @@ -2,7 +2,6 @@ - @@ -11,11 +10,8 @@ +