uci.gef
Class Selection

java.lang.Object
  |
  +--uci.gef.Selection
Direct Known Subclasses:
SelectionLowerRight, SelectionMove, SelectionNoop, SelectionReshape, SelectionResize, SelectionRotate

public abstract class Selection
extends Object
implements Serializable, MouseListener, MouseMotionListener, 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(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
 Rectangle getBounds()
          The bounding box of the selection is the bbox of the contained Fig.
 Fig getContent()
          Reply the Fig that was selected
 Rectangle getContentBounds()
          Reply the bounding box of the selected Figs, does not include space used by handles.
 Point getLocation()
          Reply the position of the Selection.
 boolean getLocked()
           
 boolean hit(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(Rectangle r, Handle h)
          Find which handle the user clicked on, or return -1 if none.
 void keyPressed(KeyEvent ke)
           
 void keyReleased(KeyEvent ke)
           
 void keyTyped(KeyEvent ke)
          Pass any events along to the selected Fig.
 void mouseClicked(MouseEvent me)
           
 void mouseDragged(MouseEvent me)
           
 void mouseEntered(MouseEvent me)
           
 void mouseExited(MouseEvent me)
           
 void mouseMoved(MouseEvent me)
           
 void mousePressed(MouseEvent me)
           
 void mouseReleased(MouseEvent me)
           
 void paint(Graphics g)
          Abstract method to display the selection handleds.
 void print(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 startTrans()
          Tell the content to start a transaction that causes damage
 void stuffBounds(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.

BORDER_WIDTH

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

_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(Graphics g)
Do nothing. Selections shoudl not appear in print outs.

paint

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

startTrans

public void startTrans()
Tell the content to start a transaction that causes damage

endTrans

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

getLocation

public 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(Point pnt)
Reply true if the given point is inside this selection

contains

public boolean contains(int x,
                        int y)

hit

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

hitHandle

public abstract void hitHandle(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 Rectangle getBounds()
The bounding box of the selection is the bbox of the contained Fig.

stuffBounds

public void stuffBounds(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 Editor.
See Also:
Editor#deselect

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 Rectangle getContentBounds()
Reply the bounding box of the selected Figs, does not include space used by handles.

keyTyped

public void keyTyped(KeyEvent ke)
Pass any events along to the selected Fig. Subclasses of Selection may reimplement this to add functionality.
Specified by:
keyTyped in interface KeyListener

keyPressed

public void keyPressed(KeyEvent ke)
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent ke)
Specified by:
keyReleased in interface KeyListener

mouseMoved

public void mouseMoved(MouseEvent me)
Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent me)
Specified by:
mouseDragged in interface MouseMotionListener

mousePressed

public void mousePressed(MouseEvent me)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent me)
Specified by:
mouseReleased in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent me)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent me)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent me)
Specified by:
mouseExited in interface MouseListener