@Test public void testDayGridPositionAtLocationRows() { if (GraphicsEnvironment.isHeadless()) { LOG.fine("cannot run test - headless environment"); return; } BasicMonthViewUI ui = getRealizedMonthViewUI(ComponentOrientation.RIGHT_TO_LEFT); int calendarRow = BasicMonthViewUI.DAY_HEADER_ROW; for (int row = 0; row <= BasicMonthViewUI.WEEKS_IN_MONTH; row++) { Point location = getLocationInRow(ui, row); Point dayGridPosition = ui.getDayGridPositionAtLocation(location.x, location.y); assertEquals("calendarRow at absolute row " + row, calendarRow, dayGridPosition.y); calendarRow++; } }
protected Point getDayGridPositionAtLocation(int x, int y) { Rectangle monthDetailsBounds = getMonthDetailsBoundsAtLocation(x, y); if ((monthDetailsBounds == null) || (!monthDetailsBounds.contains(x, y))) return null; int calendarRow = (y - monthDetailsBounds.y) / fullBoxHeight + DAY_HEADER_ROW; int absoluteColumn = (x - monthDetailsBounds.x) / fullBoxWidth; int calendarColumn = absoluteColumn + FIRST_DAY_COLUMN; if (!isLeftToRight) { int leading = monthDetailsBounds.x + monthDetailsBounds.width; calendarColumn = (leading - x) / fullBoxWidth + FIRST_DAY_COLUMN; } if (monthView.isShowingWeekNumber()) { calendarColumn -= 1; } return new Point(calendarColumn, calendarRow); }
BasicMonthViewUI extends MonthViewUI { protected Point getDayGridPositionAtLocation(int x, int y) { Rectangle monthDetailsBounds = getMonthDetailsBoundsAtLocation(x, y); if ((monthDetailsBounds == null) || (!monthDetailsBounds.contains(x, y))) return null; int calendarRow = (y - monthDetailsBounds.y) / fullBoxHeight + DAY_HEADER_ROW; int absoluteColumn = (x - monthDetailsBounds.x) / fullBoxWidth; int calendarColumn = absoluteColumn + FIRST_DAY_COLUMN; if (!isLeftToRight) { int leading = monthDetailsBounds.x + monthDetailsBounds.width; calendarColumn = (leading - x) / fullBoxWidth + FIRST_DAY_COLUMN; } if (monthView.isShowingWeekNumber()) { calendarColumn -= 1; } return new Point(calendarColumn, calendarRow); } }
BasicMonthViewUI extends MonthViewUI { protected Point getDayGridPositionAtLocation(int x, int y) { Rectangle monthDetailsBounds = getMonthDetailsBoundsAtLocation(x, y); if ((monthDetailsBounds == null) || (!monthDetailsBounds.contains(x, y))) return null; int calendarRow = (y - monthDetailsBounds.y) / fullBoxHeight + DAY_HEADER_ROW; int absoluteColumn = (x - monthDetailsBounds.x) / fullBoxWidth; int calendarColumn = absoluteColumn + FIRST_DAY_COLUMN; if (!isLeftToRight) { int leading = monthDetailsBounds.x + monthDetailsBounds.width; calendarColumn = (leading - x) / fullBoxWidth + FIRST_DAY_COLUMN; } if (monthView.isShowingWeekNumber()) { calendarColumn -= 1; } return new Point(calendarColumn, calendarRow); }  }
BasicMonthViewUI extends MonthViewUI { protected Point getDayGridPositionAtLocation(int x, int y) { Rectangle monthDetailsBounds = getMonthDetailsBoundsAtLocation(x, y); if ((monthDetailsBounds == null) || (!monthDetailsBounds.contains(x, y))) return null; int calendarRow = (y - monthDetailsBounds.y) / fullBoxHeight + DAY_HEADER_ROW; int absoluteColumn = (x - monthDetailsBounds.x) / fullBoxWidth; int calendarColumn = absoluteColumn + FIRST_DAY_COLUMN; if (!isLeftToRight) { int leading = monthDetailsBounds.x + monthDetailsBounds.width; calendarColumn = (leading - x) / fullBoxWidth + FIRST_DAY_COLUMN; } if (monthView.isShowingWeekNumber()) { calendarColumn -= 1; } return new Point(calendarColumn, calendarRow); }  @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 Point getDayGridPositionAtLocation(int x, int y) { Rectangle monthDetailsBounds = getMonthDetailsBoundsAtLocation(x, y); if ((monthDetailsBounds == null) || (!monthDetailsBounds.contains(x, y))) return null; int calendarRow = (y - monthDetailsBounds.y) / fullBoxHeight + DAY_HEADER_ROW; int absoluteColumn = (x - monthDetailsBounds.x) / fullBoxWidth; int calendarColumn = absoluteColumn + FIRST_DAY_COLUMN; if (!isLeftToRight) { int leading = monthDetailsBounds.x + monthDetailsBounds.width; calendarColumn = (leading - x) / fullBoxWidth + FIRST_DAY_COLUMN; } if (monthView.isShowingWeekNumber()) { calendarColumn -= 1; } return new Point(calendarColumn, calendarRow); }  @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; }