venice
Class ZRelationship

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZSceneGraphObject
        |
        +--edu.umd.cs.jazz.ZNode
              |
              +--edu.umd.cs.jazz.ZLeaf
                    |
                    +--edu.umd.cs.jazz.ZVisualLeaf
                          |
                          +--venice.ZVisualLeafModelElement
                                |
                                +--venice.ZRelationship
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, ListenerStateChangeable, java.io.Serializable, VModelElement, VRelationship, edu.umd.cs.jazz.event.ZNodeListener, edu.umd.cs.jazz.io.ZSerializable
Direct Known Subclasses:
ZDependency, ZGeneralization, ZRealization

public abstract class ZRelationship
extends ZVisualLeafModelElement
implements VRelationship, edu.umd.cs.jazz.event.ZNodeListener, ListenerStateChangeable

ZRelationship is an implementation of VRelationship interface using Jazz graphics library. It can't be instantiated directly but you can instantiate one of its subclasses which are just wrappers for ZRelationship

The arrowhead consist of three lines in the following way:


   |\ 2 
   | \
 1 | /
   |/ 3

 1) mArrowHeadUpDownLine
 2) mArrowHeadUpLeftLine
 3) mArrowHeadDownLeftLine
 

Author:
Hannu Laurila
See Also:
Serialized Form

Field Summary
protected static double HEADLEN
          pixels used to draw the arrowheads.
private  edu.umd.cs.jazz.component.ZLine mArrowHeadDownLeftLine
           
private  edu.umd.cs.jazz.component.ZLine mArrowHeadUpDownLine
           
private  edu.umd.cs.jazz.component.ZLine mArrowHeadUpLeftLine
          visual components used to draw the arrowhead to the line
private  java.util.LinkedList mCompositeRelationshipList
          The list of relationships which are represented by this relationship
private  edu.umd.cs.jazz.ZNode mDst
          destination model element of the relationship
private  boolean mIsRepresentedByOtherRelationship
          Is this relationship represented by some other relationship
private  edu.umd.cs.jazz.component.ZLine mLine
          visual component used to draw the line from src to dest
private  boolean mListenersEnabled
          a not-serialized variable telling that no listeners are enabled. after deserialization, the value of this will always be false.
private  boolean mPreviousUseDashed
          in case of realization, this variable stores last drawing style
private  int mRelationshipType
          type of this relationship.
private  edu.umd.cs.jazz.ZNode mSrc
          source model element of the relationship
private  edu.umd.cs.jazz.component.ZLabel mTypeLabel
          visual component used to draw the label on the line
private static java.awt.BasicStroke stDashedStroke
          a Java2D pen stroke used to draw a dashed line (e.g. dependency)
private static java.awt.BasicStroke stSolidStroke
          a Java2D pen stroke use to draw a solid line
protected static int TYPE_DEPENDENCY
          a constant which tells that this instance is a dependency
protected static int TYPE_GENERALIZATION
          a constant which tells that this instance is a generalization
protected static int TYPE_REALIZATION
          a constant which tells that this instance is a realization
 
Fields inherited from class venice.ZVisualLeafModelElement
mCompositeRelationships, mHiddenOfferedRealizations, mModelElementId, mModelElementName, mModelElementType, mModelElementVisible, mOfferedRealizationSubstitutions, mOriginalRelationships, mRequiredInterfaceSubstitutions, mRequiredRealizations
 
Fields inherited from class edu.umd.cs.jazz.ZVisualLeaf
cacheVolatile, visualComponents
 
Fields inherited from class edu.umd.cs.jazz.ZNode
clientProperties, editorFactory, findable, findable_DEFAULT, hasNodeListener, hasNodeListener_DEFAULT, parent, pickable, pickable_DEFAULT, savable, savable_DEFAULT, selectable, selectable_DEFAULT
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, inClone, listenerList, objRefTable, volatileBounds, volatileBounds_DEFAULT
 
Constructor Summary
ZRelationship(java.lang.String inId, int inRelationshipType, boolean inInitialListenersEnabled)
          constructor used by subclasses to instantiate a ZRelationship with corrent relationship type
 
Method Summary
 void addRelationship(VRelationship inRelationship)
          Relationships cannot have relationships attached to themselves so this method does nothing.
 void addVRelationshipAsSubrelationship(VRelationship inRel)
          Add the given VRelationship as a subrelationship for this VRelationship.
 void boundsChanged(edu.umd.cs.jazz.event.ZNodeEvent e)
           
