org.tigris.gef.base
Class SelectionButtons

java.lang.Object
  extended byorg.tigris.gef.base.Selection
      extended byorg.tigris.gef.base.SelectionResize
          extended byorg.tigris.gef.base.SelectionButtons
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public abstract class SelectionButtons
extends SelectionResize

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.tigris.gef.base.Selection
_content, BORDER_WIDTH, HAND_SIZE
 
Constructor Summary
SelectionButtons(org.tigris.gef.presentation.Fig f)
          Construct a new SelectionWButtons for the given Fig.
 
Method Summary
 void buttonClicked(int buttonCode)
           
protected  java.lang.Object createEdgeAbove(MutableGraphModel gm, java.lang.Object newNode)
          Subclasses should override this method if they want to provide a quickbutton above the _content fig.
protected  java.lang.Object createEdgeLeft(MutableGraphModel gm, java.lang.Object newNode)
          Subclasses should override this method if they want to provide a quickbutton at the left of the _content fig.
protected  java.lang.Object createEdgeRight(MutableGraphModel gm, java.lang.Object newNode)
          Subclasses should override this method if they want to provide a quickbutton at the right of the _content fig.
protected  java.lang.Object createEdgeToSelf(MutableGraphModel gm)
          Subclasses should override this method if they want to provide a quickbutton for selfassociation.
protected  java.lang.Object createEdgeUnder(MutableGraphModel gm, java.lang.Object newNode)
          Subclasses should override this method if they want to provide a quickbutton under the _content fig.
 java.awt.Rectangle getBounds()
          The bounding box of the selection is the bbox of the contained Fig.
protected abstract  java.lang.Object getNewNode(int buttonCode)
          Implementors should return a new node for adding via the buttons.
protected  int getPressedButton()
           
 void hideButtons()
          Dont show buttons while the user is moving the Class.
 boolean hitAbove(int x, int y, int w, int h, java.awt.Rectangle r)
           
 boolean hitBelow(int x, int y, int w, int h, java.awt.Rectangle r)
           
 boolean hitLeft(int x, int y, int w, int h, java.awt.Rectangle r)
           
 boolean hitRight(int x, int y, int w, int h, java.awt.Rectangle r)
           
 boolean intersectsRect(java.awt.Rectangle r, int x, int y, int w, int h)
           
protected  boolean isPaintButtons()
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(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)
          Paint the handles at the four corners and midway along each edge of the bounding box.
 void paintButton(javax.swing.Icon i, java.awt.Graphics g, int x, int y, int hi)
           
 void paintButtonAbove(javax.swing.Icon i, java.awt.Graphics g, int x, int y, int hi)
           
 void paintButtonBelow(javax.swing.Icon i, java.awt.Graphics g, int x, int y, int hi)
           
 void paintButtonLeft(javax.swing.Icon i, java.awt.Graphics g, int x, int y, int hi)
           
 void paintButtonRight(javax.swing.Icon i, java.awt.Graphics g, int x, int y, int hi)
           
abstract  void paintButtons(java.awt.Graphics g)
          Paint the handles at the four corners and midway along each edge of the bounding box.
protected  boolean placeFig(org.tigris.gef.presentation.Fig figToPlace, LayerPerspective layerToPlaceOn, int x, int y, java.awt.Rectangle bumpRect)
          Places a fig on the canvas in the correct position.
protected  void setPaintButtons(boolean paint)
           
protected  void setPressedButton(int pressed)
           
static void toggleShowRapidButtons()
          Toggle ShowRapidButtons.
 
Methods inherited from class org.tigris.gef.base.SelectionResize
dragHandle, hitHandle
 
Methods inherited from class org.tigris.gef.base.Selection
contains, contains, contains, damage, delete, dispose, endTrans, getContent, getContentBounds, getLocation, getLocked, hit, hitHandle, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseMoved, print, reorder, setcontent, stuffBounds, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectionButtons

public SelectionButtons(org.tigris.gef.presentation.Fig f)
Construct a new SelectionWButtons for the given Fig.

