pipe.dataLayer
Class DataLayer

java.lang.Object
  |
  +--java.util.Observable
        |
        +--pipe.dataLayer.DataLayer
All Implemented Interfaces:
Constants

public class DataLayer
extends java.util.Observable
implements Constants

DataLayer - Encapsulates entire Petri-Net, also contains functions to perform calculations

Version:
1.0
Author:
James D Bloom
See Also:

PNML - Petri-Net XMLSchema (stNet.xsd),

DataLayer UML


Field Summary
 
Fields inherited from interface pipe.gui.Constants
ADDTOKEN, ANIMATE, ANNOTATION, ANNOTATION_DEFAULT_FONT, ANNOTATION_DEFAULT_FONT_SIZE, ANNOTATION_LAYER_OFFSET, ANNOTATION_MIN_WIDTH, ANNOTATION_SIZE_OFFSET, ARC, ARC_CONTROL_POINT_CONSTANT, ARC_LAYER_OFFSET, ARC_PATH_PROXIMITY_RADIUS, ARC_PATH_SELECTION_RADIUS, ARC_POINT_LAYER_OFFSET, CREATING, DEFAULT_ELEMENT_TYPE, DELETE, DELTOKEN, DRAW, ELEMENT_FILL_COLOUR, ELEMENT_LINE_COLOUR, ENABLED_TRANSITION_COLOUR, FIRE, GRID, IMMTRANS, LOWEST_LAYER_OFFSET, NOTE_DISABLED_COLOUR, NOTE_EDITING_COLOUR, PLACE, PLACE_TRANSITION_HEIGHT, PLACE_TRANSITION_LAYER_OFFSET, PLACE_TRANSITION_PROXIMITY_RADIUS, PROPERTY_FILE_DESC, PROPERTY_FILE_EXTENSION, RANDOM, RESERVED_BORDER, RESIZE_POINT_DOWN_COLOUR, SELECT, SELECTION_FILL_COLOUR, SELECTION_LAYER_OFFSET, SELECTION_LINE_COLOUR, START, STEPBACKWARD, STEPFORWARD, STOP, TIMEDTRANS
 
Constructor Summary
DataLayer()
          Create empty Petri-Net object
DataLayer(java.io.File pnmlFile)
          Create Petri-Net object from pnmlFile
DataLayer(java.lang.String pnmlFileName)
          Create Petri-Net object from PNML file with URI pnmlFileName
 
