@Test public void testMonthGridPositionAtLocation() { 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); Point gridPositionLToR = uiLToR.getMonthGridPositionAtLocation(20, 20); assertEquals(0, gridPositionLToR.x); Point gridPositionRToL = uiRToL.getMonthGridPositionAtLocation(20, 20); assertEquals(1, gridPositionRToL.x); }
protected Point getMonthGridPositionAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; if (!isLeftToRight) { int start = calendarGrid.x + calendarGrid.width; calendarColumn = (start - x) / fullCalendarWidth; } return new Point(calendarColumn, calendarRow); }
BasicMonthViewUI extends MonthViewUI { protected Point getMonthGridPositionAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; if (!isLeftToRight) { int start = calendarGrid.x + calendarGrid.width; calendarColumn = (start - x) / fullCalendarWidth; } return new Point(calendarColumn, calendarRow); } }
BasicMonthViewUI extends MonthViewUI { protected Point getMonthGridPositionAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; if (!isLeftToRight) { int start = calendarGrid.x + calendarGrid.width; calendarColumn = (start - x) / fullCalendarWidth; } return new Point(calendarColumn, calendarRow); }  }
BasicMonthViewUI extends MonthViewUI { protected Point getMonthGridPositionAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; if (!isLeftToRight) { int start = calendarGrid.x + calendarGrid.width; calendarColumn = (start - x) / fullCalendarWidth; } 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 getMonthGridPositionAtLocation(int x, int y) { if (!calendarGrid.contains(x, y)) return null; int calendarRow = (y - calendarGrid.y) / fullCalendarHeight; int calendarColumn = (x - calendarGrid.x) / fullCalendarWidth; if (!isLeftToRight) { int start = calendarGrid.x + calendarGrid.width; calendarColumn = (start - x) / fullCalendarWidth; } 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; }