protected  void dataChanged()
          takes care of adjusting the appearance according to changes in information
 VModelElement getDestination()
          Returns the destination of the relationship
 boolean getIsRepresentedBySomeoneElse()
          Tells whether this relationship is represented by some other relationship or not.
 java.awt.geom.Point2D getRelationshipConnectPoint()
          get the point where relationships should be attached to.
 java.util.LinkedList getRelationships(VPackage inLeaveThisPackage)
          As relationships cannot have relationships attached to themselves, this method will always return null.
 int getRelationshipType()
          Returns the type of this relationship which may be one of the following: relization, generalization or dependency.
 VModelElement getSource()
          Returns the source of the relationship
 java.util.LinkedList getSubrelationships()
          Returns the list of subrelationships if this VRelationship is a composite relationship.
 void globalBoundsChanged(edu.umd.cs.jazz.event.ZNodeEvent e)
           
 java.awt.geom.Point2D intersectWithLine(java.awt.geom.Line2D inLine)
          Intersect this visualization element with a line.
 boolean isCompositeRelationship()
          Tells whether this VRelationship is a composite relationship representing one or more other relationships.
 boolean leavesVPackage(VPackage inPackage)
          Tells whether this relationship leaves the given VPackage.
 void removeSubrelationship(VRelationship inRelationshipToRemove)
          Removes the given relationship from this relationship's list of subrelationships.
 void setDestination(VModelElement inElement)
          Sets the destination end of the relationship Arrow end is targeted towards the destination
 void setIsRepresentedBySomeoneElse(boolean inValue)
          Sets whether this relationship is represented by some other relationship or not.
 void setLabelVisible(boolean inLabelVisible)
          Set whether relationships draw their labels or not.
 void setListenersEnabled(boolean inEnabled, boolean inRecurse)
          sets all listeners of this object uses to be either enabled or disabled.
 void setSource(VModelElement inElement)
          sets the source end of the relationship
 
Methods inherited from class venice.ZVisualLeafModelElement
addToCompositeRelationshipList, addToHiddenOfferedRealizations, addToOfferedRealizationSubstitutions, addToRequiredInterfaceSubstitutions, addToRequiredRealizations, clearHiddenOfferedRealizations, clearOfferedRealizationSubstitutions, clearRequiredInterfaceSubstitutions, clearRequiredRealizations, debugDump, getCompositeRelationships, getHiddenOfferedRealizations, getId, getName, getOfferedRealizationSubstitutions, getRequiredInterfaceSubstitutions, getRequiredRealizations, getType, getVisible, getVParent, setName, setType, setVisible
 
Methods inherited from class edu.umd.cs.jazz.ZVisualLeaf
addVisualComponent, addVisualComponents, clearVisualComponents, computeBounds, duplicateObject, getFirstVisualComponent, getNumVisualComponents, getVisualComponent, getVisualComponentBounds, getVisualComponentGlobalBounds, getVisualComponents, getVolatileBounds, indexOf, pick, removeVisualComponent, render, setState, setVisualComponent, setVisualComponent, trimToSize, updateObjectReferences, updateVolatility, writeObject, writeObject, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.ZNode
, addClientProperty, addNodeListener, dump, editor, extract, findNodes, getClientProperty, getGlobalBounds, getGlobalToLocalTransform, getLocalToGlobalTransform, getParent, getRoot, globalToLocal, globalToLocal, hasNodeListener, isAncestorOf, isDescendentOf, isFindable, isPickable, isSavable, isSelectable, localToGlobal, localToGlobal, lower, lowerTo, percolateEventUpSceneGraph, putClientProperty, raise, raiseTo, remove, removeNodeListener, repaint, repaint, repaint, reparent, replaceWith, setEditorFactory, setFindable, setParent, setPickable, setSavable, setSelectable, updateBounds, writeReplace
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
addMouseListener, addMouseMotionListener, clone, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getListenerList, hasLisenerOfType, hasMouseListener, processMouseEvent, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, setVolatileBounds
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface venice.VModelElement
addToCompositeRelationshipList, debugDump, getCompositeRelationships, getId, getName, getType, getVisible, getVParent, setName, setType, setVisible
 

Field Detail

TYPE_DEPENDENCY

protected static final int TYPE_DEPENDENCY
a constant which tells that this instance is a dependency

TYPE_GENERALIZATION

