|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.tigris.gef.presentation.Fig
org.tigris.gef.presentation.FigGroup
org.tigris.gef.presentation.FigNode
org.argouml.uml.diagram.ui.FigNodeModelElement
org.argouml.uml.diagram.use_case.ui.FigUseCase
A fig to display use cases on use case diagrams.
Realised as a solid oval containing the name of the use case. Optionally may be split into two compartments, with the lower compartment displaying the extension points for the use case.
Implements all interfaces through its superclasses.
There is some coordinate geometry to be done to fit rectangular text boxes inside an elipse. The rectangular text box contains the name and any extension points if shown, and is deemed to be of height 2h and width 2w. We allow a margin of p above the top and below the bottom of the box, so we know the height of the elipse, 2b = 2h + 2p.
The formula for an elipse of width 2a and height 2b, centred on the origin, is
x^2/a^2 + y^2/b^2 = 1.
We know that a corner of the rectangle is at coordinate (w,h), since the rectangle must also be centred on the origin to fit within the elipse. Subsituting these values for x and y in the formula above, we can compute a, half the width of the elipse, since we know b.
a = wb/sqrt(b^2 - h^2).
But b was defined in terms of the height of the rectangle plus agreed padding at the top, so we can write.
a = (wh + wb)/ sqrt(2hp + p^2)
Given we now know a and b, we can find the coordinates of any partition line required between use case name and extension points.
Finally we need to transform our coordinates, to recognise that the origin is at our top left corner, and the Y coordinates are reversed.
Nested Class Summary | |
class |
FigUseCase.FigMyCircle
FigMyCircle is a FigCircle with corrected connectionPoint method: this methods calculates where a connected edge ends. |
Nested classes inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement |
|
Field Summary | |
private FigUseCase.FigMyCircle |
bigPort
UML use cases do not really have ports, so just define one big one so that users can drag edges to or from any point in the icon. |
private FigUseCase.FigMyCircle |
cover
We don't use _bigPort for the actual graphics of the oval. |
private org.tigris.gef.presentation.FigRect |
epBigPort
The rectangle for the entire extension point box. |
private org.tigris.gef.presentation.FigLine |
epSep
The line separating name and extension points. |
private org.tigris.gef.presentation.FigGroup |
epVec
The vector of graphics for extension points (if any). |
private CompartmentFigText |
highlightedFigText
Text highlighted by mouse actions on the diagram. |
private static Logger |
LOG
|
protected static int |
MIN_VERT_PADDING
The minimum padding allowed above and below the rectangle for the use case name and extension points to the top of the use case oval itself. |
protected static int |
SPACER
Space above and below the line separating name from extension points. |
Fields inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement |
ABSTRACT, ACTIVE, LEAF, POPUP_ADD_OFFSET, ROOT, ROWHEIGHT, SHADOW_COLOR_ALPHA, SHADOW_COLOR_VALUE, STEREOHEIGHT |
Fields inherited from class org.tigris.gef.presentation.FigNode |
_blinkPorts, _highlight, ang135, ang225, ang315, ang45 |
Fields inherited from class org.tigris.gef.presentation.FigGroup |
_dynObjects, _extraFrameSpace |
Fields inherited from class org.tigris.gef.presentation.Fig |
_allowsSaving, _context, _dashes, _dashPeriod, _dashStyle, _displayed, _fillColor, _filled, _group, _h, _layer, _lineColor, _lineWidth, _locked, _resource, _selected, _shown, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, MIN_SIZE |
Constructor Summary | |
FigUseCase()
Constructor for a new use case fig. |
|
FigUseCase(org.tigris.gef.graph.GraphModel gm,
Object node)
A version of the constructor used to associated the Fig with a particular NSUML object. |
Method Summary | |
private Dimension |
calcEllipse(Dimension rectSize,
int vertPadding)
A private utility to calculate the bounding oval for the given rectangular text box. |
private double |
calcX(double a,
double b,
double y)
Private utility routine to work out the (positive) x coordinate of a point on an oval, given the radii and y coordinate. |
Object |
clone()
Make a copy of the current fig. |
protected void |
createFeatureIn(org.tigris.gef.presentation.FigGroup fg,
InputEvent ie)
Create a new "feature" (extension point) in the use case fig. |
Color |
getFillColor()
Get the line colour for the use case oval. |
boolean |
getFilled()
Get whether the use case oval is to be filled. |
List |
getGravityPoints()
Makes sure that the edges stick to the elipse fig of the usecase. |
Color |
getLineColor()
Get the line colour for the use case oval. |
int |
getLineWidth()
Get the line width for the use case oval. |
Dimension |
getMinimumSize()
Compute the minimum acceptable size of the use case. |
private CompartmentFigText |
getNextVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec,
int i)
Private method to find the next visible feature to highlight. |
Vector |
getPopUpActions(MouseEvent me)
Build a collection of menu items relevant for a right-click popup menu on a Use Case. |
private CompartmentFigText |
getPreviousVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec,
int i)
Private method to find the previous visible feature to highlight. |
private Dimension |
getTextSize()
A private utility routine to calculate the minimum size of the rectangle to hold the name and extension points (if displayed). |
boolean |
isExtensionPointVisible()
Returns whether the extension points are currently displayed. |
void |
keyPressed(KeyEvent ke)
Deal with a key being pressed. |
org.tigris.gef.base.Selection |
makeSelection()
Creates a set of handles for dragging generalization/specializations or associations. |
protected void |
modelChanged(PropertyChangeEvent mee)
Adjust the fig in the light of some change to the model. |
void |
mouseClicked(MouseEvent me)
React to a mouse key being clicked. |
void |
mouseExited(MouseEvent me)
Deal with the mouse leaving the fig. |
void |
mousePressed(MouseEvent me)
React to a mouse key being pressed. |
String |
placeString()
The text string to be used as the default name of the new use case fig. |
void |
postLoad()
|
void |
setBounds(int x,
int y,
int w,
int h)
Change the boundary of the use case. |
void |
setExtensionPointVisible(boolean isVisible)
Set the visibility of the extension point compartment. |
void |
setFillColor(Color col)
Set the fill colour for the use case oval. |
void |
setFilled(boolean f)
Set whether the use case oval is to be filled. |
void |
setLineColor(Color col)
Set the line colour for the use case oval. |
void |
setLineWidth(int w)
Set the line width for the use case oval. |
protected void |
textEdited(org.tigris.gef.presentation.FigText ft)
Invoked when text has been edited. |
private CompartmentFigText |
unhighlight()
Private utility to unhighlight any currently selected extension point. |
protected void |
updateExtensionPoint()
Updates the extensionpoints in the fig. |
protected void |
updateNameText()
Updates the text of the name FigText. |
protected void |
updateStereotypeText()
Updates the text of the sterotype FigText. |
Methods inherited from class org.tigris.gef.presentation.FigNode |
addFigEdge, bindPort, cleanUp, contains, deepHitPort, delete, dispose, endTrans, getBlinkPorts, getFigEdges, getFigEdges, getHighlight, getPortFig, getPortFigs, getPortSector, hidePorts, hitPort, hitPort, isBlinkPorts, isDragConnectable, mouseEntered, mouseReleased, removeFigEdge, removePort, setBlinkPorts, setHighlight, showPorts, superTranslate, translate, updateEdges |
Methods inherited from class org.tigris.gef.presentation.FigGroup |
addFigs, deepSelect, elements, getDisplayedFigs, getExtraFrameSpace, getFigAt, getFigs, getFigs, getFont, getFontFamily, getFontSize, getPrivateData, getSize, getSubFigBounds, getTextColor, getTextFillColor, getTextFilled, hitFig, isReshapable, isRotatable, iterator, parseDynObjects, removeAll, removeFig, setExtraFrameSpace, setFigs, setFigs, setFont, setFontFamily, setFontSize, setPrivateData, setTextColor, setTextFillColor, setTextFilled |
Methods inherited from class org.tigris.gef.presentation.Fig |
addAnnotation, addPoint, addPropertyChangeListener, align, center, connectionPoint, contains, contains, countCornersContained, createDrag, drawDashedLine, drawDashedPerimeter, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, getBounds, getBounds, getClosestPoint, getContext, getDashed, getDashed01, getDashedString, getFilled01, getFirstPoint, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLastPoint, getLayer, getLocation, getLocked, getNumPoints, getOwner, getPerimeterLength, getPoint, getPoints, getPreferredSize, getResource, getSingle, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getXs, getY, getYs, hasFillColor, hasLineColor, initAnnotations, insertPoint, intersects, intersectsPerimeter, isAnnotation, isCopieable, isCopyable, isCutable, isDisplayed, isLowerRightResizable, isMovable, isResizable, isSelected, isVisible, OK, pointAlongPerimeter, postSave, preSave, print, redraw, removeAnnotation, removeAnnotation, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setCenter, setContext, setDashed, setDashedString, setDisplayed, setGroup, setHandleBox, setHeight, setLayer, setLocation, setLocation, setLocked, setMovable, setNumPoints, setPoint, setPoint, setPoint, setPoint, setPoints, setPoints, setPoints, setPoints, setPoints, setResizable, setResource, setSavingAllowed, setSelected, setSingle, setSize, setSize, setVisible, setVisState, setWidth, setX, setXs, setY, setYs, stuffBounds, stuffPointAlongPerimeter, translateAnnotations, unsetAnnotationOwner, updateAnnotationPositions, updateVisState, within |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.event.MouseListener |
mouseEntered, mouseReleased |
Methods inherited from interface org.tigris.gef.ui.Highlightable |
addPropertyChangeListener, removePropertyChangeListener |
Field Detail |
private static final Logger LOG
protected static final int MIN_VERT_PADDING
protected static final int SPACER
private FigUseCase.FigMyCircle bigPort
private FigUseCase.FigMyCircle cover
private org.tigris.gef.presentation.FigLine epSep
private org.tigris.gef.presentation.FigGroup epVec
private org.tigris.gef.presentation.FigRect epBigPort
private CompartmentFigText highlightedFigText
Constructor Detail |
public FigUseCase()
At creation the extension point box is not showing (for consistency with existing implementations). We can show it later.
public FigUseCase(org.tigris.gef.graph.GraphModel gm, Object node)
Used at creation time of a UseCase. And also when Add to Diagram is activated. However, the load routines use the main constructor and call setOwner directly.
gm
- The graph model to associate with this Fig. Ignored in this
implementation.node
- The NSUML object to associate with this Fig.Method Detail |
public String placeString()
Note. Good UML would probably prefer a name starting with a capital and no spaces!
placeString
in class FigNodeModelElement
public Object clone()
Uses the generic superclass clone which gives a vector of all the figs. Then initialize our instance variables from this vector.
clone
in class FigNodeModelElement
Object.clone()
public Vector getPopUpActions(MouseEvent me)
Adds to the generic pop up items from the parent.
getPopUpActions
in interface org.tigris.gef.ui.PopupGenerator
getPopUpActions
in class FigNodeModelElement
me
- The mouse event that generated this popup.
PopupGenerator.getPopUpActions(java.awt.event.MouseEvent)
public boolean isExtensionPointVisible()
true
if the attributes are visible,
false
otherwise.public void setExtensionPointVisible(boolean isVisible)
We don't change the size of the use case, so we just have to
mark the extension point elements' visibility.
setBounds(int, int, int, int)
will do the relayout
(with name in the middle) for us.
isVisible
- true
if the compartment should be shown,
false
otherwise.public org.tigris.gef.base.Selection makeSelection()
makeSelection
in class FigNodeModelElement
Fig.makeSelection()
public Dimension getMinimumSize()
We work out the minimum size of the text box, and from that the radii of the enclosing ellipse.
private Dimension getTextSize()
private Dimension calcEllipse(Dimension rectSize, int vertPadding)
To sufficiently constrain the problem, we define that there is a gap
given by the parameter vertPadding
above the top of the
box to the top of the oval.
All computations are done in double, and then converted to integer at the end.
rectSize
- The dimensions of the rectangle to be boundedvertPadding
- The padding between the top of the box and the top
of the ellipse.
public void setBounds(int x, int y, int w, int h)
If we are called with less than the minimum size, we impose the minimum size.
We place the name and extension points at the centre of the rectangle.
Set the bounds of all components of the Fig.
x
- X coordinate of upper left cornery
- Y coordinate of upper left cornerw
- width of bounding boxh
- height of bounding boxprivate double calcX(double a, double b, double y)
a
- radius in X directionb
- radius in Y directiony
- Y coordinate
public void setLineColor(Color col)
This involves setting the _cover oval, not the bigPort.
col
- The colour desired.public Color getLineColor()
This involves getting the _cover oval colour, not the bigPort.
public void setFillColor(Color col)
This involves setting the _cover oval, not the bigPort.
col
- The colour desired.public Color getFillColor()
This involves getting the _cover oval colour, not the bigPort.
public void setFilled(boolean f)
This involves setting the _cover oval, not the bigPort.
f
- true
if the oval is to be filled,
false
if not.public boolean getFilled()
This involves getting the _cover oval, not the bigPort.
true
if the oval is to be filled,
false
if not.public void setLineWidth(int w)
This involves setting the _cover oval, not the bigPort.
w
- The line width desired.public int getLineWidth()
This involves getting the _cover oval colour, not the bigPort.
public void mousePressed(MouseEvent me)
me
- The mouse action that caused us to be invoked.public void mouseClicked(MouseEvent me)
mouseClicked
in interface MouseListener
mouseClicked
in class FigNodeModelElement
me
- The mouse action that caused us to be invoked.MouseListener.mouseClicked(java.awt.event.MouseEvent)
public void mouseExited(MouseEvent me)
me
- The mouse action that caused us to be invoked.public void keyPressed(KeyEvent ke)
We deal with UP and DOWN, and use these to move through the list of selected extension points. We deal with ENTER and use that to start the text editor.
keyPressed
in interface KeyListener
keyPressed
in class FigNodeModelElement
ke
- The key event that caused us to be invoked.KeyListener.keyPressed(java.awt.event.KeyEvent)
protected void textEdited(org.tigris.gef.presentation.FigText ft) throws PropertyVetoException
We check that it is one of the extension point compartments and then parse accordingly.
The parameter ft is the text that has been edited.
textEdited
in class FigNodeModelElement
ft
- the FigText that has been edited and contains the new text
PropertyVetoException
- thrown when new text represents
an unacceptable valueFigNodeModelElement.textEdited(org.tigris.gef.presentation.FigText)
private CompartmentFigText getPreviousVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec, int i)
We're passed in a group (which will be the extension point vector) and the currently highlighted fig (a member of that vector).
fgVec
- A fig group (invariably the extension point vector) in
which to seek the previous visible feature.i
- The index of the currently selected entry in
fgVec
.
private CompartmentFigText getNextVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec, int i)
We're passed in a group (which will be the extension point vector) and the currently highlighted fig (a member of that vector).
fgVec
- A fig group (invariably the extension point vector) in
which to seek the next visible feature.i
- The index of the currently selected entry in
fgVec
.
protected void createFeatureIn(org.tigris.gef.presentation.FigGroup fg, InputEvent ie)
Extension points are not strictly features, but that is a historical accident of naming. This creates a new entry in the extension point vector.
createFeatureIn
in class FigNodeModelElement
fg
- The fig group to which this applies (which must be the
extension point vector).ie
- The input event that triggered us. In the current
implementation a mouse double click.private CompartmentFigText unhighlight()
protected void modelChanged(PropertyChangeEvent mee)
Called both when there has been a change to notation, and when there has been an NSUML event.
modelChanged
in class FigNodeModelElement
mee
- the ModelElementEvent that caused the changeFigNodeModelElement.modelChanged(java.beans.PropertyChangeEvent)
protected void updateExtensionPoint()
protected void updateNameText()
FigNodeModelElement
updateNameText
in class FigNodeModelElement
FigNodeModelElement.updateNameText()
public List getGravityPoints()
Fig.getGravityPoints()
protected void updateStereotypeText()
FigNodeModelElement
updateStereotypeText
in class FigNodeModelElement
FigNodeModelElement.updateStereotypeText()
public void postLoad()
postLoad
in class FigNodeModelElement
Fig.postLoad()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ArgoUML © 1996-2004 (20050222) | ArgoUML Homepage | ArgoUML Developers' page | ArgoUML Cookbook |