vanted.petrinetelements
Class PetriNet

java.lang.Object
  extended by vanted.petrinetelements.PetriNet

public class PetriNet
extends java.lang.Object

The Class PetriNet for Petri net handling.

Author:
Kevin Pucknat

Field Summary
static java.lang.Integer CAPACITY_MAX_VALUE
          The capacity maximum value.
static TransitionRule TRANSITION_RULE
          The transition rule.
 
Constructor Summary
PetriNet()
          Instantiates a new petri net.
PetriNet(org.graffiti.graph.Graph graph)
          Instantiates a new petri net.
 
Method Summary
 void addHideArcWeight(HideArcWeight hideArcWeight)
          Adds the object HideArcWeight to the HideArcWeightAttribute.
 void addHideCapacity(HideCapacity hideCapacity)
          Adds the object HideCapacity to the HideCapacityAttribute.
 void addHideLabel(HideLabel hideLabel)
          Adds the object HideLabel to the HideLabelAttribute.
 void addHideToken(HideToken hideToken)
          Adds the object HideToken to the HideTokenAttribute.
 void addListener(PetriNetListener listener)
          Adds the listener.
 boolean createPetriNet(org.graffiti.graph.Graph graph, boolean transformPetriNet)
          Creates the Petri net if it is correct.
 java.util.List<Transition> createRandomReversibleTransitions(java.util.List<Transition> transitions)
          Returns one random transition of the pair of reversible transitions.
 java.util.List<AbstractArc> getAllArcs()
          Gets the all arcs.
 java.util.List<Place> getAllPlaces()
          Gets all the places.
 java.util.List<Place> getAllPlacesWithCapacity()
          Gets all the places with capacity.
 java.util.List<Transition> getAllSelectedTransitions(java.util.Collection<org.graffiti.graph.Node> nodes)
          Gets all the selected transitions.
 java.util.List<Transition> getAllTransitions()
          Gets all the transitions.
 double[] getCapacityVector()
           
 boolean[] getEnabledTransitions(TransitionRule rule)
          Gets the enabled transitions.
 boolean[] getEnabledTransitionsFromMarking(double[] marking, TransitionRule rule)
          Gets the enabled transitions from marking.
 org.graffiti.graph.Graph getGraph()
          Gets the graph.
 HideArcWeight getHideArcWeight()
          Gets the object HideArcWeight which contains true (hiding all arc weight), or false.
 HideCapacity getHideCapacity()
          Get the object HideCapacity which contains true (hiding all capacities), or false.
 HideLabel getHideLabel()
          Gets the object HideLabel which contains true (hiding all node label), or false.
 HideToken getHideToken()
          Gets the object HideToken which contains true (hiding all tokens), or false.
 Library getLibrary()
          Gets the library.
 java.util.List<PetriNetListener> getListeners()
          Gets the listeners.
 Marking getMarking()
          Gets the marking.
static double[] getMarking(PetriNet pn)
          Gets the Petri net marking.
 int getPlacePosition(Place place)
          Gets the place position in the Petri net.
 int getTransitionPosition(Transition transition)
          Gets the transition position in the Petri net.
 Library parsePetriNet2Lib()
          Parses the Petri net to the library.
 void removeHideArcWeight()
          Removes the object HideArcWeight which contains true (hiding all arc weights), or false and the HideArcWeightAttribute.
 void removeHideCapacity()
          Removes the object HideCapacity which contains true (hiding all capacities), or false and the HideCapacityAttribute.
 void removeHideLabel()
          Removes the object HideLabel which contains true (hiding all node label), or false and the HideLabelAttribute.
 void removeHideToken()
          Removes the object HideToken which contains true (hiding all tokens), or false and the HideTokenAttribute.
 boolean removeNode(NodePN node)
          Removes this node.
 void run()
          Run infinity.
 void run(int steps)
          Run with ... steps.
 void stop()
          Stop both run methods.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CAPACITY_MAX_VALUE

public static java.lang.Integer CAPACITY_MAX_VALUE
The capacity maximum value.


TRANSITION_RULE

public static TransitionRule TRANSITION_RULE
The transition rule.

Constructor Detail

PetriNet

public PetriNet()
Instantiates a new petri net.


PetriNet

public PetriNet(org.graffiti.graph.Graph graph)
Instantiates a new petri net.

Parameters:
graph - the graph
Method Detail

getGraph

public org.graffiti.graph.Graph getGraph()
Gets the graph.

Returns:
the graph

createPetriNet

public boolean createPetriNet(org.graffiti.graph.Graph graph,
                              boolean transformPetriNet)
Creates the Petri net if it is correct.

Parameters:
graph - the graph
transformPetriNet - the transform petri net
Returns:
true, if successful

getAllPlaces

public java.util.List<Place> getAllPlaces()
Gets all the places.

Returns:
the all places

getAllTransitions

public java.util.List<Transition> getAllTransitions()
Gets all the transitions.

Returns:
the all transitions

getAllArcs

public java.util.List<AbstractArc> getAllArcs()
Gets the all arcs.

Returns:
the all arcs

removeNode

public boolean removeNode(NodePN node)
Removes this node.

Parameters:
node - the node
Returns:
true, if successful

getMarking

public Marking getMarking()
Gets the marking.

Returns:
the marking

getAllPlacesWithCapacity

public java.util.List<Place> getAllPlacesWithCapacity()
Gets all the places with capacity.

Returns:
the all places with capacity

getAllSelectedTransitions

public java.util.List<Transition> getAllSelectedTransitions(java.util.Collection<org.graffiti.graph.Node> nodes)
Gets all the selected transitions.

Parameters:
nodes - the nodes
Returns:
the all selected transitions

createRandomReversibleTransitions

public java.util.List<Transition> createRandomReversibleTransitions(java.util.List<Transition> transitions)
Returns one random transition of the pair of reversible transitions.

Parameters:
transitions - the transitions
revTransitions - in transitions containing reversible transitions
Returns:
all normal transitions and only one of a pair of reversible transitions

run

public void run()
Run infinity.


run

public void run(int steps)
Run with ... steps.

Parameters:
steps - the steps

stop

public void stop()
Stop both run methods.


addListener

public void addListener(PetriNetListener listener)
Adds the listener.

Parameters:
listener - the listener

getListeners

public java.util.List<PetriNetListener> getListeners()
Gets the listeners.

Returns:
the listeners

getEnabledTransitions

public boolean[] getEnabledTransitions(TransitionRule rule)
Gets the enabled transitions.

Parameters:
rule - the rule
Returns:
the enabled transitions

getEnabledTransitionsFromMarking

public boolean[] getEnabledTransitionsFromMarking(double[] marking,
                                                  TransitionRule rule)
Gets the enabled transitions from marking.

Parameters:
marking - the marking
rule - the rule
Returns:
the enabled transitions from marking

getMarking

public static double[] getMarking(PetriNet pn)
Gets the Petri net marking.

Parameters:
pn - the pn
Returns:
the marking

addHideToken

public void addHideToken(HideToken hideToken)
Adds the object HideToken to the HideTokenAttribute.

Parameters:
hideToken - the hide token

removeHideToken

public void removeHideToken()
Removes the object HideToken which contains true (hiding all tokens), or false and the HideTokenAttribute.


getHideToken

public HideToken getHideToken()
Gets the object HideToken which contains true (hiding all tokens), or false.

Returns:
the hide token

addHideCapacity

public void addHideCapacity(HideCapacity hideCapacity)
Adds the object HideCapacity to the HideCapacityAttribute.

Parameters:
hideCapacity - the hide capacity

removeHideCapacity

public void removeHideCapacity()
Removes the object HideCapacity which contains true (hiding all capacities), or false and the HideCapacityAttribute.


getHideCapacity

public HideCapacity getHideCapacity()
Get the object HideCapacity which contains true (hiding all capacities), or false.

Returns:
the hide capacity

addHideArcWeight

public void addHideArcWeight(HideArcWeight hideArcWeight)
Adds the object HideArcWeight to the HideArcWeightAttribute.

Parameters:
hideArcWeight - the hide arc weight

removeHideArcWeight

public void removeHideArcWeight()
Removes the object HideArcWeight which contains true (hiding all arc weights), or false and the HideArcWeightAttribute.


getHideArcWeight

public HideArcWeight getHideArcWeight()
Gets the object HideArcWeight which contains true (hiding all arc weight), or false.

Returns:
the hide arc weight

addHideLabel

public void addHideLabel(HideLabel hideLabel)
Adds the object HideLabel to the HideLabelAttribute.

Parameters:
hideLabel - the hide label

removeHideLabel

public void removeHideLabel()
Removes the object HideLabel which contains true (hiding all node label), or false and the HideLabelAttribute.


getHideLabel

public HideLabel getHideLabel()
Gets the object HideLabel which contains true (hiding all node label), or false.

Returns:
the hide label

getPlacePosition

public int getPlacePosition(Place place)
Gets the place position in the Petri net.

Parameters:
place - the place
Returns:
the place position

getTransitionPosition

public int getTransitionPosition(Transition transition)
Gets the transition position in the Petri net.

Parameters:
transition - the transition
Returns:
the transition position

parsePetriNet2Lib

public Library parsePetriNet2Lib()
Parses the Petri net to the library.

Returns:
the library

getLibrary

public Library getLibrary()
Gets the library.

Returns:
the library

getCapacityVector

public double[] getCapacityVector()