Parameters:
f - The given Fig.
Method Detail

toggleShowRapidButtons

public static void toggleShowRapidButtons()
Toggle ShowRapidButtons. Use this to switch off the displaying of the rapid buttons completely. This may be used for a user setting, although the benefit of switching them of is debatable. See also issue 2492.


hitAbove

public boolean hitAbove(int x,
                        int y,
                        int w,
                        int h,
                        java.awt.Rectangle r)
Parameters:
x - x of the selection button icon
y - y of the selection button icon
w - width of the selection button icon
h - height of the selection button icon
r - outer rectangle of the fig
Returns:
true if the selection button above the fig was clicked

hitBelow

public boolean hitBelow(int x,
                        int y,
                        int w,
                        int h,
                        java.awt.Rectangle r)
Parameters:
x - x of the selection button icon
y - y of the selection button icon
w - width of the selection button icon
h - height of the selection button icon
r - outer rectangle of the fig
Returns:
true if the selection button below the fig was clicked

hitLeft

public boolean hitLeft(int x,
                       int y,
                       int w,
                       int h,
                       java.awt.Rectangle r)
Parameters:
x - x of the selection button icon
y - y of the selection button icon
w - width of the selection button icon
h - height of the selection button icon
r - outer rectangle of the fig
Returns:
true if the selection button left from the fig was clicked

hitRight

public boolean hitRight(int x,
                        int y,
                        int w,
                        int h,
                        java.awt.Rectangle r)
Parameters:
x - x of the selection button icon
y - y of the selection button icon
w - width of the selection button icon
h - height of the selection button icon
r - outer rectangle of the fig
Returns:
true if the selection button right from the fig was clicked

intersectsRect

public boolean intersectsRect(java.awt.Rectangle r,
                              int x,
                              int y,
                              int w,
                              int h)
Parameters:
x - x of rectangle 2
y - y of rectangle 2
w - width of rectangle 2
h - height of rectangle 2
r - rectangle 1
Returns:
true if rectangle 1 intersects with the rectangle 2

paint

public void paint(java.awt.Graphics g)
Paint the handles at the four corners and midway along each edge of the bounding box.

Overrides:
paint in class SelectionResize
Parameters:
g - The Graphics where we paint this.

paintButtons

public abstract void paintButtons(java.awt.Graphics g)
Paint the handles at the four corners and midway along each edge of the bounding box.

Parameters:
g - The Graphics where to paint the buttons.

paintButtonAbove

public void paintButtonAbove(javax.swing.Icon i,
                             java.awt.Graphics g,
                             int x,
                             int y,
                             int hi)
Parameters:
i - the icon to be painted
g - the graphics to draw on
x - x for the icon
y - y for the icon
hi - the button identifier

paintButtonBelow

public void paintButtonBelow(javax.swing.Icon i,
                             java.awt.Graphics g,
                             int x,
                             int y,
                             int hi)
Parameters:
i - the icon to be painted
g - the graphics to draw on
x - x for the icon
y - y for the icon
hi - the button identifier

paintButtonLeft

public void paintButtonLeft(javax.swing.Icon i,
                            java.awt.Graphics g,
                            int x,
                            int y,
                            int hi)
Parameters:
i - the icon to be painted
g - the graphics to draw on
x - x for the icon
y - y for the icon
hi - the button identifier

paintButtonRight

public void paintButtonRight(javax.swing.Icon i,
                             java.awt.Graphics g,
                             int x,
                             int y,
                             int hi)
Parameters:
i - the icon to be painted
g - the graphics to draw on
x - x for the icon
y - y for the icon
hi - the button identifier

paintButton

public void paintButton(javax.swing.Icon i,
                        java.awt.Graphics g,
                        int x,
                        int y,
                        int hi)
Parameters:
i - the icon to be painted
g - the graphics to draw on
x - x for the icon
y - y for the icon
hi - the button identifier

getBounds

public java.awt.Rectangle getBounds()
Description copied from class: Selection
The bounding box of the selection is the bbox of the contained Fig.

