org.argouml.uml.diagram.ui
Class SelectionWButtons

java.lang.Object
  extended byorg.tigris.gef.base.Selection
      extended byorg.tigris.gef.base.SelectionResize
          extended byorg.argouml.uml.diagram.ui.SelectionNodeClarifiers
              extended byorg.argouml.uml.diagram.ui.SelectionWButtons
All Implemented Interfaces:
EventListener, KeyListener, MouseListener, MouseMotionListener, Serializable
Direct Known Subclasses:
SelectionActionState, SelectionActor, SelectionClass, SelectionClassifierRole, SelectionComponent, SelectionComponentInstance, SelectionInterface, SelectionNode, SelectionNodeInstance, SelectionObject, SelectionState, SelectionUseCase

public abstract class SelectionWButtons
extends SelectionNodeClarifiers

See Also:
Serialized Form

Field Summary
private static int IMAGE_SIZE
           
private static int MARGIN
           
private static int MAX_PLACINGS
          The maximum number of tries to place a fig.
private static int numButtonClicks
           
private  boolean paintButtons
          True if the buttons on selection are currently shown.
private  int placeCounter
          Counter for counting the number of times there has been a try to place a fig.
private static Color PRESSED_COLOR
           
private  int pressedButton
           
private static boolean showRapidButtons
          The bool showRapidButtons is only false if the user selected to never show the buttons.
 
Fields inherited from class org.tigris.gef.base.SelectionResize
 
Fields inherited from class org.tigris.gef.base.Selection
_content, BORDER_WIDTH, HAND_SIZE
 
Constructor Summary
SelectionWButtons(org.tigris.gef.presentation.Fig f)
          Construct a new SelectionWButtons for the given Fig.
 
Method Summary
 void buttonClicked(int buttonCode)
           
protected  Object createEdgeAbove(org.tigris.gef.graph.MutableGraphModel gm, Object newNode)
          Subclasses should override this method if they want to provide a quickbutton above the _content fig.
protected  Object createEdgeLeft(org.tigris.gef.graph.MutableGraphModel gm, Object newNode)
          Subclasses should override this method if they want to provide a quickbutton at the left of the _content fig.
protected  Object createEdgeRight(org.tigris.gef.graph.MutableGraphModel gm, Object newNode)
          Subclasses should override this method if they want to provide a quickbutton at the right of the _content fig.
protected  Object createEdgeToSelf(org.tigris.gef.graph.MutableGraphModel gm)
          Subclasses should override this method if they want to provide a quickbutton for selfassociation.
protected  Object createEdgeUnder(org.tigris.gef.graph.MutableGraphModel gm, Object newNode)
          Subclasses should override this method if they want to provide a quickbutton under the _content fig.
 Rectangle getBounds()
           
protected abstract  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, Rectangle r)
           
 boolean hitBelow(int x, int y, int w, int h, Rectangle r)
           
 boolean hitLeft(int x, int y, int w, int h, Rectangle r)
           
 boolean hitRight(int x, int y, int w, int h, Rectangle r)
           
 boolean intersectsRect(Rectangle r, int x, int y, int w, int h)
           
protected  boolean isPaintButtons()
           
 void mouseEntered(MouseEvent me)
           
 void mouseExited(MouseEvent me)
           
 void mousePressed(MouseEvent me)
           
 void mouseReleased(MouseEvent me)
           
 void paint(Graphics g)
          Paint the handles at the four corners and midway along each edge of the bounding box.
 void paintButton(Icon i, Graphics g, int x, int y, int hi)
           
 void paintButtonAbove(Icon i, Graphics g, int x, int y, int hi)
           
 void paintButtonBelow(Icon i, Graphics g, int x, int y, int hi)
           
 void paintButtonLeft(Icon i, Graphics g, int x, int y, int hi)
           
 void paintButtonRight(Icon i, Graphics g, int x, int y, int hi)
           
abstract  void paintButtons(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, org.tigris.gef.base.LayerPerspective layerToPlaceOn, int x, int y, 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
 

Field Detail

IMAGE_SIZE

private static final int IMAGE_SIZE
See Also:
Constant Field Values

MARGIN

private static final int MARGIN
See Also:
Constant Field Values

PRESSED_COLOR

private static final Color PRESSED_COLOR

MAX_PLACINGS

private static final int MAX_PLACINGS
The maximum number of tries to place a fig.

See Also:
Constant Field Values

numButtonClicks

private static int numButtonClicks

showRapidButtons

private static boolean showRapidButtons
The bool showRapidButtons is only false if the user selected to never show the buttons. The user can not do this currently.


paintButtons

private boolean paintButtons
True if the buttons on selection are currently shown.


pressedButton

private int pressedButton

placeCounter

private int placeCounter
Counter for counting the number of times there has been a try to place a fig.

Constructor Detail

SelectionWButtons

public SelectionWButtons(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,
                        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,
                        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,
                       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,
                        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(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(Graphics g)
Paint the handles at the four corners and midway along each edge of the bounding box.

Overrides:
paint in class SelectionNodeClarifiers
Parameters:
g - The Graphics where we paint this.
See Also:
Selection.paint(java.awt.Graphics)

paintButtons

public abstract void paintButtons(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(Icon i,
                             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(Icon i,
                             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(Icon i,
                            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(Icon i,
                             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(Icon i,
                        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 Rectangle getBounds()
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(MouseEvent me)
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(MouseEvent me)
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(MouseEvent me)
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(MouseEvent me)
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

placeFig

protected boolean placeFig(org.tigris.gef.presentation.Fig figToPlace,
                           org.tigris.gef.base.LayerPerspective layerToPlaceOn,
                           int x,
                           int y,
                           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 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 Object createEdgeAbove(org.tigris.gef.graph.MutableGraphModel gm,
                                 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 Object createEdgeLeft(org.tigris.gef.graph.MutableGraphModel gm,
                                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 Object createEdgeRight(org.tigris.gef.graph.MutableGraphModel gm,
                                 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 Object createEdgeUnder(org.tigris.gef.graph.MutableGraphModel gm,
                                 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 Object createEdgeToSelf(org.tigris.gef.graph.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.


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook