org.processmining.framework.models.petrinet
Class Place

java.lang.Object
  extended by att.grappa.Element
      extended by att.grappa.Node
          extended by org.processmining.framework.models.ModelGraphVertex
              extended by org.processmining.framework.models.petrinet.PNNode
                  extended by org.processmining.framework.models.petrinet.Place
All Implemented Interfaces:
att.grappa.GrappaConstants, java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
ColoredPlace, ReplayedPlace

public class Place
extends PNNode
implements java.lang.Comparable, java.lang.Cloneable

A place is node in a Petri net. It is the passive component in the Petri net structure, and may hold zero to an arbitrary number of tokens. The marking of all the places in the net relates to the state of the Petri net.

Author:
not attributable
See Also:
Token, Transition, PetriNet

Field Summary
 
Fields inherited from class org.processmining.framework.models.ModelGraphVertex
identifier, object2, value, visualObject
 
Fields inherited from class att.grappa.Node
defaultNamePrefix
 
Fields inherited from class att.grappa.Element
counter, highlight, linewidth, object, printAllAttributes, printDefaultAttributes, usePrintList, visible
 
Fields inherited from interface att.grappa.GrappaConstants
_NO_TYPE, ANONYMOUS_PREFIX, BBOX_ATTR, BBOX_HASH, BOX_SHAPE, BOX_TYPE, CLUSTERRANK_ATTR, COLOR_ATTR, COLOR_HASH, COLOR_TYPE, CUSTOM_ATTR, CUSTOM_HASH, CUSTOM_SHAPE, DELETION_MASK, DIAMOND_SHAPE, DIR_ATTR, DIR_HASH, DIR_TYPE, DISTORTION_ATTR, DISTORTION_HASH, DOUBLE_TYPE, DOUBLECIRCLE_SHAPE, DOUBLEOCTAGON_SHAPE, EDGE, EGG_SHAPE, FILLCOLOR_ATTR, FILLCOLOR_HASH, FONTCOLOR_ATTR, FONTCOLOR_HASH, FONTNAME_ATTR, FONTNAME_HASH, FONTSIZE_ATTR, FONTSIZE_HASH, FONTSTYLE_ATTR, FONTSTYLE_HASH, FONTSTYLE_TYPE, GRAPPA_BACKGROUND_COLOR_ATTR, GRAPPA_BACKGROUND_COLOR_HASH, GRAPPA_DELETION_STYLE_ATTR, GRAPPA_DELETION_STYLE_HASH, GRAPPA_FONTSIZE_ADJUSTMENT_ATTR, GRAPPA_FONTSIZE_ADJUSTMENT_HASH, GRAPPA_SELECTION_STYLE_ATTR, GRAPPA_SELECTION_STYLE_HASH, GRAPPA_SHAPE, HASHLIST_TYPE, HEIGHT_ATTR, HEIGHT_HASH, HEXAGON_SHAPE, HIGHLIGHT_MASK, HIGHLIGHT_OFF, HIGHLIGHT_ON, HIGHLIGHT_TOGGLE, HOUSE_SHAPE, IDENTXFRM, IMAGE_ATTR, IMAGE_HASH, INTEGER_TYPE, INVERTEDHOUSE_SHAPE, INVERTEDTRAPEZIUM_SHAPE, INVERTEDTRIANGLE_SHAPE, LABEL_ATTR, LABEL_HASH, LINE_SHAPE, LINE_TYPE, LOG10, LP_ATTR, LP_HASH, MARGIN_ATTR, MARGIN_HASH, MCIRCLE_SHAPE, MCLIMIT_ATTR, MCLIMIT_HASH, MDIAMOND_SHAPE, MINBOX_ATTR, MINBOX_HASH, MINLEN_ATTR, MINLEN_HASH, MINSIZE_ATTR, MINSIZE_HASH, MRECORD_SHAPE, MSQUARE_SHAPE, NBSP, NEW_LINE, NO_SHAPE, NODE, NODESEP_ATTR, NODESEP_HASH, OCTAGON_SHAPE, ORIENTATION_ATTR, ORIENTATION_HASH, OVAL_SHAPE, PACKAGE_PREFIX, PARALLELOGRAM_SHAPE, PATCH_ATTR, PATCH_HASH, PENTAGON_SHAPE, PERIPHERIES_ATTR, PERIPHERIES_HASH, PERIPHERY_GAP, PKG_LOWER, PKG_UPLOW, PKG_UPPER, PLAINTEXT_SHAPE, POINT_TYPE, PointsPerInch, POLYGON_SHAPE, POS_ATTR, POS_HASH, PRINTLIST_ATTR, PRINTLIST_HASH, RANKDIR_ATTR, RANKDIR_HASH, RANKSEP_ATTR, RANKSEP_HASH, RECORD_SHAPE, RECTS_ATTR, RECTS_HASH, ROTATION_ATTR, ROTATION_HASH, ROUNDEDBOX_SHAPE, SELECTION_MASK, SHAPE_ATTR, SHAPE_HASH, SHAPE_MASK, SHAPE_TYPE, SIDES_ATTR, SIDES_HASH, SIZE_ATTR, SIZE_HASH, SIZE_TYPE, SKEW_ATTR, SKEW_HASH, STRING_TYPE, STYLE_ATTR, STYLE_HASH, STYLE_TYPE, SUBGRAPH, SYSTEM, TAG_ATTR, TAG_HASH, TIP_ATTR, TIP_HASH, TRAPEZIUM_SHAPE, TRIANGLE_SHAPE, TRIPLEOCTAGON_SHAPE, TYPES_SHIFT, WEIGHT_ATTR, WEIGHT_HASH, WIDTH_ATTR, WIDTH_HASH
 
Constructor Summary
Place(java.lang.String identifier, PetriNet net)
          Constructor.
 
Method Summary
 Token addToken(Token to)
          Adds the specified token to this place.
 java.lang.Object clone()
          Make a deep copy of the object.
 int compareTo(java.lang.Object object)
           
 boolean equals(java.lang.Object o)
          Overridden to specify when two Petri net places are considered to be equal.
 int getNumber()
          Returns the number which is associated to this place.
 int getNumberOfTokens()
          Gets the number of tokens held by this place.
 int getNumberOfTokens(java.util.Date timestamp)
          Gets the number of tokens that are available at the given timestamp at that place.
 Token getRandomAvailableToken()
          Gets one of the tokens from this place.
 Token getRandomAvailableToken(java.util.Date timestamp)
          Gets one of the tokens from this place that is available at the given timestamp.
 int hashCode()
          Overridden to produce the same hash code for equal objects.
 boolean hasIdentifier(java.lang.String id)
          Determines whether this place has the given identifier associated.
 void removeAllTokens()
          Removes all tokens held by this place.
 Token removeToken()
          Removes one of the tokens held by this place.
 Token removeToken(Token to)
          Removes the specified token from this place.
 void setNumber(int n)
          Assigns a number to this place.
 
Methods inherited from class org.processmining.framework.models.ModelGraphVertex
getIdentifier, getIncidentEdges, getInEdgesIterator, getNeighbors, getOutEdgesIterator, getPredecessors, getSuccessors, getValue, getVerticesOnlyPredecessor, getVerticesOnlySuccessor, getVerticesPredecessorAndSuccessor, setIdentifier, setValue, toString
 
Methods inherited from class att.grappa.Node
addEdge, attributeType, edgeElements, findInEdgeByKey, findOutEdgeByKey, getCenterPoint, getInEdges, getOutEdges, getType, inDegree, inEdgeElements, isNode, outDegree, outEdgeElements, printNode, removeEdge
 
