@Test public void testDayBoundsNullDate() { if (GraphicsEnvironment.isHeadless()) { LOG.fine("cannot run test - headless environment"); return; } BasicMonthViewUI ui = getRealizedMonthViewUI(ComponentOrientation.LEFT_TO_RIGHT); try { ui.getDayBounds(null); fail("date param null is not allowed - must fire NPE"); } catch (NullPointerException ex) { } }
protected Rectangle getDayBounds(Date date) { if (!isVisible(date)) return null; Point position = getDayGridPosition(date); Rectangle monthBounds = getMonthBounds(date); monthBounds.y += getMonthHeaderHeight() + (position.y - DAY_HEADER_ROW) * fullBoxHeight; if (monthView.isShowingWeekNumber()) { position.x++; } position.x -= FIRST_DAY_COLUMN; if (isLeftToRight) { monthBounds.x += position.x * fullBoxWidth; } else { int start = monthBounds.x + monthBounds.width - fullBoxWidth; monthBounds.x = start - position.x * fullBoxWidth; } monthBounds.width = fullBoxWidth; monthBounds.height = fullBoxHeight; return monthBounds; }
BasicMonthViewUI extends MonthViewUI { protected Rectangle getDayBounds(Date date) { if (!isVisible(date)) return null; Point position = getDayGridPosition(date); Rectangle monthBounds = getMonthBounds(date); monthBounds.y += getMonthHeaderHeight() + (position.y - DAY_HEADER_ROW) * fullBoxHeight; if (monthView.isShowingWeekNumber()) { position.x++; } position.x -= FIRST_DAY_COLUMN; if (isLeftToRight) { monthBounds.x += position.x * fullBoxWidth; } else { int start = monthBounds.x + monthBounds.width - fullBoxWidth; monthBounds.x = start - position.x * fullBoxWidth; } monthBounds.width = fullBoxWidth; monthBounds.height = fullBoxHeight; return monthBounds; } }
BasicMonthViewUI extends MonthViewUI { protected Rectangle getDayBounds(Date date) { if (!isVisible(date)) return null; Point position = getDayGridPosition(date); Rectangle monthBounds = getMonthBounds(date); monthBounds.y += getMonthHeaderHeight() + (position.y - DAY_HEADER_ROW) * fullBoxHeight; if (monthView.isShowingWeekNumber()) { position.x++; } position.x -= FIRST_DAY_COLUMN; if (isLeftToRight) { monthBounds.x += position.x * fullBoxWidth; } else { int start = monthBounds.x + monthBounds.width - fullBoxWidth; monthBounds.x = start - position.x * fullBoxWidth; } monthBounds.width = fullBoxWidth; monthBounds.height = fullBoxHeight; return monthBounds; }  }
BasicMonthViewUI extends MonthViewUI { protected Rectangle getDayBounds(Date date) { if (!isVisible(date)) return null; Point position = getDayGridPosition(date); Rectangle monthBounds = getMonthBounds(date); monthBounds.y += getMonthHeaderHeight() + (position.y - DAY_HEADER_ROW) * fullBoxHeight; if (monthView.isShowingWeekNumber()) { position.x++; } position.x -= FIRST_DAY_COLUMN; if (isLeftToRight) { monthBounds.x += position.x * fullBoxWidth; } else { int start = monthBounds.x + monthBounds.width - fullBoxWidth; monthBounds.x = start - position.x * fullBoxWidth; } monthBounds.width = fullBoxWidth; monthBounds.height = fullBoxHeight; return monthBounds; }  @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 getDayBounds(Date date) { if (!isVisible(date)) return null; Point position = getDayGridPosition(date); Rectangle monthBounds = getMonthBounds(date); monthBounds.y += getMonthHeaderHeight() + (position.y - DAY_HEADER_ROW) * fullBoxHeight; if (monthView.isShowingWeekNumber()) { position.x++; } position.x -= FIRST_DAY_COLUMN; if (isLeftToRight) { monthBounds.x += position.x * fullBoxWidth; } else { int start = monthBounds.x + monthBounds.width - fullBoxWidth; monthBounds.x = start - position.x * fullBoxWidth; } monthBounds.width = fullBoxWidth; monthBounds.height = fullBoxHeight; return monthBounds; }  @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; }