Method Summary
 void addAnnotation(AnnotationNote labelInput)
          Add placeInput to the back of the Place ArrayList All observers are notified of this change (Model-View Architecture)
 void addArc(Arc arcInput)
          Add arcInput to back of the Arc ArrayList All observers are notified of this change (Model-View Architecture)
 void addPetriNetObject(PetriNetObject pnObject)
          Add any PetriNetObject - the object will be added to the appropriate list.
 void addPlace(Place placeInput)
          Add placeInput to the back of the Place ArrayList All observers are notified of this change (Model-View Architecture)
 void addToken(Token tokenInput)
          Add tokenInput to the back of the Token ArrayList All observers are notified of this change.
 void addTransition(Transition transitionInput)
          Add transitionInput to back of the Transition ArrayList All observers are notified of this change (Model-View Architecture)
 void emptyPNML()
          Empty all attributes, turn into empty Petri-Net
 Transition fireRandomTransition()
          Fire a random transition, takes rate (probability) of Transitions into account
 void fireRandomTransitionBackwards()
           
 void fireTransition(Transition transition)
          Fire a specified transition, no affect if transtions not enabled
 void fireTransitionBackwards(Transition transition)
           
 Arc getArc(java.lang.String arcName)
          Return the Arc called arcName from the Petri-Net
 Arc[] getArcs()
          Get an List of all the Arcs objects in the Petri-Net
 Arc getArcWithSource(PetriNetObject arcName)
          Return the Arc called arcName from the Petri-Net
 Arc getArcWithTarget(PetriNetObject arcName)
          Return the Arc called arcName from the Petri-Net
 int[][] getBackwardsIncidenceMatrix()
          Return the Backward Incidence Matrix for the Petri-Net
 int[] getCurrentMarkupMatrix()
          Return the Initial Markup Matrix for the Petri-Net
 org.w3c.dom.Document getDOM()
          Return a DOM for the Petri-Net
 org.w3c.dom.Document getDOM(java.io.File pnmlFile)
          Return a DOM for the PNML File pnmlFile
 org.w3c.dom.Document getDOM(java.lang.String pnmlFileName)
          Return a DOM for the PNML file at URI pnmlFileName
 int[][] getForwardsIncidenceMatrix()
          Return the Foward Incidence Matrix for the Petri-Net
 int[][] getIncidenceMatrix()
          Return the Incidence Matrix for the Petri-Net
 int[] getInitialMarkupMatrix()
          Return the Initial Markup Matrix for the Petri-Net
 AnnotationNote[] getLabels()
          Get a List of all the net-level NameLabel objects in the Petri-Net
 int getListPosition(PetriNetObject pnObject)
          Get position of Petri-Net Object in ArrayList of given Petri-Net Object's type
 java.util.Iterator getPetriNetObjects()
          Returns an iterator of all PetriNetObjects - the order of these cannot be guaranteed.
 Place getPlace(int placeNo)
          Return the Place called placeName from the Petri-Net
 Place getPlace(java.lang.String placeName)
          Return the Place called placeName from the Petri-Net
 Place[] getPlaces()
          Get an List of all the Place objects in the Petri-Net
 PlaceTransitionObject getPlaceTransitionObject(java.lang.String ptoId)
          Return the PlaceTransitionObject called ptoName from the Petri-Net
 Transition getTransition(int transitionNo)
          Return the Transition called transitionName from the Petri-Net
 Transition getTransition(java.lang.String transitionName)
          Return the Transition called transitionName from the Petri-Net
 Transition[] getTransitions()
          Get an List of all the Transition objects in the Petri-Net
 java.lang.String getURI()
          Return a URI for the PNML file for the Petri-Net
 void loadPNML(java.lang.String filename)
          Load PNML file
 void print()
          prints out a brief representation of the dataLayer object
 void removeArc(java.lang.String idInput)
          Remove first Arc that has an id equal to idInput
 void removePetriNetObject(PetriNetObject pnObject)
          Removes the specified object from the appropriate ArrayList of objects.
 void removePlace(java.lang.String idInput)
          Remove first Place that has an id equal to idInput
 void removeTransition(java.lang.String idInput)
          Remove first Transition that has an id equal to idInput
 void resetEnabledTransitions()
           
 void restoreInitialMarking()
          Restores Initial Markup Matrix to current Petri-Net Markup
 void restoreState()
          Restores To previous Stored Markup
 java.util.Iterator returnTransitions()
           
 void savePNML(java.io.File file)
          Save the Petri-Net
 void setArcConnectionMap()
          Function populates the arcsMap hashtable enabling easier cross referencing of places, transitions and the arcs connected to them.
 void setBackwardsIncidenceMatrix(int[][] backwardsIncidenceInput)
          Set the Backward Incidence Matrix
 void setEnabledTransitions()
          Determines whether all transitions are enabled and sets the correct value of the enabled boolean
 void setEnabledTransitionsBackwards()
          Determines whether all transitions are enabled and sets the correct value of the enabled boolean
 void setFowardIncidenceMatrix(int[][] fowardIncidenceInput)
          Set the Foward Incidence Matrix
 void setIncidenceMatrix(int[][] incidenceInput)
          Set the Incidence Matrix
 void setInitalMarkupMatrix(int[][] markupInput)
          Set the Initial Markup Matrix
 void storeInitialMarking()
          Stores Initial Markup Matrix from current Petri-Net Markup
 void storeState()
          Stores Current Markup
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataLayer

public DataLayer(java.lang.String pnmlFileName)
Create Petri-Net object from PNML file with URI pnmlFileName

Parameters:
pnmlFileName - Name of PNML File

DataLayer

public DataLayer(java.io.File pnmlFile)
Create Petri-Net object from pnmlFile

Parameters:
pnmlFile - PNML File

DataLayer

public DataLayer()
Create empty Petri-Net object

Method Detail

setArcConnectionMap

public void setArcConnectionMap()
Function populates the arcsMap hashtable enabling easier cross referencing of places, transitions and the arcs connected to them.


removePlace

public void removePlace(java.lang.String idInput)
Remove first Place that has an id equal to idInput

Parameters:
idInput - id of Place object to remove from Petri-Net

removeTransition

public void removeTransition(java.lang.String idInput)
Remove first Transition that has an id equal to idInput

Parameters:
idInput - id of Transition object to remove from Petri-Net

removeArc

public void removeArc(java.lang.String idInput)
Remove first Arc that has an id equal to idInput

Parameters:
idInput - id of Arc object to remove from Petri-Net

addPlace

public void addPlace(Place placeInput)
Add placeInput to the back of the Place ArrayList All observers are notified of this change (Model-View Architecture)

Parameters:
placeInput - Place Object to add

addAnnotation

public void addAnnotation(AnnotationNote labelInput)
Add placeInput to the back of the Place ArrayList All observers are notified of this change (Model-View Architecture)


