@Test @Ignore("Math.ceil use seems to result in pixel difference") public void testMonthBoundsAtLocation() { if (GraphicsEnvironment.isHeadless()) { LOG.fine("cannot run test - headless environment"); return; } BasicMonthViewUI uiRToL = getRealizedMonthViewUI(ComponentOrientation.RIGHT_TO_LEFT); BasicMonthViewUI uiLToR = getRealizedMonthViewUI(ComponentOrientation.LEFT_TO_RIGHT); Rectangle monthBoundsRToL = uiRToL.getMonthBoundsAtLocation(20, 20); Rectangle monthBoundsLToR = uiLToR.getMonthBoundsAtLocation(20, 20); assertEquals("bounds of left-most month must be equal", monthBoundsLToR, monthBoundsRToL); Rectangle monthBoundsTwoRToL = uiRToL.getMonthBoundsAtLocation( monthBoundsRToL.width + 20, 20); Rectangle monthBoundsTwoLToR = uiRToL.getMonthBoundsAtLocation( monthBoundsLToR.width + 20, 20); assertEquals("bounds of right-most month must be equal", monthBoundsTwoLToR, monthBoundsTwoRToL); }
protected Rectangle getMonthBoundsAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; return new Rectangle(calendarGrid.x + calendarColumn * fullCalendarWidth, calendarGrid.y + calendarRow * fullCalendarHeight, calendarWidth, calendarHeight); }
BasicMonthViewUI extends MonthViewUI { protected Rectangle getMonthBoundsAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; return new Rectangle(calendarGrid.x + calendarColumn * fullCalendarWidth, calendarGrid.y + calendarRow * fullCalendarHeight, calendarWidth, calendarHeight); } }
BasicMonthViewUI extends MonthViewUI { protected Rectangle getMonthBoundsAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; return new Rectangle(calendarGrid.x + calendarColumn * fullCalendarWidth, calendarGrid.y + calendarRow * fullCalendarHeight, calendarWidth, calendarHeight); }  }
BasicMonthViewUI extends MonthViewUI { protected Rectangle getMonthBoundsAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; return new Rectangle(calendarGrid.x + calendarColumn * fullCalendarWidth, calendarGrid.y + calendarRow * fullCalendarHeight, calendarWidth, calendarHeight); }  @SuppressWarnings({ "UnusedDeclaration" }) static ComponentUI createUI(JComponent c); @Override void installUI(JComponent c); @Override void uninstallUI(JComponent c); @Override String[] getDaysOfTheWeek(); boolean isUsingKeyboard(); void setUsingKeyboard(boolean val); @Override Date getDayAtLocation(int x, int y); boolean isWeekOfYearCell(int x, int y); @Override void update(Graphics g, JComponent c); @Override void paint(Graphics g, JComponent c); @Override Date getLastDisplayedDay(); }
BasicMonthViewUI extends MonthViewUI { protected Rectangle getMonthBoundsAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; return new Rectangle(calendarGrid.x + calendarColumn * fullCalendarWidth, calendarGrid.y + calendarRow * fullCalendarHeight, calendarWidth, calendarHeight); }  @SuppressWarnings({ "UnusedDeclaration" }) static ComponentUI createUI(JComponent c); @Override void installUI(JComponent c); @Override void uninstallUI(JComponent c); @Override String[] getDaysOfTheWeek(); boolean isUsingKeyboard(); void setUsingKeyboard(boolean val); @Override Date getDayAtLocation(int x, int y); boolean isWeekOfYearCell(int x, int y); @Override void update(Graphics g, JComponent c); @Override void paint(Graphics g, JComponent c); @Override Date getLastDisplayedDay(); static final int MONTH_DOWN; static final int MONTH_UP; }