/** * Retrieve the <code>Lite</code> object visible under a point. This object should actually be * searched in reverse order in the <code>Lite</code> object list. */ public Lite itemUnder(int x, int y) { for (int i = lites.size() - 1; i >= 0; i--) { Lite l = elementAt(i); if (l.getBounds().contains(x, y)) return l; } return null; }
/** * Paint each <code>Lite</code> object in turn after testing if it is inside the clip of the * Graphics. This is the right way to do it if the repainting time of <code>Lite</code> objects is * much greater than the time required to compute its bounds. * * @see excentric.LiteGroup#paintAll(java.awt.Graphics) */ public void paint(Graphics g) { Rectangle clip = g.getClipBounds(); for (Enumeration e = lites.elements(); e.hasMoreElements(); ) { Lite l = (Lite) e.nextElement(); // if (l.getBounds().intersects(clip)) l.paint(g); } }
/** * Compute the bounds of the <code>Lite</code> objets. * * @return The bounding rectangle. */ public Rectangle getBounds() { if (lites.isEmpty()) return new Rectangle(); Enumeration e = elements(); Lite l = (Lite) e.nextElement(); Rectangle r = l.getBounds(); while (e.hasMoreElements()) { l = (Lite) e.nextElement(); r.add(l.getBounds()); } return r; }
/** * Paint each <code>Lite</code> object . * * @see excentric.LiteGroup#paint(java.awt.Graphics) */ public void paintAll(Graphics g) { for (Enumeration e = lites.elements(); e.hasMoreElements(); ) { Lite l = (Lite) e.nextElement(); l.paint(g); } }
/** * Sets the position of each of the <code>Lite</code> objects to the specified Point. * * @param p The new position point. */ public void setPosition(Point p) { for (Enumeration e = lites.elements(); e.hasMoreElements(); ) { Lite l = (Lite) e.nextElement(); l.setPosition(p); } }