package jsetool.gui; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.io.Serializable; /** * @author Mike Lawson * * @since Oct 24, 2004 * * Objects that implement Drawable can be managed * the a DrawingPane. * * */ public interface Drawable extends Serializable { /** * Tells the object to draw itself on the given * graphics context. * @param g the graphics context to draw */ public void draw(Graphics g); /** * Tells this object to follow the given mouse event. * * @param me */ public void mouseDragged(MouseEvent me); /** * Returns true if the given mouse event says that it is inside the * drawn shape * @param me * @return boolean */ public boolean isMouseOn(MouseEvent me); /** * Tells the object to highlight itself on the given graphics context. * * @param doHighlight true if the object should highlight itself, false is not. */ public void setHighlight(boolean doHighlight); /** * Called by the encapsulating drawing pane whenever the mouse * is pressed on this object. * * @param me the event that caused the callback. */ public void mousePressed(MouseEvent me); /** * Called by the encapsulating drawing pane whenever the mouse * is released off of this object. * * @param me the event that caused the callback. */ public void mouseReleased(MouseEvent me); /** * Called by the encapsulating drawing pane whenever the mouse * is clicked on the object. This object should set itself as * "selected." * @param isSelected true if the object is selected, false if not. * @param me the event that caused the callback. * */ public void setSelected(boolean isSelected, MouseEvent me); /** * Sets whether this object is editable or not, based on the value. * * Implementations should cache this value and take appropriate actions * when showEditor is called (if ever). * * An example is whether an object will let you change its label. * @param isEditable */ public void setEditable(boolean isEditable); /** * Called when the user has selected to edit something about * the Drawable object, e.g. change it's label. * * This will always be called, regardless if setEditable has * been previously called. * * @param me the event that caused the callback */ public void showEditor(MouseEvent me); /** * Tells the Drawable object that it is being deleted. * The object should clean up any open resources and identify any * other associated drawables that must be deleted as well. * * It should set a flag such that toBeDeleted returns true for itself * and all associated objects. * */ public void objectIsBeingDeleted(); /** * Returns true if this object should be deleted from the drawing pane. * * @return boolean */ public boolean toBeDeleted(); /** * Gets the X coordinate of the upper-left point of the object. * @return double */ public double getX(); /** * Gets the Y coordinate of the upper-left point of the object. * @return double */ public double getY(); /** * Gets the width of the object * @return double */ public double getWidth(); /** * Gets the height of the object. * * @return double */ public double getHeight(); /** * Optional method, sets a temporary flag to be the given value. * * @param b */ public void setExplored(boolean b); }