package ballWorlds; import java.awt.Shape; import java.awt.geom.Point2D; /** * A Morphable is an object that can be "morphed" in various ways: for example, * changing its position, velocity, mass, size, Shape or World. * * @author David Mutchler, Salman Azhar, Curt Clifton and others, January 2005. * Modified September 2008, September 2009. */ public interface Morphable { /** * Moves this Morphable object to the given Point2D, by setting the * Morphable's position (part of its Shape) to the given Point2D. * * @param point * the Point2D to which this Morphable object should move. */ public void moveTo(Point2D point); /** * Moves this Morphable object from its current World to the given World, * but maintaining the same position (point) at which the Morphable * currently lives. * * @param world * the World to which this Morphable object should move. */ public void moveTo(World world); /** * Moves this Morphable object to the given Point2D in the given World. * * @param point * the Point2D to which this Morphable object should move. * @param world * the World to which this Morphable object should move. */ public void moveTo(Point2D point, World world); /** * Applies the given force (in the x and y directions) to this Morphable. * * @param force * force (in the x and y directions) to apply to this Morphable. */ public void applyForce(Point2D force); /** * Sets the velocity (i.e., speed in x-direction and speed in y-direction) * of this Morphable object to the given velocity. * * @param velocity * the new velocity for this Morphable object. */ public void setVelocity(Point2D velocity); /** * Multiplies this Morphable object's size by the given multiplier, thus * either shrinking (multiplier < 1) or expanding (multiplier > 1) this * Morphable object's size. The size of an object should be incorporated * into its Shape. * * @param multiplier * number to multiply this Morphable object's size by. */ public void multiplySize(double multiplier); /** * Sets this Morphable object's size to the given size. The size of an * object should be incorporated in its Shape. * * @param size * size to set this Morphable object's size to. */ public void setSize(double size); /** * Sets this Morphable object's mass to the given mass. * * @param mass * mass to set this Morphable object's mass to. */ public void setMass(double mass); /** * Sets the Shape of this Morphable object to the given Shape. * * @param shape * the new Shape for this Morphable object. */ public void setShape(Shape shape); }