venice
Class ZPackage

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZSceneGraphObject
        |
        +--edu.umd.cs.jazz.ZNode
              |
              +--edu.umd.cs.jazz.ZGroup
                    |
                    +--venice.ZPackage
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, ListenerStateChangeable, java.io.Serializable, VModelElement, VPackage, edu.umd.cs.jazz.event.ZNodeListener, edu.umd.cs.jazz.io.ZSerializable

public class ZPackage
extends edu.umd.cs.jazz.ZGroup
implements VPackage, edu.umd.cs.jazz.event.ZNodeListener, ListenerStateChangeable, java.io.Serializable

ZPackage is a concrete implementation of VPackage using Jazz library. ZPackage is implemented as an extension of Jazz's ZGroup which provides useful grouping mechanisms so we do not have to implement them ourselves.

Author:
Hannu Laurila
See Also:
Serialized Form

Field Summary
private  edu.umd.cs.jazz.ZGroup mChildGroup
          the group below ZPackage which is the real place for all children of type VModelElement.
private  java.util.LinkedList mCompositeRelationships
          This packages list of composite relationships.
private  edu.umd.cs.jazz.component.ZRectangle mContentRectangle
          visual component used to draw the rectangle around package contents
private  java.util.LinkedList mHiddenOfferedRealizations
          If package has hidden offered interfaces their realizations are kept in this list.
private  boolean mIsRootPackage
          is this package a root package.
private  edu.umd.cs.jazz.component.ZRectangle mLabelRectangle
          visual component used to draw the rectangle around package label
private  boolean mListenersEnabled
          a not-serialized variable telling that no listeners are enabled. after deserialization, the value of this will always be false.
private  java.lang.String mModelElementId
          model element id
private  java.lang.String mModelElementName
          model element name
private  java.lang.String mModelElementType
          model element type
private  boolean mModelElementVisible
          model element visibility
private  java.util.LinkedList mOfferedRealizationSubstitutions
          If package has hidden offered interfaces their substitute dependencies are kept in this list.
private  java.util.LinkedList mOriginalRelationships
          This packages list of original relationships.
private  edu.umd.cs.jazz.component.ZLabel mPackageLabel
          visual component used to draw the package label
private  java.util.LinkedList mRequiredInterfaceSubstitutions
           
private  java.util.LinkedList mRequiredRealizations
          If package has required interfaces drawn their realizations are kept in this list.
private  boolean mShowContent
          show content (children) of the package
private  int mState
          Package state, OPEN by default.
private static double stAssumedLabelHeight
          Used for estimating label height on initialization
 
Fields inherited from class edu.umd.cs.jazz.ZGroup
cacheVolatile, children, childrenFindable, childrenFindable_DEFAULT, childrenPickable, childrenPickable_DEFAULT, hasOneChild, hasOneChild_DEFAULT
 
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
 
Fields inherited from interface venice.VPackage
CLOSED, OPEN, TRANSPARENT
 
Constructor Summary
ZPackage(java.lang.String inId, boolean inInitialListenersEnabled)
           
 
Method Summary
private  void addChildGroupListener()
           
 void addRelationship(VRelationship inRelationship)
          Add the given VRelationship, where this element is either the source or destination, to this element's list of original relationships.
 VRelationship addToCompositeRelationshipList(VRelationship inRel)
          Add the given relationship to this element's list of composite relationships.
 void addToHiddenOfferedRealizations(VRelationship inRea)
          Add relationship to this list.
 void addToOfferedRealizationSubstitutions(VRelationship inRea)
          Add relationship to this list.
 void addToRequiredInterfaceSubstitutions(VRelationship inRea)
          Add relationship to this list.
 void addToRequiredRealizations(VRelationship inRea)
          Add relationship to this list.
 void addVChild(VModelElement inElem)
          Adds a modelelement to be children of this package.
 void boundsChanged(edu.umd.cs.jazz.event.ZNodeEvent e)
          Notified when childrens bounds change.
 void clearHiddenOfferedRealizations()
          Clear this list.
 void clearOfferedRealizationSubstitutions()
          Clear this list.
 void clearRequiredInterfaceSubstitutions(VRelationship inRea)
          Clear VRelationship inRea from this list.
 void clearRequiredRealizations()
          Clear this list.
protected  void computeBounds()
          computes the bounds of this ZPackage.
protected  void dataChanged()
          modify the package rectangles etc. called when for example child moves so we need to determine new positions for the rectangles
 void debugDump()
          Dump information for this node to stdout.
 java.util.LinkedList getCompositeRelationships()
          Returns the list of all composite relationships this element has.
 java.util.LinkedList getHiddenOfferedRealizations()
          Get content of this list.
 java.lang.String getId()
          returns the id of the element
 java.lang.String getName()
          returns the name of the element
 java.util.LinkedList getOfferedRealizationSubstitutions()
          Get content of this list.
 java.awt.geom.Point2D getRelationshipConnectPoint()
          get the point where relationships should be attached to.
 java.util.LinkedList getRelationships(VPackage inCrossThisPackage)
          Returns a list of relationships which start from this package and span across the border of the given package and are not represented by some other relationship.
 java.util.LinkedList getRequiredInterfaceSubstitutions()
          Get content of this list.
 java.util.LinkedList getRequiredRealizations()
          Get content of this list.
 boolean getShowContent()
          Get current status of package content visibility
 int getState()
          Tells the state of this package.
 java.lang.String getType()
          returns the type of the element
 VModelElement[] getVChildren()
          returns an array consisting of contents of the package
 boolean getVisible()
          returns true if element is shown in the visualization
 VPackage getVParent()
          get parent package for this node.
 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 isRootPackage()
          determine if this package is root package.
 void makeDefaultLayout(boolean inRecurse, int level)
          creates the default layout for the package.
 boolean pick(java.awt.geom.Rectangle2D rect, edu.umd.cs.jazz.util.ZSceneGraphPath path)
           
 void removeAllVChildren(boolean inRecurse)
          clears the package.
private  void removeChildGroupListener()
           
 void removeVChild(VModelElement inElem)
          removes a child from the package
 void render(edu.umd.cs.jazz.util.ZRenderContext ctx)
          renders this package
private  void setFadingEnabled(boolean inState)
          Enables fading of package contents while getting closer.
 void setListenersEnabled(boolean inEnabled, boolean inRecurse)
          sets all listeners of this object uses to be either enabled or disabled.
 void setName(java.lang.String inName)
          sets the name of the element
 void setRootPackage(boolean inIsRootPackage)
          set if this package is the root package.
 void setShowContent(boolean inState)
          sets the status of package content visibility
 void setState(int inState)
          Sets the state of the package.
 void setType(java.lang.String inType)
          sets the type of the element
 void setVisible(boolean inState)
          sets the visibility of the element
 
Methods inherited from class edu.umd.cs.jazz.ZGroup
addChild, addChildImpl, addChildren, addGroupListener, childAddedNotification, childRemovedNotification, dump, duplicateObject, extract, findNodes, getChild, getChildren, getChildrenFindable, getChildrenIterator, getChildrenPickable, getChildrenReference, getNumChildren, getShallowBounds, getVolatileBounds, hasOneChild, indexOf, insertAbove, iterator, lower, lowerTo, raise, raiseTo, removeAllChildren, removeChild, removeChild, removeChild, removeChildImpl, removeGroupListener, removeNodeListener, setChildrenFindable, setChildrenPickable, setHasOneChild, setState, trimToSize, updateHasNodeListener, updateVolatility, writeObject, writeObject, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.ZNode
, addClientProperty, addNodeListener, editor, getClientProperty, getGlobalBounds, getGlobalToLocalTransform, getLocalToGlobalTransform, getParent, getRoot, globalToLocal, globalToLocal, hasNodeListener, isAncestorOf, isDescendentOf, isFindable, isPickable, isSavable, isSelectable, localToGlobal, localToGlobal, lower, lowerTo, percolateEventUpSceneGraph, putClientProperty, raise, raiseTo, remove, repaint, repaint, repaint, reparent, replaceWith, setEditorFactory, setFindable, setParent, setPickable, setSavable, setSelectable, updateBounds, updateObjectReferences, 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
 

Field Detail

stAssumedLabelHeight

private static double stAssumedLabelHeight
Used for estimating label height on initialization

mModelElementId

private java.lang.String mModelElementId
model element id

mModelElementName

private java.lang.String mModelElementName
model element name

mModelElementType

private java.lang.String mModelElementType
model element type

mModelElementVisible

private boolean mModelElementVisible
model element visibility

mShowContent

private boolean mShowContent
show content (children) of the package

mChildGroup

private edu.umd.cs.jazz.ZGroup mChildGroup
the group below ZPackage which is the real place for all children of type VModelElement. Reason for using another group below the package to store the children is that now we can easily implement fading and content hiding by putting different edit groups above just one child which is mChildGroup.

mIsRootPackage

private boolean mIsRootPackage
is this package a root package.

mPackageLabel

private edu.umd.cs.jazz.component.ZLabel mPackageLabel
visual component used to draw the package label

mLabelRectangle

private edu.umd.cs.jazz.component.ZRectangle mLabelRectangle
visual component used to draw the rectangle around package label

mContentRectangle

private edu.umd.cs.jazz.component.ZRectangle mContentRectangle
visual component used to draw the rectangle around package contents

mOriginalRelationships

private java.util.LinkedList mOriginalRelationships
This packages list of original relationships.

mCompositeRelationships

private java.util.LinkedList mCompositeRelationships
This packages list of composite relationships.

mOfferedRealizationSubstitutions

private java.util.LinkedList mOfferedRealizationSubstitutions
If package has hidden offered interfaces their substitute dependencies are kept in this list.

mHiddenOfferedRealizations

private java.util.LinkedList mHiddenOfferedRealizations
If package has hidden offered interfaces their realizations are kept in this list.

mRequiredRealizations

private java.util.LinkedList mRequiredRealizations
If package has required interfaces drawn their realizations are kept in this list.

mRequiredInterfaceSubstitutions

private java.util.LinkedList mRequiredInterfaceSubstitutions

mState

private int mState
Package state, OPEN by default.

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

ZPackage

public ZPackage(java.lang.String inId,
                boolean inInitialListenersEnabled)
Method Detail

setFadingEnabled

private void setFadingEnabled(boolean inState)
Enables fading of package contents while getting closer. Sets up magnification rates which control when fading happens.

addToHiddenOfferedRealizations

public void addToHiddenOfferedRealizations(VRelationship inRea)
Add relationship to this list.

addToOfferedRealizationSubstitutions

public void addToOfferedRealizationSubstitutions(VRelationship inRea)
Add relationship to this list.

addToRequiredInterfaceSubstitutions

public void addToRequiredInterfaceSubstitutions(VRelationship inRea)
Add relationship to this list.

addToRequiredRealizations

public void addToRequiredRealizations(VRelationship inRea)
Add relationship to this list.

clearRequiredRealizations

public void clearRequiredRealizations()
Clear this list.

clearHiddenOfferedRealizations

public void clearHiddenOfferedRealizations()
Clear this list.

clearOfferedRealizationSubstitutions

public void clearOfferedRealizationSubstitutions()
Clear this list.

clearRequiredInterfaceSubstitutions

public void clearRequiredInterfaceSubstitutions(VRelationship inRea)
Clear VRelationship inRea from this list.

getRequiredRealizations

public java.util.LinkedList getRequiredRealizations()
Get content of this list.

getHiddenOfferedRealizations

public java.util.LinkedList getHiddenOfferedRealizations()
Get content of this list.

getOfferedRealizationSubstitutions

public java.util.LinkedList getOfferedRealizationSubstitutions()
Get content of this list.

getRequiredInterfaceSubstitutions

public java.util.LinkedList getRequiredInterfaceSubstitutions()
Get content of this list.

removeChildGroupListener

private void removeChildGroupListener()

addChildGroupListener

private void addChildGroupListener()

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

addVChild

public void addVChild(VModelElement inElem)
Description copied from interface: VPackage
Adds a modelelement to be children of this package. The model element is visualized to be inside the package.
Specified by:
addVChild in interface VPackage

getShowContent

public boolean getShowContent()
Description copied from interface: VPackage
Get current status of package content visibility
Specified by:
getShowContent in interface VPackage
Following copied from interface: venice.VPackage
Returns:
true if contents of the package is shown, false otherwise.

getVChildren

public VModelElement[] getVChildren()
Description copied from interface: VPackage
returns an array consisting of contents of the package
Specified by:
getVChildren in interface VPackage

removeVChild

public void removeVChild(VModelElement inElem)
Description copied from interface: VPackage
removes a child from the package
Specified by:
removeVChild in interface VPackage

getVParent

public VPackage getVParent()
Description copied from interface: VModelElement
get parent package for this node.
Specified by:
getVParent in interface VModelElement

setShowContent

public void setShowContent(boolean inState)
Description copied from interface: VPackage
sets the status of package content visibility
Specified by:
setShowContent in interface VPackage

makeDefaultLayout

public void makeDefaultLayout(boolean inRecurse,
                              int level)
creates the default layout for the package. Layout making is either a recursive or a non-recursive operation. If recursion is used, children ZPackages are laid out before laying out this ZPackage.
Parameters:
inRecurse - if true, recurses to children ZPackages.

