org.tigris.gef.base
Class Selection

java.lang.Object
  extended by org.tigris.gef.base.Selection
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
SelectionLowerRight, SelectionMove, SelectionNoop, SelectionReshape, SelectionResize, SelectionRotate

public abstract class Selection
extends java.lang.Object
implements java.io.Serializable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener

This class represents the "selection" object that is used when you select one or more Figs in the drawing window. Selections handle the display of handles or whatever graphics indicate that something is selected, and they process events to manipulate the selected Fig.

See Also:
Fig, Serialized Form

Field Summary
protected  Fig _content
          _content refers to the Fig that is selected.
static int BORDER_WIDTH
          The margin between the contents bbox and the frame
static int HAND_SIZE
          The size of the little handle boxes.
 
Constructor Summary
Selection(Fig f)
          Construct a new selection.
 
Method Summary
 boolean contains(Fig f)
          Reply true if this selection contains the given Fig
 boolean contains(int x, int y)
           
 boolean contains(java.awt.Point pnt)
          Reply true if the given point is inside this selection
 void damage()
          This selection object needs to be redrawn, register its damaged area within the given Editor
 void delete()
          If the selection is being deleted, the selected object must be deleted also.
 void dispose()
           
abstract  void dragHandle(int mx, int my, int an_x, int an_y, Handle h)
          Move one of the handles of a selected Fig.
 void endTrans()
          Tell the content to end a transaction that causes damage
 java.awt.Rectangle getBounds()
          The bounding box of the selection is the bbox of the contained Fig.
 Fig getContent()
          Reply the Fig that was selected
 java.awt.Rectangle getContentBounds()
          Reply the bounding box of the selected Figs, does not include space used by handles.
 java.awt.Point getLocation()
          Reply the position of the Selection.
 boolean getLocked()
           
 boolean hit(java.awt.Rectangle r)
          Reply true if the given Rectangle is inside or overlapps me
 void hitHandle(int x, int y, int w, int h, Handle hdl)
           
abstract  void hitHandle(java.awt.Rectangle r, Handle h)
          Find which handle the user clicked on, or return -1 if none.
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void keyReleased(java.awt.event.KeyEvent ke)
           
 void keyTyped(java.awt.event.KeyEvent ke)
          Pass any events along to the selected Fig.
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseDragged(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
           
 void paint(java.awt.Graphics g)
          Abstract method to display the selection handleds.
 void print(java.awt.Graphics g)
          Do nothing.
 void reorder(int func, Layer lay)
          Tell the selected Fig to move to front or back, etc.
 void setcontent(Fig f)
           
 void stuffBounds(java.awt.Rectangle r)
          Returns my bounding box in the given Rectangle.
 void translate(int dx, int dy)
          When the selection is told to move, move the selected Fig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HAND_SIZE

public static final int HAND_SIZE
The size of the little handle boxes.

See Also:
Constant Field Values

BORDER_WIDTH

public static final int BORDER_WIDTH
The margin between the contents bbox and the frame

See Also:
Constant Field Values

_content

protected Fig _content
_content refers to the Fig that is selected.

Constructor Detail

Selection

public Selection(Fig f)
Construct a new selection. Empty, subclases can override

Method Detail

getContent

public Fig getContent()
Reply the Fig that was selected


setcontent

public void setcontent(Fig f)

getLocked

public boolean getLocked()

contains

public boolean contains(Fig f)
Reply true if this selection contains the given Fig


print

public void print(java.awt.Graphics g)
Do nothing. Selections shoudl not appear in print outs.


paint

public void paint(java.awt.Graphics g)
Abstract method to display the selection handleds.


endTrans

public void endTrans()
Tell the content to end a transaction that causes damage


getLocation

public java.awt.Point getLocation()
Reply the position of the Selection. That is defined to be the upper left corner of my bounding box.


damage

public void damage()
This selection object needs to be redrawn, register its damaged area within the given Editor


contains

public final boolean contains(java.awt.Point pnt)
Reply true if the given point is inside this selection


contains

public boolean contains(int x,
                        int y)

hit

public boolean hit(java.awt.Rectangle r)
Reply true if the given Rectangle is inside or overlapps me


hitHandle

public abstract void hitHandle(java.awt.Rectangle r,
                               Handle h)
Find which handle the user clicked on, or return -1 if none.


hitHandle

public final void hitHandle(int x,
                            int y,
                            int w,
                            int h,
                            Handle hdl)

reorder

public void reorder(int func,
                    Layer lay)
Tell the selected Fig to move to front or back, etc.


translate

public void translate(int dx,
                      int dy)
When the selection is told to move, move the selected Fig


getBounds

public java.awt.Rectangle getBounds()
The bounding box of the selection is the bbox of the contained Fig.


stuffBounds

public void stuffBounds(java.awt.Rectangle r)
Returns my bounding box in the given Rectangle. This avoids memory allocation.


delete

public void delete()
If the selection is being deleted, the selected object must be deleted also. This is different from just deselecting the selected Fig, to do that use one of the deselect operations in SelectionManager.

See Also:
SelectionManager.deselect(org.tigris.gef.presentation.Fig)

dispose

public void dispose()

dragHandle

public abstract void dragHandle(int mx,
                                int my,
                                int an_x,
                                int an_y,
                                Handle h)
Move one of the handles of a selected Fig.


getContentBounds

public java.awt.Rectangle getContentBounds()
Reply the bounding box of the selected Figs, does not include space used by handles.


keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Pass any events along to the selected Fig. Subclasses of Selection may reimplement this to add functionality.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Specified by:
keyReleased in interface java.awt.event.KeyListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener