List of usage examples for org.joda.time MutableDateTime MutableDateTime
public MutableDateTime(Object instant)
From source file:com.tmathmeyer.sentinel.ui.views.year.YearCalendar.java
License:Open Source License
/** * //from w w w. j a va 2s . co m * @param dt any date time in the year that you wish to display * @param eventModel the event model so that this can access the database */ public YearCalendar(DateTime dt, EventClient eventModel) { this.setLayout(new BorderLayout()); drawCalendar(new MutableDateTime(dt)); this.eventModel = eventModel; }
From source file:com.tmathmeyer.sentinel.ui.views.year.YearCalendar.java
License:Open Source License
/** * /*from ww w .j a v a 2 s . c om*/ * @param dt any date time * @return the date time that corresponds to january first of the year of * the date time provided */ private MutableDateTime getStartOfYearCalendar(DateTime dt) { MutableDateTime jan1 = new MutableDateTime(new DateTime(dt.getYear(), 1, 1, 1, 1)); jan1.addDays(0 - (jan1.getDayOfWeek())); return jan1; }
From source file:com.tmathmeyer.sentinel.ui.views.year.YearCalendar.java
License:Open Source License
/** * gets the drawn year/*from w w w . j a v a 2 s.com*/ * * @param start the date time that starts the series. * @return the jpanel that contains the colored days and the S/M/T/W/R/F/S * labels */ private JPanel getFourMonthGrid(MutableDateTime start) { int gridHeight = 19; int gridWidth = 7; JPanel p = new JPanel(); p.setLayout(new GridLayout(gridHeight, gridWidth)); String[] days = { "S", "M", "T", "W", "R", "F", "S" }; for (int i = 0; i < 7; i++) { JLabel header = new JLabel(days[i]); header.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Colors.BORDER)); header.setHorizontalAlignment(SwingConstants.CENTER); header.setFont(new Font("DejaVu Sans", Font.ITALIC, 12)); p.add(header); } for (int j = 0; j < 18 * 7; j++) { Color dayBackground = start.getMonthOfYear() % 2 == 0 ? Colors.TABLE_BACKGROUND : Colors.TABLE_GRAY_HEADER; Integer eventCount = events.get(start.getDayOfYear()); eventCount = eventCount == null ? 0 : eventCount; YearlyDayHolder day = new YearlyDayHolder(start.toDateTime(), dayBackground); MutableDateTime today = new MutableDateTime(DateTime.now()); today.setMillisOfDay(0); MutableDateTime checking = new MutableDateTime(start); start.setMillisOfDay(0); if (checking.toDateTime().isEqual(today)) { day.setBackground(Colors.SELECTED_BACKGROUND); day.setForeground(Colors.SELECTED_TEXT); } JLabel dayLabel = new JLabel(start.getDayOfMonth() + ""); dayLabel.setHorizontalAlignment(SwingConstants.CENTER); day.setLayout(new GridLayout(1, 1)); day.add(dayLabel); day.setBorder( BorderFactory.createMatteBorder(0, start.getDayOfWeek() % 7 == 0 ? 1 : 0, 1, 1, Colors.BORDER)); day.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent me) { YearlyDayHolder event = (YearlyDayHolder) (me.getSource()); MainPanel.getInstance().miniMove(event.getDateTime()); MainPanel.getInstance().viewDay(); } @Override public void mouseEntered(MouseEvent me) { // this is just a demo of what it can do } @Override public void mouseExited(MouseEvent me) { } @Override public void mousePressed(MouseEvent me) { // TODO: something? maybe nothing? have to decide with // team/steakholders } @Override public void mouseReleased(MouseEvent me) { YearlyDayHolder event = (YearlyDayHolder) (me.getSource()); MainPanel.getInstance().miniMove(event.getDateTime()); } }); p.add(day); start.addDays(1); } int width = 280; int height = 570; p.setMinimumSize(new Dimension(0, height - 150)); p.setPreferredSize(new Dimension(width, height)); p.setMaximumSize(new Dimension(width + 350, height + 150)); return p; }
From source file:com.tmathmeyer.sentinel.ui.views.year.YearCalendar.java
License:Open Source License
@Override public void previous() { MutableDateTime mdt = new MutableDateTime(this.calendarStart); mdt.addYears(-2);/*from w w w . j av a 2s . c om*/ this.display(mdt.toDateTime()); }
From source file:com.tmathmeyer.sentinel.ui.views.year.YearCalendar.java
License:Open Source License
@Override public void display(DateTime newTime) { this.events.clear(); this.drawCalendar(new MutableDateTime(newTime)); MainPanel.getInstance().miniMove(newTime); this.revalidate(); this.repaint(); }
From source file:com.tmathmeyer.sentinel.ui.views.year.YearCalendar.java
License:Open Source License
@Override public void updateDisplayable(Displayable event, boolean added) { Interval ival = event.getInterval(); MutableDateTime start = new MutableDateTime(ival.getStart()); while (start.isBefore(ival.getEnd())) { if (!added) { int day = start.getDayOfYear(); Integer ec = this.events.get(day); int eventCount = (ec == null || ec <= 0) ? 0 : ec - 1; this.events.put(day, eventCount); } else {/* w w w . j av a 2 s. c o m*/ int day = start.getDayOfYear(); Integer ec = this.events.get(day); int eventCount = (ec == null) ? 1 : ec + 1; this.events.put(day, eventCount); } start.addDays(1); } }
From source file:com.tmathmeyer.sentinel.utils.Months.java
License:Open Source License
public static DateTime nextMonth(DateTime time) { MutableDateTime mdt = new MutableDateTime(time); mdt.addMonths(1); return mdt.toDateTime(); }
From source file:com.tmathmeyer.sentinel.utils.Months.java
License:Open Source License
public static DateTime prevMonth(DateTime time) { MutableDateTime mdt = new MutableDateTime(time); mdt.addMonths(-1); return mdt.toDateTime(); }
From source file:com.tmathmeyer.sentinel.utils.Months.java
License:Open Source License
public static DateTime nextDay(DateTime time) { MutableDateTime mdt = new MutableDateTime(time); mdt.addDays(1); return mdt.toDateTime(); }
From source file:com.tmathmeyer.sentinel.utils.Months.java
License:Open Source License
public static DateTime prevDay(DateTime time) { MutableDateTime mdt = new MutableDateTime(time); mdt.addDays(-1); return mdt.toDateTime(); }