computeBounds

protected void computeBounds()
computes the bounds of this ZPackage. It is a union of content rectangle and the label rectangle. In case of root package, we use normal ZGroup bounds calculation
Overrides:
computeBounds in class edu.umd.cs.jazz.ZGroup

render

public void render(edu.umd.cs.jazz.util.ZRenderContext ctx)
renders this package
Overrides:
render in class edu.umd.cs.jazz.ZGroup

pick

public boolean pick(java.awt.geom.Rectangle2D rect,
                    edu.umd.cs.jazz.util.ZSceneGraphPath path)
Overrides:
pick in class edu.umd.cs.jazz.ZGroup

dataChanged

protected void dataChanged()
modify the package rectangles etc. called when for example child moves so we need to determine new positions for the rectangles

boundsChanged

public void boundsChanged(edu.umd.cs.jazz.event.ZNodeEvent e)
Notified when childrens bounds change. Causes dataChanged() to be called.
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

removeAllVChildren

public void removeAllVChildren(boolean inRecurse)
clears the package. Not part of VPackage interface.
Parameters:
inRecurse - if true, clears the children ZPackages too.

setRootPackage

public void setRootPackage(boolean inIsRootPackage)
set if this package is the root package. For root package the label and rectangles are now drawn.
Parameters:
inIsRootPackage - true, if this is root package

isRootPackage

public boolean isRootPackage()
determine if this package is root package.
Returns:
true if root package

getId

public java.lang.String getId()
Description copied from interface: VModelElement
returns the id of the element
Specified by:
getId in interface VModelElement

getName

public java.lang.String getName()
Description copied from interface: VModelElement
returns the name of the element
Specified by:
getName in interface VModelElement

getType

public java.lang.String getType()
Description copied from interface: VModelElement
returns the type of the element
Specified by:
getType in interface VModelElement

getVisible

public boolean getVisible()
Description copied from interface: VModelElement
returns true if element is shown in the visualization
Specified by:
getVisible in interface VModelElement

setName

public void setName(java.lang.String inName)
Description copied from interface: VModelElement
sets the name of the element
Specified by:
setName in interface VModelElement

setType

public void setType(java.lang.String inType)
Description copied from interface: VModelElement
sets the type of the element
Specified by:
setType in interface VModelElement

setVisible

public void setVisible(boolean inState)
Description copied from interface: VModelElement
sets the visibility of the element
Specified by:
setVisible in interface VModelElement

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

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 inCrossThisPackage)
Returns a list of relationships which start from this package and span across the border of the given package and are not represented by some other relationship.
Specified by:
getRelationships in interface VModelElement
Following copied from interface: venice.VModelElement
Parameters:
inLeaveThisPackage - the package that all returned relationships must leave
Returns:
linked list of relationships for this node and its children that cross the given package

addRelationship

public void addRelationship(VRelationship inRelationship)
Description copied from interface: VModelElement
Add the given VRelationship, where this element is either the source or destination, to this element's list of original relationships. Original relationships are those relations that are defined in the GXL model, not created on the fly by the visualization.
Specified by:
addRelationship in interface VModelElement
Following copied from interface: venice.VModelElement
Parameters:
inRelationship - add given relation as an original relationship for this model element.

addToCompositeRelationshipList

public VRelationship addToCompositeRelationshipList(VRelationship inRel)
Description copied from interface: VModelElement
Add the given relationship to this element's list of composite relationships.
Specified by:
addToCompositeRelationshipList in interface VModelElement
Following copied from interface: venice.VModelElement
Parameters:
inRel - The relationship to add to list of composite relationships.
Returns:
the new composite VRelationship in which inRel was added or null if inRel was added in an old composite VRelationship

getCompositeRelationships

public java.util.LinkedList getCompositeRelationships()
Description copied from interface: VModelElement
Returns the list of all composite relationships this element has.
Specified by:
getCompositeRelationships in interface VModelElement
Following copied from interface: venice.VModelElement
Returns:
the list of composite relationships for this element

setState

public void setState(int inState)
Description copied from interface: VPackage
Sets the state of the package. State can be either CLOSED, OPEN or TRANSPARENT.
Specified by:
setState in interface VPackage

getState

public int getState()
Description copied from interface: VPackage
Tells the state of this package.
Specified by:
getState in interface VPackage

debugDump

public void debugDump()
Description copied from interface: VModelElement
Dump information for this node to stdout.
Specified by:
debugDump in interface VModelElement