/** * A method to update the current month. Sets the variable that controls the month and updates the * text. * * @param newMonth an integer value between 0 and 11. */ public void updateMonth(int newMonth) { pastMonthOffset = currentMonthOffset; currentMonthOffset = CakeCal.getDayOfWeek(new SimpleDate((newMonth), 1, currentYear)); miniDays[(currentDay - 1) + pastMonthOffset].setForeground(Color.black); currentMonth = newMonth; miniCalTitle.setText(curMonths[currentMonth - 1] + ", " + currentYear); events = calendar.getEvents( Period.parse( currentYear + "." + currentMonth + ".1:00.00-" + currentYear + "." + currentMonth + "." + curMonths[currentMonth - 1] + ":24.00")); panelEvent.update(); if (currentDay > (CakeCal.getMonths(currentYear))[currentMonth - 1]) { currentDay = (CakeCal.getMonths(currentYear))[currentMonth - 1]; } updateDays(); mview.updateMonth(); dayView.updateDay(); weekView.updateWeek(); this.updateDays(); }
/** * Updates the year. Will also update the month depending on the year. * * @param newYear The new year that has been inputed. */ public void updateYear(int newYear) { currentYear = newYear; yTitle.setText(currentYear + ""); updateMonth(currentMonth); panelEvent.update(); this.updateDays(); }
public void showDialog(MenuItem item) { FragmentManager manager = getFragmentManager(); EventDialog eventDialog = new EventDialog(); eventDialog.show(manager, "EventDialog"); }
/** * On the mini month this method will always highlight the current day in red * * @param s The new day */ public void highlightToday(int s) { // Creates border on the selected day for (int i = 0; i < 42; i++) { float[] n = new float[3]; Color.RGBtoHSB(212, 208, 200, n); miniDays[i].setOpaque(true); miniDays[i].setForeground(Color.BLACK); miniDays[i].setFont(null); Border line = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); TitledBorder title = BorderFactory.createTitledBorder(line); miniDays[i].setBorder(title); } // Creates the font for the selected day miniDays[(currentDay - 1) + currentMonthOffset].setForeground(Color.black); miniDays[(s - 1) + currentMonthOffset].setForeground(Color.BLACK); miniDays[(s - 1) + currentMonthOffset].setFont(new Font("Verdana", Font.BOLD, 12)); miniDays[(s - 1) + currentMonthOffset].setOpaque(true); // Set the border of the selected date in the mini calendar Border line = BorderFactory.createEtchedBorder(Color.BLACK, Color.BLACK); TitledBorder title = BorderFactory.createTitledBorder(line); miniDays[(s - 1) + currentMonthOffset].setBorder(title); // miniDays[(s-1) + currentMonthOffset].setBackground(Color.WHITE); currentDay = s; if (currentMonth == TODAYMONTH && currentYear == TODAYYEAR) { // Highlights the current day in red when the current month and year is selected miniDays[(TODAYDAY - 1) + currentMonthOffset].setForeground(Color.RED); miniDays[(TODAYDAY - 1) + currentMonthOffset].setFont(new Font("Verdana", Font.BOLD, 12)); DayToErase = (TODAYDAY - 1) + currentMonthOffset; } else if (DayToErase > 0) { // changes the current day back to black when the current month and year are not highlighted. miniDays[DayToErase].setForeground(Color.black); DayToErase = -1; } // This var holds the number of dates of the previous month int previousMonthDates = curMonths[((currentMonth - 2) + 12) % 12]; for (int k = currentMonthOffset - 1; k >= 0; k--) { miniDays[k].setText(previousMonthDates + ""); miniDays[k].setForeground(Color.GRAY); previousMonthDates--; } // Testing // Testing // System.out.println("curMonths[currentMonth - 1] ==" + curMonths[currentMonth - 1]); int count = 1; for (int k = (curMonths[currentMonth - 1] + currentMonthOffset); k < 42; k++) { miniDays[k].setText(count + ""); miniDays[k].setForeground(Color.GRAY); count++; } // Testing smallMonth.repaint(); miniMonth.repaint(); panelEvent.update(); weekView.updateWeek(); }