protected static final int TYPE_GENERALIZATION
a constant which tells that this instance is a generalization

TYPE_REALIZATION

protected static final int TYPE_REALIZATION
a constant which tells that this instance is a realization

HEADLEN

protected static final double HEADLEN
pixels used to draw the arrowheads. Increates to get bigger arrows

mSrc

private edu.umd.cs.jazz.ZNode mSrc
source model element of the relationship

mDst

private edu.umd.cs.jazz.ZNode mDst
destination model element of the relationship

mLine

private edu.umd.cs.jazz.component.ZLine mLine
visual component used to draw the line from src to dest

mArrowHeadUpLeftLine

private edu.umd.cs.jazz.component.ZLine mArrowHeadUpLeftLine
visual components used to draw the arrowhead to the line

mArrowHeadDownLeftLine

private edu.umd.cs.jazz.component.ZLine mArrowHeadDownLeftLine

mArrowHeadUpDownLine

private edu.umd.cs.jazz.component.ZLine mArrowHeadUpDownLine

mTypeLabel

private edu.umd.cs.jazz.component.ZLabel mTypeLabel
visual component used to draw the label on the line

mRelationshipType

private int mRelationshipType
type of this relationship. One of TYPE_ constants

mPreviousUseDashed

private boolean mPreviousUseDashed
in case of realization, this variable stores last drawing style

mCompositeRelationshipList

private java.util.LinkedList mCompositeRelationshipList
The list of relationships which are represented by this relationship

mIsRepresentedByOtherRelationship

private boolean mIsRepresentedByOtherRelationship
Is this relationship represented by some other relationship

stDashedStroke

private static java.awt.BasicStroke stDashedStroke
a Java2D pen stroke used to draw a dashed line (e.g. dependency)

stSolidStroke

private static java.awt.BasicStroke stSolidStroke
a Java2D pen stroke use to draw a solid line

mListenersEnabled

private transient boolean mListenersEnabled
a not-serialized variable telling that no listeners are enabled. after deserialization, the value of this will always be false.
Constructor Detail

ZRelationship

public ZRelationship(java.lang.String inId,
                     int inRelationshipType,
                     boolean inInitialListenersEnabled)
constructor used by subclasses to instantiate a ZRelationship with corrent relationship type
Method Detail

getSource

public VModelElement getSource()
Description copied from interface: VRelationship
Returns the source of the relationship
Specified by:
getSource in interface VRelationship

getDestination

public VModelElement getDestination()
Description copied from interface: VRelationship
Returns the destination of the relationship
Specified by:
getDestination in interface VRelationship

setSource

public void setSource(VModelElement inElement)
Description copied from interface: VRelationship
sets the source end of the relationship
Specified by:
setSource in interface VRelationship

setDestination

public void setDestination(VModelElement inElement)
Description copied from interface: VRelationship
Sets the destination end of the relationship Arrow end is targeted towards the destination
Specified by:
setDestination in interface VRelationship

getRelationshipConnectPoint

public java.awt.geom.Point2D getRelationshipConnectPoint()
Description copied from interface: VModelElement
get the point where relationships should be attached to. Probably element center. This method cannot return null.
Specified by:
getRelationshipConnectPoint in interface VModelElement
Following copied from interface: venice.VModelElement
Returns:
the point for relationships to attach to

setListenersEnabled

public void setListenersEnabled(boolean inEnabled,
                                boolean inRecurse)
Description copied from interface: ListenerStateChangeable
sets all listeners of this object uses to be either enabled or disabled.
Specified by:
setListenersEnabled in interface ListenerStateChangeable
Following copied from interface: venice.ListenerStateChangeable
Parameters:
inEnabled - new state for listeners
inRecurse - whether to recurse to vmodelelement children

dataChanged

protected void dataChanged()
takes care of adjusting the appearance according to changes in information
Overrides:
dataChanged in class ZVisualLeafModelElement

boundsChanged

public void boundsChanged(edu.umd.cs.jazz.event.ZNodeEvent e)
Specified by:
boundsChanged in interface edu.umd.cs.jazz.event.ZNodeListener

globalBoundsChanged

public void globalBoundsChanged(edu.umd.cs.jazz.event.ZNodeEvent e)
Specified by:
globalBoundsChanged in interface edu.umd.cs.jazz.event.ZNodeListener

intersectWithLine

