package jdraw.framework;

import java.awt.*;
import java.awt.event.MouseEvent;

/**
 * Handles are used to change a figure by direct manipulation.
 * Handles know their owning figure and they provide methods to
 * ask the handle's bounds and to track changes.
 * @see Figure
 *
 * @author  Dominik Gruntz
 * @version 2.0, 26.04.01
 */
public interface Handle {
	
	/**
	 * Gets the handle's owner.
	 * @return the figure which owns the handle
	 */
	public Figure getOwner();
	
	/**
	 * Gets the bounding box of the handle. This result depends on the
	 * current position of the figure.
	 * @return bounds of handle
	 */
	public java.awt.Rectangle getBounds();
	
	/**
	 * Draws this handle.
	 */
	public void draw(Graphics g);

	/**
	 * Returns a curser which should be displayed when the mouse is
	 * over the handle. Signals the type of operation which can be
	 * performed using this handle.
	 * <P>
	 * A default implementation may return
	 * Cursor.getDefaultCursor().
	 * @return handle's Cursor
	 */
	public Cursor getCursor();
	
	/**
	 * Tests if a point is contained in the handle.
	 * @param x x-coordinate of mouse position
	 * @param y y-coordinate of mouse position
	 * @return <tt>true</tt>, if coordinates are contained in the figure, 
	 *         <tt>false</tt> otherwise
	 */
	public boolean contains(int x, int y);
	
	/**
	 * Tracks the start of an interaction. Usually, the position
	 * where an interaction starts is stored.
	 * @param x the x position where the interaction started
	 * @param y the y position where the interaction started
	 * @param view the view in which the interaction is performed
	 */
	public void startInteraction(int x, int y, MouseEvent e, DrawView v);

	
	/**
	 * Tracks a step of a started interaction.
	 * @param x the current x position
	 * @param y the current y position
	 * @param view the view in which the interaction is performed
	 */
	public void dragInteraction(int x, int y, MouseEvent e, DrawView v);

	
	/**
	 * Tracks the end of a running interaction.
	 * @param x the current x position
	 * @param y the current y position
	 * @param view the view in which the interaction is performed
	 */
	public void stopInteraction(int x, int y, MouseEvent e, DrawView v);
}