Overrides:
getBounds in class Selection
See Also:
Selection.getBounds()

hideButtons

public void hideButtons()
Dont show buttons while the user is moving the Class. Called from FigClass when it is translated.


buttonClicked

public void buttonClicked(int buttonCode)
Parameters:
buttonCode - the button identifier

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class Selection
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class Selection
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class Selection
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class Selection
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

placeFig

protected boolean placeFig(org.tigris.gef.presentation.Fig figToPlace,
                           LayerPerspective layerToPlaceOn,
                           int x,
                           int y,
                           java.awt.Rectangle bumpRect)
Places a fig on the canvas in the correct position. Takes a coordinate pair x,y and a rectangle that should be avoided because there can be other figures. If the place action results in x.y coordinates for the fig to place that are not allowed (beyond the borders of the diagram), the operation is repeated with corrected parameters. If it is not possible to add the fig because there are allready to many figs, false is returned and the fig is not added.

Parameters:
figToPlace - The figure one wishes to place on a diagram
layerToPlaceOn - The layer that contains the figs
x - The x coordinate where one wishes to place the fig
y - The y coordinate where one wishes to place the fig
bumpRect - The rectangle that should be avoided since there can be other figs.
Returns:
boolean false if the fig is not placed.

getNewNode

protected abstract java.lang.Object getNewNode(int buttonCode)
Implementors should return a new node for adding via the buttons.

Parameters:
buttonCode - the code (identifier) for the selection button that was hit
Returns:
a newly created UML element

createEdgeAbove

protected java.lang.Object createEdgeAbove(MutableGraphModel gm,
                                           java.lang.Object newNode)
Subclasses should override this method if they want to provide a quickbutton above the _content fig. This method returns the edge (modelelement) that should be drawn in the case such a quickbutton was pressed.

Parameters:
gm - the graphmodel
newNode - The node (modelelement) created by pressing the quickbutton
Returns:
Object The new edge

createEdgeLeft

protected java.lang.Object createEdgeLeft(MutableGraphModel gm,
                                          java.lang.Object newNode)
Subclasses should override this method if they want to provide a quickbutton at the left of the _content fig. This method returns the edge (modelelement) that should be drawn in the case such a quickbutton was pressed.

Parameters:
gm - the graphmodel
newNode - The node (modelelement) created by pressing the quickbutton
Returns:
Object The new edge

createEdgeRight

protected java.lang.Object createEdgeRight(MutableGraphModel gm,
                                           java.lang.Object newNode)
Subclasses should override this method if they want to provide a quickbutton at the right of the _content fig. This method returns the edge (modelelement) that should be drawn in the case such a quickbutton was pressed.

Parameters:
gm - the graphmodel
newNode - The node (modelelement) created by pressing the quickbutton
Returns:
Object The new edge

createEdgeUnder

protected java.lang.Object createEdgeUnder(MutableGraphModel gm,
                                           java.lang.Object newNode)
Subclasses should override this method if they want to provide a quickbutton under the _content fig. This method returns the edge (modelelement) that should be drawn in the case such a quickbutton was pressed.

Parameters:
gm - the graphmodel
newNode - The node (modelelement) created by pressing the quickbutton
Returns:
Object The new edge

createEdgeToSelf

protected java.lang.Object createEdgeToSelf(MutableGraphModel gm)
Subclasses should override this method if they want to provide a quickbutton for selfassociation. This method returns the edge (modelelement) that should be drawn in the case such a quickbutton was pressed.

Parameters:
gm - the graphmodel
Returns:
Object The new edge

setPaintButtons

protected void setPaintButtons(boolean paint)
Parameters:
paint - The _paintButtons to set.

isPaintButtons

protected boolean isPaintButtons()
Returns:
Returns the _paintButtons.

setPressedButton

protected void setPressedButton(int pressed)
Parameters:
pressed - the identifier for the pressed Button

getPressedButton

protected int getPressedButton()
Returns:
Returns the identifier for the pressed Button.