|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.uppaal.model.core2.Element
com.uppaal.model.core2.Node
com.uppaal.model.core2.Document
public class Document
Model for a network of timed automata as defined in UPPAAL. The document object is the root of a tree containing templates, locations and edges.
This class supports the command pattern: It can execute classes implementing the Command interface. It also supports unlimited undo/redo. When using the command interface, each change will increment a version counter. Notice that the version counter is not incremented if the document tree is modified directly.
UPPAAL timed automata model document can be loaded from a file or Internet by using a PrototypeDocument.load() method:
Document doc = new PrototypeDocument().load(url);
The following code demonstrates how to create a document from scratch with
default properties (colors and so on) without using editor Commands:
PrototypeDocument prototype = new PrototypeDocument();
Document doc = new Document(prototype);
doc.setProperty("declarations", "clock x;"); // shared global clock x
Then a template can be created and manipulated as follows:
Template t = doc.createTemplate(); // new TA template with defaults
doc.insert(t, null).setProperty("name", "Template"); // insert and set the name
t.setProperty("declarations", "clock y;"); // create local clock y
The timed automata elements can be created like-wise:
Location l0 = t.createLocation(); // create a location
t.insert(l0, null).setProperty("name", "L0"); // insert and name it
l0.setProperty("x", 0); // set the graphical position x
l0.setProperty("y", 0); // set the graphical position y
l0.setFlag("urgent", true); // make the location urgent
Location l1 = t.createLocation();
t.insert(l1, l0).setProperty("name", "L1");
l1.setProperty("x", 200);
l1.setProperty("y", 0);
Edge e = t.createEdge(); // create an edge
t.insert(e, l1); // insert it after location l1 (can be null)
e.setSource(l0); // set the origin
e.setTarget(l1); // set the destination
e.setProperty("assignment", "x = 0, y = 0"); // add some assignments
Finally a system declaration should be added:
doc.setProperty("system",
"Process = Template();\n"+
"system Process;");
Then the model can be saved into an XML file:
try {
doc.save("sampledoc.xml");
} catch (IOException e) {
e.printStackTrace(System.err);
}
For further examples, visit Engine
on how to compile and interact with simulator and verifier.
Template,
Location,
Edge,
Element,
Property,
Serialized Form| Field Summary | |
|---|---|
protected LinkedList<CommandListener> |
cmdListeners
Command listeners |
protected LinkedList<Command> |
redoList
Commands on the redo stack. |
protected LinkedList<Command> |
undoList
Commands on the undo stack. |
protected int |
version
The version increases with every command executed. |
| Fields inherited from class com.uppaal.model.core2.Node |
|---|
first, next, previous |
| Fields inherited from class com.uppaal.model.core2.Element |
|---|
listeners, properties, prototype |
| Constructor Summary | |
|---|---|
Document()
Constructor without a prototype. |
|
Document(Element prototype)
Constructor using the given prototype. |
|
| Method Summary | |
|---|---|
void |
accept(Visitor visitor)
Accept a visitor. |
void |
addCommandListener(CommandListener listener)
adds editing command listener |
boolean |
canRedo()
|
boolean |
canUndo()
|
LscTemplate |
createLscTemplate()
Creates a new stand-alone LSC template using a LSC prototype from the document. |
Template |
createTemplate()
Creates a new stand-alone TA template using a template prototype from the document. |
void |
execute(Command... commands)
|
void |
execute(Command command)
Execute a command. |
Document |
getDocument()
Returns the document of this element. |
AbstractTemplate |
getLastTATemplate()
Returns the last TA template or null if no such template exists. |
AbstractTemplate |
getTemplate(String name)
Returns the first template with the given name or null if no such template exists. |
AbstractTemplate |
getTemplates()
Returns the first template of the document. |
int |
getVersion()
Returns the current version number of the document. |
static boolean |
merge(AbstractTemplate source,
AbstractTemplate target)
Merges the source template into target (useful for pasting from clipboard). |
void |
redo()
Redo last undone command. |
void |
removeCommandListener(CommandListener listener)
removes editing command listener |
Element |
resolveXPath(String path)
|
void |
save(File file)
|
void |
save(String filename)
|
void |
undo()
Undo last command. |
| Methods inherited from class com.uppaal.model.core2.Node |
|---|
clone, getFirst, getLast, getNext, getPrevious, insert, move, remove, setPrototype |
| Methods inherited from class com.uppaal.model.core2.Element |
|---|
acceptSafe, addListener, getColor, getLocalProperty, getParent, getProperties, getProperty, getPropertyValue, getPrototype, getPrototypeFromParent, getTemplate, getX, getY, hasFlag, importInto, isPropertyLocal, removeListener, setProperties, setProperty, setPropertyFromPath |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int version
protected LinkedList<Command> undoList
protected LinkedList<Command> redoList
protected LinkedList<CommandListener> cmdListeners
| Constructor Detail |
|---|
public Document()
public Document(Element prototype)
| Method Detail |
|---|
public void execute(Command command)
public void execute(Command... commands)
public void undo()
throws CannotUndoException
CannotUndoExceptionpublic boolean canUndo()
public void redo()
throws CannotRedoException
CannotRedoExceptionpublic boolean canRedo()
public void addCommandListener(CommandListener listener)
public void removeCommandListener(CommandListener listener)
public int getVersion()
public Template createTemplate()
public LscTemplate createLscTemplate()
public AbstractTemplate getTemplates()
public AbstractTemplate getTemplate(String name)
public AbstractTemplate getLastTATemplate()
public void accept(Visitor visitor)
throws Exception
Element
accept in class NodeExceptionpublic Document getDocument()
Element
getDocument in class Elementpublic Element resolveXPath(String path)
public void save(String filename)
throws IOException
IOException
public void save(File file)
throws IOException
IOException
public static boolean merge(AbstractTemplate source,
AbstractTemplate target)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||