Methods inherited from class att.grappa.Element
addTag, attrNotOfInterest, attrOfInterest, bdfs, buildShape, canonString, canonValue, clearBBox, delete, getAttribute, getAttributePairs, getAttributeValue, getDefaultAttribute, getDefaultAttribute, getGraph, getGrappaNexus, getId, getIdKey, getLocalAttribute, getLocalAttributeKeys, getLocalAttributePairs, getName, getSubgraph, getThisAttribute, getThisAttributeValue, hasAttributeForKey, hasDefaultTag, hasDefaultTags, hasLocalTag, hasLocalTags, hasTag, hasTags, isEdge, isOfInterest, isSubgraph, listAttrsOfInterest, printElement, removeTag, removeTags, setAttribute, setAttribute, setDefaultAttribute, setDefaultAttribute, setDefaultAttribute, setDefaultAttribute, setIdKey, setSubgraph, setUserAttributeType, typeString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Place

public Place(java.lang.String identifier,
             PetriNet net)
Constructor.

Parameters:
identifier - the name of the this place
net - the PetriNet this place belongs to
Method Detail

addToken

public Token addToken(Token to)
Adds the specified token to this place. Note that if the given token is already held by this place, it is not added again.

Parameters:
to - the token that should be added
Returns:
the added token

removeToken

public Token removeToken(Token to)
Removes the specified token from this place.

Parameters:
to - the token that should be removed
Returns:
the token that has been removed if it was found, null otherwise

removeAllTokens

public void removeAllTokens()
Removes all tokens held by this place.


removeToken

public Token removeToken()
Removes one of the tokens held by this place.

Returns:
the token that has been chosen to be removed if there is at least one available, null otherwise

getNumberOfTokens

public int getNumberOfTokens()
Gets the number of tokens held by this place. If a timestamp should be considered, use getNumberOfTokens(Date timestamp) instead.

Returns:
the amount of tokens in this place

getNumberOfTokens

public int getNumberOfTokens(java.util.Date timestamp)
Gets the number of tokens that are available at the given timestamp at that place. If a timestamp is not important, use getNumberOfTokens() instead.

Parameters:
timestamp - the time at which the tokens must be available
Returns:
the amount of tokens available at the given time

getRandomAvailableToken

public Token getRandomAvailableToken(java.util.Date timestamp)
Gets one of the tokens from this place that is available at the given timestamp. If a timestamp is not important, use getRandomAvailableToken() instead.

Parameters:
timestamp - the time at which the token must be available
Returns:
one of the tokens from this place if there is any available, null otherwise

getRandomAvailableToken

public Token getRandomAvailableToken()
Gets one of the tokens from this place. If a timestamp should be considered, use getRandomAvailableToken(Date timestamp) instead.

Returns:
one token from this place if the place is marked, null otherwise

hasIdentifier

public boolean hasIdentifier(java.lang.String id)
Determines whether this place has the given identifier associated.

Parameters:
id - the name to compare with
Returns:
true if this place has the same name as the given string, false otherwise

setNumber

public void setNumber(int n)
Assigns a number to this place.

Since the identifier of a place is not necessarily unique (i.e., two places can have the same name) this method can be used to assign unique numbers to the places of a Petri net, if needed. getNumber() can be used to retrieve the number.

Parameters:
n - the number to be assigned

getNumber

public int getNumber()
Returns the number which is associated to this place.

Since the identifier of a place is not necessarily unique (i.e., two places can have the same name) this method can be used to retrieve unique numbers from the places of a Petri net, if needed. However, they are not associated automatically but must have been set using the setNumber(int i) method before.

Returns:
the number associated

compareTo

public int compareTo(java.lang.Object object)
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
object - Object
Returns:
int

equals

public boolean equals(java.lang.Object o)
Overridden to specify when two Petri net places are considered to be equal.

Overrides:
equals in class ModelGraphVertex
Parameters:
o - the Place to be compared with
Returns:
true if the identifiers are the same, false otherwise.

hashCode

public int hashCode()
Overridden to produce the same hash code for equal objects.

Overrides:
hashCode in class java.lang.Object
Returns:
int The hash code calculated.

clone

public java.lang.Object clone()
Make a deep copy of the object. Note that this method needs to be extended as soon as there are attributes added to the class which are not primitive or immutable.
Note further that the belonging Petri net is not cloned (so the cloned object will point to the same one as this object). Only the PetriNet.clone() method will update the refernce correspondingly.

Overrides:
clone in class att.grappa.Node
Returns:
Object the cloned object