public java.awt.geom.Point2D intersectWithLine(java.awt.geom.Line2D inLine)
Description copied from interface: VModelElement
Intersect this visualization element with a line. If these graphic elements don't intersect, null is returned.
Specified by:
intersectWithLine in interface VModelElement
Following copied from interface: venice.VModelElement
Parameters:
inLine - the line to calculate intersection with
Returns:
the point of intersection or null

getRelationships

public java.util.LinkedList getRelationships(VPackage inLeaveThisPackage)
As relationships cannot have relationships attached to themselves, this method will always return null.
Specified by:
getRelationships in interface VModelElement
Overrides:
getRelationships in class ZVisualLeafModelElement
Returns:
always returns null

addRelationship

public void addRelationship(VRelationship inRelationship)
Relationships cannot have relationships attached to themselves so this method does nothing.
Specified by:
addRelationship in interface VModelElement
Overrides:
addRelationship in class ZVisualLeafModelElement
Following copied from interface: venice.VModelElement
Parameters:
inRelationship - add given relation as an original relationship for this model element.

leavesVPackage

public boolean leavesVPackage(VPackage inPackage)
Description copied from interface: VRelationship
Tells whether this relationship leaves the given VPackage. If inPackage is null, this function returns true.
Specified by:
leavesVPackage in interface VRelationship
Following copied from interface: venice.VRelationship
Parameters:
inPackage - the package to check for leaving, can be null
Returns:
whether this relationship leaves given package

addVRelationshipAsSubrelationship

public void addVRelationshipAsSubrelationship(VRelationship inRel)
Description copied from interface: VRelationship
Add the given VRelationship as a subrelationship for this VRelationship. This function does not check if the given relationships is already in the list. If it is, then that relationship will be twice in the list which is not wanted behaviour. The given relationships is removed from visualization.
Specified by:
addVRelationshipAsSubrelationship in interface VRelationship
Following copied from interface: venice.VRelationship
Parameters:
inRel - the relationship to add as subrelationship

isCompositeRelationship

public boolean isCompositeRelationship()
Description copied from interface: VRelationship
Tells whether this VRelationship is a composite relationship representing one or more other relationships. Composite relationships are used when nodes move their dependencies to their parent packages to minimize screen clutter.
Specified by:
isCompositeRelationship in interface VRelationship
Following copied from interface: venice.VRelationship
Returns:
whether this is a composite relationship

getSubrelationships

public java.util.LinkedList getSubrelationships()
Description copied from interface: VRelationship
Returns the list of subrelationships if this VRelationship is a composite relationship. If this relationship is not a composite relationship, null is returned.
Specified by:
getSubrelationships in interface VRelationship
Following copied from interface: venice.VRelationship
Returns:
the list of subrelationships for this VRelationship

removeSubrelationship

public void removeSubrelationship(VRelationship inRelationshipToRemove)
Description copied from interface: VRelationship
Removes the given relationship from this relationship's list of subrelationships. If the relationships does not exist in this relationships subrelationship list, nothing happens.
Specified by:
removeSubrelationship in interface VRelationship
Following copied from interface: venice.VRelationship
Parameters:
inRelationshipToRemove - the relationship to remove from subrelationships

getRelationshipType

public int getRelationshipType()
Returns the type of this relationship which may be one of the following: relization, generalization or dependency.

This is a partial hack solution, because one might argue that type should be represented as a class hierarchy.

Returns:
the type of this relationship

setIsRepresentedBySomeoneElse

public void setIsRepresentedBySomeoneElse(boolean inValue)
Description copied from interface: VRelationship
Sets whether this relationship is represented by some other relationship or not.
Specified by:
setIsRepresentedBySomeoneElse in interface VRelationship
Following copied from interface: venice.VRelationship
Parameters:
inValue - whether this relationship is represented by some other relationship or not

getIsRepresentedBySomeoneElse

public boolean getIsRepresentedBySomeoneElse()
Description copied from interface: VRelationship
Tells whether this relationship is represented by some other relationship or not.
Specified by:
getIsRepresentedBySomeoneElse in interface VRelationship
Following copied from interface: venice.VRelationship
Returns:
whether this relationship is represented by some other relationship or not

setLabelVisible

public void setLabelVisible(boolean inLabelVisible)
Description copied from interface: VRelationship
Set whether relationships draw their labels or not. Initial mode is to have the label invisible.
Specified by:
setLabelVisible in interface VRelationship
Following copied from interface: venice.VRelationship
Parameters:
inLabelVisible - whether to draw label or not