/** * Causes the module to move to the specified Vector location. * * <p>This method is NOT overloadable because very specific things need to happen when moved for * the module to work correctly. * * @param v The Vector to move to. */ public final void locate(Vector v) { onLocate(v); bounds.position = new Vector( v); // The Vector is copied so that nothing has a reference to position through a // refererence }
/** * Causes the module to move to the specified position. * * <p>This method is NOT overloadable because very specific things need to happen when moved for * the module to work correctly. * * @param x The new x position of the module. * @param y The new y position of the module. */ public final void locate(int x, int y) { onLocate( new Vector( x, y)); // Call the onLocate() method in case a subclass wants to know when it is // re-located bounds.position = new Vector(x, y); // The position has changed, so update the bounds position }
/** * Causes the module to resize as the specified Vector. * * <p>This method is NOT overloadable because very specific things need to happen when resized for * the module to work correctly. * * @param v The Vector to resize to. */ public final void resize(Vector v) { v.x = v.x < 0 ? 0 : v.x; v.y = v.y < 0 ? 0 : v.y; onResize(v); bounds.size = new Vector( v); // The Vector is copied so that nothing has a reference to size through a // refererence // doRenderCalc(); repaint(); // repaint(); }
/** * Causes the module to resize to the specified width and height. * * <p>This method is NOT overloadable because very specific things need to happen when resized for * the module to work correctly. * * @param width The new width of the module. * @param height The new height of the module. */ public final void resize(int width, int height) { width = width < 0 ? 0 : width; // The Module should not be resizable to less than zero height = height < 0 ? 0 : height; onResize( new Vector( width, height)); // Call the onResize() method in case a subclass cares when it is resized bounds.size = new Vector(width, height); // Update the size of the bounds // doRenderCalc(); //Re-do render calculations because this now has a different buffer size // repaint(); //Redraw in case it needs to be re-drawn repaint(); }
public final boolean intersects(Rectangle r) { return (bounds.intersects(r)); }
public final boolean intersects(Module m) { return (bounds.intersects(m.bounds)); }
public final int bottom() { return bounds.bottom(); }
/* right() and bottom() return the x and y values of the right of the Module and thhe bottom of the Module, respectively. These cannot be modified. */ public final int right() { return bounds.right(); }
/** * Returns whether the Module contains the specified point. * * <p>The Container classes often need to know whether a point is within the bounds of a Module, * particularly whether the Module contains the mouse so that it is active. * * @param point The point to check against. * @return Whether the point is within the Module's bounds. */ public final boolean containsPoint(Vector point) { return bounds.contains(point); }