|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--pipe.dataLayer.DataLayer
DataLayer - Encapsulates entire Petri-Net, also contains functions to perform calculations
Inner Class Summary | |
class |
DataLayer.Matrix
dataLayer - Encapsulates entire Matrix, also contains functions to perform some manipulation TODO: Combined with IntMatrix |
Field Summary | |
private java.util.ArrayList |
arcsArray
ArrayList containing all the Arc objects in the Petri-Net |
private java.util.Hashtable |
arcsMap
Hashtable which maps PlaceTransitionObjects to their list of connected arcs |
private java.util.ArrayList |
arrowsArray
ArrayList containing all the Arrow objects in the Petri-Net |
private DataLayer.Matrix |
backwardsIncidenceMatrix
Backward Incidence Matrix |
private java.util.ArrayList |
changeArrayList
An ArrayList used to point to either the Arc, Place or Transition ArrayLists when these ArrayLists are being update |
private int[] |
currentMarkupMatrix
Initial Markup Matrix |
private int |
DISPLAY_SCALE_FACTORX
X-Axis Scale Value |
private int |
DISPLAY_SCALE_FACTORY
Y-Axis Scale Value |
private int |
DISPLAY_SHIFT_FACTORX
X-Axis Shift Value |
private int |
DISPLAY_SHIFT_FACTORY
Y-Axis Shift Value |
private DataLayer.Matrix |
fowardsIncidenceMatrix
Foward Incidence Matrix |
private DataLayer.Matrix |
incidenceMatrix
Incidence Matrix |
private int[] |
initialMarkupMatrix
Initial Markup Matrix |
private DataLayer.Matrix |
markupHistoryMatrix
Markup Storage Array |
private int[] |
markupMatrixAnimationStorage
Markup Matrix Storage used during animation |
private java.lang.Object[] |
markupStore
Markup Matrix Storage |
private java.util.ArrayList |
placesArray
List containing all the Place objects in the Petri-Net |
private java.lang.String |
pnmlName
PNML File Name |
private int |
position
Markup Matrix Storage Position |
private static java.util.Random |
randomNumber
|
private java.util.ArrayList |
tokensArray
ArrayList containing all the Token objects in the Petri-Net |
private java.util.ArrayList |
transitionsArray
ArrayList containing all the Transition objects ing2D.setStroke(new BasicStroke(1.5f)); the Petri-Net |
Fields inherited from class java.util.Observable |
changed, obs |
Fields inherited from interface pipe.gui.Constants |
ADDTOKEN, ARC, DEFAULT_BACKGROUND_COLOR, DEFAULT_DIRECTORY, DEFAULT_ELEMENT_COLOR, DEFAULT_ELEMENT_TYPE, DEFAULT_FILENAME, DELETE, DELTOKEN, DRAW, FIRE, MOVE, PLACE, RANDOM, START, STEPBACKWARD, STEPFORWARD, STOP, TRANSITION |
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 |
addArc(Arc arcInput)
Add arcInput to back of the Arc ArrayList All observers are notified of this change (Model-View Architecture) |
private void |
addArcToArcsMap(Arc arcInput)
Update the arcsMap hashtable to reflect the new arc |
void |
addArrow(ArrowLabel arrowInput)
|
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) |
private Arc |
createArc(org.w3c.dom.Element inputArcElement)
Creates a Arc object from a Arc DOM Element |
private org.w3c.dom.Element |
createArcElement(Arc inputArc,
org.w3c.dom.Document document)
Creates a Arc Element for a PNML Petri-Net DOM |
private void |
createBackwardsIncidenceMatrix()
Creates Backwards Incidence Matrix from current Petri-Net |
private void |
createCurrentMarkupMatrix()
Creates Initial Markup Matrix from current Petri-Net |
private void |
createFowardIncidenceMatrix()
Creates Foward Incidence Matrix from current Petri-Net |
private void |
createIncidenceMatrix()
Creates Incidence Matrix from current Petri-Net |
private void |
createInitialMarkupMatrix()
Creates Initial Markup Matrix from current Petri-Net |
private void |
createMatrixes()
Creates all Petri-Net Matrixes from current Petri-Net |
private Place |
createPlace(org.w3c.dom.Element inputPlaceElement)
Creates a Place object from a Place DOM Element |
private org.w3c.dom.Element |
createPlaceElement(Place inputPlace,
org.w3c.dom.Document document)
Creates a Place Element for a PNML Petri-Net DOM |
private Transition |
createTransition(org.w3c.dom.Element inputTransitionElement)
Creates a Transition object from a Transition DOM Element |
private org.w3c.dom.Element |
createTransitionElement(Transition inputTransition,
org.w3c.dom.Document document)
Creates a Transition Element for a PNML Petri-Net DOM |
void |
emptyPNML()
Empty all attributes, turn into empty Petri-Net |
void |
fireRandomTransition()
Fire a random transition, takes rate (probability) of Transitions into account |
void |
fireRandomTransitionBackwards()
|
private void |
fireTransition(int transitionNo)
Fire a specified transition, no affect if transtions not enabled |
void |
fireTransition(Transition transition)
Fire a specified transition, no affect if transtions not enabled |
private void |
fireTransitionBackwards(int transitionNo)
|
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[][] |
getFowardsIncidenceMatrix()
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 |
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 |
private void |
initializeMatrixes()
Initialize Arrays |
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.lang.String filename)
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 |
private boolean |
setPetriNetObjectArrayList(PetriNetObject pnObject)
Sets an internal ArrayList according to the class of the object passed in. |
void |
storeInitialMarking()
Stores Initial Markup Matrix from current Petri-Net Markup |
void |
storeState()
Stores Current Markup |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static java.util.Random randomNumber
private java.lang.String pnmlName
private java.util.ArrayList placesArray
private java.util.ArrayList transitionsArray
private java.util.ArrayList arcsArray
private java.util.ArrayList tokensArray
private java.util.ArrayList arrowsArray
private java.util.ArrayList changeArrayList
private int[] initialMarkupMatrix
private int[] currentMarkupMatrix
private int[] markupMatrixAnimationStorage
private java.lang.Object[] markupStore
private int position
private DataLayer.Matrix markupHistoryMatrix
private DataLayer.Matrix fowardsIncidenceMatrix
private DataLayer.Matrix backwardsIncidenceMatrix
private DataLayer.Matrix incidenceMatrix
private final int DISPLAY_SCALE_FACTORX
private final int DISPLAY_SCALE_FACTORY
private final int DISPLAY_SHIFT_FACTORX
private final int DISPLAY_SHIFT_FACTORY
private java.util.Hashtable arcsMap
Constructor Detail |
public DataLayer(java.lang.String pnmlFileName) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException
pnmlFileName
- Name of PNML Filejava.io.IOException
- SAXException
- TransformerException
- ParserConfigurationException
- public DataLayer(java.io.File pnmlFile) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException
pnmlFile
- PNML Filejava.io.IOException
- SAXException
- TransformerException
- ParserConfigurationException
- public DataLayer()
Method Detail |
private void initializeMatrixes()
public void setArcConnectionMap()
public void removePlace(java.lang.String idInput)
idInput
- id of Place object to remove from Petri-Netpublic void removeTransition(java.lang.String idInput)
idInput
- id of Transition object to remove from Petri-Netpublic void removeArc(java.lang.String idInput)
idInput
- id of Arc object to remove from Petri-Netpublic void addPlace(Place placeInput)
placeInput
- Place Object to addpublic void addTransition(Transition transitionInput)
transitionInput
- Transition Object to addpublic void addArc(Arc arcInput)
arcInput
- Arc Object to addprivate void addArcToArcsMap(Arc arcInput)
arcInput
- New Arcpublic void addToken(Token tokenInput)
tokenInput
- Token Object to addpublic void addArrow(ArrowLabel arrowInput)
public void addPetriNetObject(PetriNetObject pnObject)
pnObject
- The PetriNetObject to be added.public void removePetriNetObject(PetriNetObject pnObject)
pnObject
- The PetriNetObject to be removed.public java.util.Iterator returnTransitions()
private boolean setPetriNetObjectArrayList(PetriNetObject pnObject)
pnObject
- The pnObject in question.public java.util.Iterator getPetriNetObjects()
public void setFowardIncidenceMatrix(int[][] fowardIncidenceInput)
fowardIncidenceInput
- Foward Incidence Matrix objectpublic void setBackwardsIncidenceMatrix(int[][] backwardsIncidenceInput)
backwardsIncidenceInput
- Backward Incidence Matrix objectpublic void setIncidenceMatrix(int[][] incidenceInput)
incidenceInput
- Backward Incidence Matrix objectpublic void setInitalMarkupMatrix(int[][] markupInput)
markupInput
- Initial Markup Matrix objectpublic void savePNML(java.lang.String filename) throws javax.xml.parsers.ParserConfigurationException, org.w3c.dom.DOMException, javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException
filename
- URI location to save fileParserConfigurationException
- DOMException
- TransformerConfigurationException
- TransformerException
- public void loadPNML(java.lang.String filename) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException
filename
- URI location of PNMLjava.io.IOException
- SAXException
- TransformerException
- ParserConfigurationException
- private Place createPlace(org.w3c.dom.Element inputPlaceElement)
inputPlaceElement
- Input Place DOM Elementprivate Transition createTransition(org.w3c.dom.Element inputTransitionElement)
inputTransitionElement
- Input Transition DOM Elementprivate Arc createArc(org.w3c.dom.Element inputArcElement)
inputArcElement
- Input Arc DOM Elementprivate org.w3c.dom.Element createPlaceElement(Place inputPlace, org.w3c.dom.Document document)
inputPlace
- Input Placedocument
- Any DOM to enable creation of Elements and Attributesprivate org.w3c.dom.Element createTransitionElement(Transition inputTransition, org.w3c.dom.Document document)
inputTransition
- Input Transitiondocument
- Any DOM to enable creation of Elements and Attributesprivate org.w3c.dom.Element createArcElement(Arc inputArc, org.w3c.dom.Document document)
inputArc
- Input Arcdocument
- Any DOM to enable creation of Elements and Attributesprivate void createMatrixes()
private void createFowardIncidenceMatrix()
private void createBackwardsIncidenceMatrix()
private void createIncidenceMatrix()
private void createInitialMarkupMatrix()
private void createCurrentMarkupMatrix()
public void storeInitialMarking()
public void restoreInitialMarking()
public void storeState()
public void restoreState()
public void fireTransition(Transition transition)
transition
- Reference of specifiec Transitionprivate void fireTransition(int transitionNo)
transitionNo
- Position of Transition in internal ArrayListpublic void fireRandomTransition()
public void fireTransitionBackwards(Transition transition)
private void fireTransitionBackwards(int transitionNo)
public void fireRandomTransitionBackwards()
public void setEnabledTransitions()
public void resetEnabledTransitions()
public void setEnabledTransitionsBackwards()
public void emptyPNML()
public int getListPosition(PetriNetObject pnObject)
pnObject
- PlaceTransitionObject to get the position ofpublic Place[] getPlaces()
public Transition[] getTransitions()
public Arc[] getArcs()
public Transition getTransition(java.lang.String transitionName)
transitionName
- Name of Transition object to returnpublic Transition getTransition(int transitionNo)
transitionNo
- No of Transition object to returnpublic Place getPlace(java.lang.String placeName)
placeName
- Name of Place object to returnpublic Place getPlace(int placeNo)
placeNo
- No of Place object to returnpublic Arc getArc(java.lang.String arcName)
arcName
- Name of Arc object to returnpublic Arc getArcWithSource(PetriNetObject arcName)
arcName
- Name of Arc object to returnpublic Arc getArcWithTarget(PetriNetObject arcName)
arcName
- Name of Arc object to returnpublic PlaceTransitionObject getPlaceTransitionObject(java.lang.String ptoId)
ptoId
- Id of PlaceTransitionObject object to returnpublic int[][] getFowardsIncidenceMatrix()
public int[][] getBackwardsIncidenceMatrix()
public int[][] getIncidenceMatrix()
public int[] getInitialMarkupMatrix()
public int[] getCurrentMarkupMatrix()
public org.w3c.dom.Document getDOM(java.lang.String pnmlFileName) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
pnmlFileName
- URI of PNML fileParserConfigurationException
- java.io.IOException
- SAXException
- public org.w3c.dom.Document getDOM(java.io.File pnmlFile) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
pnmlFile
- File Object for PNML of Petri-NetParserConfigurationException
- java.io.IOException
- SAXException
- public org.w3c.dom.Document getDOM() throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
ParserConfigurationException
- java.io.IOException
- SAXException
- public java.lang.String getURI()
public void print()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |