Petri Net: how to model transition [message #667519] |
Fri, 29 April 2011 10:24 |
chiara Messages: 10 Registered: March 2011 |
Junior Member |
|
|
Hi,
As i did not find anything prepared to model petri net, i tried to visualize it by supposing that transitions are similars to connections between states.
However, in my diagram, only states are represented in Petri net. I don't succeed to visulaize transitions.
Can you help me?
**/ code to represent transitions in Petri Net:
for (State begin : cd.getSources()) {
iteratorEnd=0;
Anchor[] anchor_end = new Anchor[cd.getDestinations().size()];
anchor_start[iteratorStart] = FeatureProvider.unique.pictMap.get(begin.getName());
for (State end : cd.getDestinations()) {
anchor_end[iteratorEnd] = FeatureProvider.unique.pictMap.get(end.getName());
AddConnectionContext contextConn = new AddConnectionContext(anchor_start[iteratorStart], anchor_end[iteratorEnd]);
contextConn.setNewObject(cd);
contextConn.setTargetContainer(containerShape);
I
Transition trans = (Transition) ContextConn.getNewObject();
connection[i] = createConnection();
connection[i].setStart(anchor_start[iteratorStart]);
connection[i].setEnd(anchor_end[iteratorEnd]);
Polyline polyline = gaService.createPolyline(connection[i]);
Color color = manageColor(new ColorConstant(255,255,255));
polyline.setForeground(color);
polyline.setLineWidth(2);
link(connection[i], trans);
ConnectionDecorator cdec = peCreateService.createConnectionDecorator(connection[i], false, 1.0, true);
createArrow(cdec, color);
link(connection[i], trans);
iteratorEnd++;
i++;
}
iteratorStart++;
}
}
//create connection create a Manhattan connection
|
|
|
Re: Petri Net: how to model transition [message #667543 is a reply to message #667519] |
Fri, 29 April 2011 12:42 |
Michael Wenz Messages: 1931 Registered: July 2009 Location: Walldorf, Germany |
Senior Member |
|
|
Without having a closer look at the rest of the coding, I see you are using
ColorConstant(255,255,255) for the line foreground. So you end up with a
white line on a white diagram...
Michael
"chiara" wrote in message news:ipe35t$snm$1@news.eclipse.org...
Hi,
As i did not find anything prepared to model petri net, i tried to visualize
it by supposing that transitions are similars to connections between states.
However, in my diagram, only states are represented in Petri net. I don't
succeed to visulaize transitions.
Can you help me?
**/ code to represent transitions in Petri Net:
for (State begin : cd.getSources()) {
iteratorEnd=0;
Anchor[] anchor_end = new Anchor[cd.getDestinations().size()];
anchor_start[iteratorStart] =
FeatureProvider.unique.pictMap.get(begin.getName());
for (State end : cd.getDestinations()) {
anchor_end[iteratorEnd] = FeatureProvider.unique.pictMap.get(end.getName());
AddConnectionContext contextConn = new
AddConnectionContext(anchor_start[iteratorStart], anchor_end[iteratorEnd]);
contextConn.setNewObject(cd);
contextConn.setTargetContainer(containerShape);
I
Transition trans = (Transition) ContextConn.getNewObject();
connection[i] = createConnection();
connection[i].setStart(anchor_start[iteratorStart]);
connection[i].setEnd(anchor_end[iteratorEnd]);
Polyline polyline = gaService.createPolyline(connection[i]);
Color color = manageColor(new ColorConstant(255,255,255));
polyline.setForeground(color);
polyline.setLineWidth(2);
link(connection[i], trans);
ConnectionDecorator cdec =
peCreateService.createConnectionDecorator(connection[i], false, 1.0, true);
createArrow(cdec, color);
link(connection[i], trans);
iteratorEnd++;
i++;
}
iteratorStart++;
}
}
//create connection create a Manhattan connection
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03234 seconds