addTransition

public void addTransition(Transition transitionInput)
Add transitionInput to back of the Transition ArrayList All observers are notified of this change (Model-View Architecture)

Parameters:
transitionInput - Transition Object to add

addArc

public void addArc(Arc arcInput)
Add arcInput to back of the Arc ArrayList All observers are notified of this change (Model-View Architecture)

Parameters:
arcInput - Arc Object to add

addToken

public void addToken(Token tokenInput)
Add tokenInput to the back of the Token ArrayList All observers are notified of this change.

Parameters:
tokenInput - Token Object to add

addPetriNetObject

public void addPetriNetObject(PetriNetObject pnObject)
Add any PetriNetObject - the object will be added to the appropriate list. If the object passed in isn't a Transition, Place or Arc nothing will happen. All observers are notified of this change.

Parameters:
pnObject - The PetriNetObject to be added.

removePetriNetObject

public void removePetriNetObject(PetriNetObject pnObject)
Removes the specified object from the appropriate ArrayList of objects. All observers are notified of this change.

Parameters:
pnObject - The PetriNetObject to be removed.

returnTransitions

public java.util.Iterator returnTransitions()

getPetriNetObjects

public java.util.Iterator getPetriNetObjects()
Returns an iterator of all PetriNetObjects - the order of these cannot be guaranteed.

Returns:
An iterator of all PetriNetObjects

setFowardIncidenceMatrix

public void setFowardIncidenceMatrix(int[][] fowardIncidenceInput)
Set the Foward Incidence Matrix

Parameters:
fowardIncidenceInput - Foward Incidence Matrix object

setBackwardsIncidenceMatrix

public void setBackwardsIncidenceMatrix(int[][] backwardsIncidenceInput)
Set the Backward Incidence Matrix

Parameters:
backwardsIncidenceInput - Backward Incidence Matrix object

setIncidenceMatrix

public void setIncidenceMatrix(int[][] incidenceInput)
Set the Incidence Matrix

Parameters:
incidenceInput - Backward Incidence Matrix object

setInitalMarkupMatrix

public void setInitalMarkupMatrix(int[][] markupInput)
Set the Initial Markup Matrix

Parameters:
markupInput - Initial Markup Matrix object

savePNML

public void savePNML(java.io.File file)
              throws java.lang.NullPointerException,
                     java.io.IOException,
                     javax.xml.parsers.ParserConfigurationException,
                     org.w3c.dom.DOMException,
                     javax.xml.transform.TransformerConfigurationException,
                     javax.xml.transform.TransformerException
Save the Petri-Net

Throws:
javax.xml.parsers.ParserConfigurationException
org.w3c.dom.DOMException
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException
java.lang.NullPointerException
java.io.IOException

loadPNML

public void loadPNML(java.lang.String filename)
              throws java.io.IOException,
                     org.xml.sax.SAXException,
                     javax.xml.transform.TransformerException,
                     javax.xml.parsers.ParserConfigurationException
Load PNML file

Parameters:
filename - URI location of PNML
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException

storeInitialMarking

public void storeInitialMarking()
Stores Initial Markup Matrix from current Petri-Net Markup


restoreInitialMarking

public void restoreInitialMarking()
Restores Initial Markup Matrix to current Petri-Net Markup


storeState

public void storeState()
Stores Current Markup


restoreState

public void restoreState()
Restores To previous Stored Markup


fireTransition

public void fireTransition(Transition transition)
Fire a specified transition, no affect if transtions not enabled

Parameters:
transition - Reference of specifiec Transition

fireRandomTransition

public Transition fireRandomTransition()
Fire a random transition, takes rate (probability) of Transitions into account


fireTransitionBackwards

public void fireTransitionBackwards(Transition transition)

fireRandomTransitionBackwards

public void fireRandomTransitionBackwards()

setEnabledTransitions

public void setEnabledTransitions()
Determines whether all transitions are enabled and sets the correct value of the enabled boolean


resetEnabledTransitions

public void resetEnabledTransitions()

setEnabledTransitionsBackwards

public void setEnabledTransitionsBackwards()
Determines whether all transitions are enabled and sets the correct value of the enabled boolean


emptyPNML

public void emptyPNML()
Empty all attributes, turn into empty Petri-Net


getListPosition

public int getListPosition(PetriNetObject pnObject)
Get position of Petri-Net Object in ArrayList of given Petri-Net Object's type

Parameters:
pnObject - PlaceTransitionObject to get the position of
Returns:
Position (-1 if not present) of Petri-Net Object in ArrayList of given Petri-Net Object's type

getPlaces

public Place[] getPlaces()
Get an List of all the Place objects in the Petri-Net

