jdraw.framework
Interface Figure

All Superinterfaces:
java.lang.Cloneable, java.io.Serializable

public interface Figure
extends java.io.Serializable, java.lang.Cloneable

Base interface for all figures implemented in the grafic editor. Every Figure-type has to implement this interface.


Method Summary
 void addFigureListener(jdraw.framework.FigureListener listener)
          Adds the specified figure listener to receive figure events from this figure.
 java.lang.Object clone()
          Returns a Clone of this figure
 boolean contains(int x, int y)
          Tests whether the mouse coordinates are contained in the figure.
 void draw(java.awt.Graphics g)
          draw is called when the figure has to be drawn.
 java.awt.Rectangle getBounds()
          Returns the bounds of a figure.
 java.awt.Point getCenter()
          Returns the center of a figure.
 java.util.List getHandles()
          Returns a list of handles.
 boolean isEmpty()
          Tests whether the figure is empty.
 void move(int dx, int dy)
          Moves the figure.
 void removeFigureListener(jdraw.framework.FigureListener listener)
          Removes the specified figure listener so that it no longer receives figure events from this figure.
 void setBounds(java.awt.Point origin, java.awt.Point corner)
          Changes the bounds of the figure.
 

Method Detail

setBounds

public void setBounds(java.awt.Point origin,
                      java.awt.Point corner)
Changes the bounds of the figure. The figure has to adjust its size and position when this method is called, and registered figure listeners have to be notified.

Parameters:
origin - the new origin
corner - the new corner
See Also:
addFigureListener(jdraw.framework.FigureListener)

draw

public void draw(java.awt.Graphics g)
draw is called when the figure has to be drawn.

Parameters:
g - Graphics object on which figure has to be drawn.
See Also:
Graphics

move

public void move(int dx,
                 int dy)
Moves the figure. The figure has to adjust its coordinates when this method is called, and registered figure listeners have to be notified.

Parameters:
dx - move distance in x direction (argument in pixels)
dy - move distance in y direction (argument in pixels)
See Also:
addFigureListener(jdraw.framework.FigureListener)

contains

public boolean contains(int x,
                        int y)
Tests whether the mouse coordinates are contained in the figure. contains is called when the mouse is pressed in the grafic in order to decide which figure has to be selected.

Parameters:
x - x-coordinate of mouse position
y - y-coordinate of mouse position
Returns:
true, if coordinates are contained in the figure, false otherwise

getBounds

public java.awt.Rectangle getBounds()
Returns the bounds of a figure. The bounds of a figure is a rectangle which contains the figure.

Returns:
bounds of the figure

getCenter

public java.awt.Point getCenter()
Returns the center of a figure. The center is usually the center of its bounds rectangle.

Returns:
center of the figure

getHandles

public java.util.List getHandles()
Returns a list of handles. Handles are used to manipulate a figure. If the figure does not support handles, null may be returned as result.

Returns:
list of handles (may be null if handles are not supported)
See Also:
FigureHandle

isEmpty

public boolean isEmpty()
Tests whether the figure is empty. This method may be called when a new figure is spawn in order to decide whether the figure should be included in the model or not. Empty figures may be discarded. This behavior has to be implemented in the extensions of DrawTool.

Returns:
true, if figure is "empty" false otherwise
See Also:
DrawTool

addFigureListener

public void addFigureListener(jdraw.framework.FigureListener listener)
Adds the specified figure listener to receive figure events from this figure. If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the figure listener.
See Also:
FigureListener

removeFigureListener

public void removeFigureListener(jdraw.framework.FigureListener listener)
Removes the specified figure listener so that it no longer receives figure events from this figure. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this figure. If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the figure listener.
See Also:
FigureListener

clone

public java.lang.Object clone()
Returns a Clone of this figure

Overrides:
clone in class java.lang.Object
Returns:
clone of figure