Returns:
An List of all the Place objects

getLabels

public AnnotationNote[] getLabels()
Get a List of all the net-level NameLabel objects in the Petri-Net

Returns:
A List of all the net-level (as opposed to element-specific) label objects

getTransitions

public Transition[] getTransitions()
Get an List of all the Transition objects in the Petri-Net

Returns:
An List of all the Transition objects

getArcs

public Arc[] getArcs()
Get an List of all the Arcs objects in the Petri-Net

Returns:
An List of all the Arc objects

getTransition

public Transition getTransition(java.lang.String transitionName)
Return the Transition called transitionName from the Petri-Net

Parameters:
transitionName - Name of Transition object to return
Returns:
The first Transition object found with a name equal to transitionName

getTransition

public Transition getTransition(int transitionNo)
Return the Transition called transitionName from the Petri-Net

Parameters:
transitionNo - No of Transition object to return
Returns:
The Transition object

getPlace

public Place getPlace(java.lang.String placeName)
Return the Place called placeName from the Petri-Net

Parameters:
placeName - Name of Place object to return
Returns:
The first Place object found with a name equal to placeName

getPlace

public Place getPlace(int placeNo)
Return the Place called placeName from the Petri-Net

Parameters:
placeNo - No of Place object to return
Returns:
The Place object

getArc

public Arc getArc(java.lang.String arcName)
Return the Arc called arcName from the Petri-Net

Parameters:
arcName - Name of Arc object to return
Returns:
The first Arc object found with a name equal to arcName

getArcWithSource

public Arc getArcWithSource(PetriNetObject arcName)
Return the Arc called arcName from the Petri-Net

Parameters:
arcName - Name of Arc object to return
Returns:
The first Arc object found with a name equal to arcName

getArcWithTarget

public Arc getArcWithTarget(PetriNetObject arcName)
Return the Arc called arcName from the Petri-Net

Parameters:
arcName - Name of Arc object to return
Returns:
The first Arc object found with a name equal to arcName

getPlaceTransitionObject

public PlaceTransitionObject getPlaceTransitionObject(java.lang.String ptoId)
Return the PlaceTransitionObject called ptoName from the Petri-Net

Parameters:
ptoId - Id of PlaceTransitionObject object to return
Returns:
The first Arc PlaceTransitionObject found with a name equal to ptoName

getForwardsIncidenceMatrix

public int[][] getForwardsIncidenceMatrix()
Return the Foward Incidence Matrix for the Petri-Net

Returns:
The Foward Incidence Matrix for the Petri-Net

getBackwardsIncidenceMatrix

public int[][] getBackwardsIncidenceMatrix()
Return the Backward Incidence Matrix for the Petri-Net

Returns:
The Backward Incidence Matrix for the Petri-Net

getIncidenceMatrix

public int[][] getIncidenceMatrix()
Return the Incidence Matrix for the Petri-Net

Returns:
The Incidence Matrix for the Petri-Net

getInitialMarkupMatrix

public int[] getInitialMarkupMatrix()
Return the Initial Markup Matrix for the Petri-Net

Returns:
The Initial Markup Matrix for the Petri-Net

getCurrentMarkupMatrix

public int[] getCurrentMarkupMatrix()
Return the Initial Markup Matrix for the Petri-Net

Returns:
The Initial Markup Matrix for the Petri-Net

getDOM

public org.w3c.dom.Document getDOM(java.lang.String pnmlFileName)
                            throws javax.xml.parsers.ParserConfigurationException,
                                   java.io.IOException,
                                   org.xml.sax.SAXException
Return a DOM for the PNML file at URI pnmlFileName

Parameters:
pnmlFileName - URI of PNML file
Returns:
A DOM for the PNML file pnmlFileName
Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

getDOM

public org.w3c.dom.Document getDOM(java.io.File pnmlFile)
                            throws javax.xml.parsers.ParserConfigurationException,
                                   java.io.IOException,
                                   org.xml.sax.SAXException
Return a DOM for the PNML File pnmlFile

Parameters:
pnmlFile - File Object for PNML of Petri-Net
Returns:
A DOM for the File Object for PNML of Petri-Net
Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

getDOM

public org.w3c.dom.Document getDOM()
                            throws javax.xml.parsers.ParserConfigurationException,
                                   java.io.IOException,
                                   org.xml.sax.SAXException
Return a DOM for the Petri-Net

Returns:
A DOM for the Petri-Net
Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

getURI

public java.lang.String getURI()
Return a URI for the PNML file for the Petri-Net

Returns:
A DOM for the Petri-Net

print

public void print()
prints out a brief representation of the dataLayer object