Graphiti diagram animation [message #1354736] |
Wed, 14 May 2014 07:52  |
Eclipse User |
|
|
|
Hello,
I'm working on the implementation of an animation feature for my graphiti editor.
what i need is the following:
- Click on the animation menu item from the menu
- The editor should change the color of a pictogram element, wait for one second and then change the color of another element until all the elements in a list changes their color.
what i had implemented until now is the following:
- click on the animation menu item
- The command handler responsible for the command is executed.
- The handler will get the list of pictogram elements to be animated
- The handler will call the function animatePictorgamElement() of the ToolbehaviorProvider
- The handler will animate one pictogram element
- clicking the animation menu item another time will animate the second pictogram from the list
So what is happening in this scenario is that it is animating the diagram step by step or element by element. What i needed was to animate the whole elements with one second waiting.
In order to fullfill my requirements i insered a while loop in the execute function of the handler which will run until all elements are animated. The inside the while loop and after calling the animate function of the ToolBehaviorProvider, i added a wait(1000) command.
The result was quite different than expected, the animation done by the tool behavior is applied only after the end of the while loop.
In the Handler:
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
editor = HandlerUtil.getActiveEditor(arg0);
service = editor.getAppService();
List<EObject> contents = editor.getResource().getContents();
List<Element> elements = service.animateDiagram(contents.get(1), contents.get(0));
while(counter<elements.size()){
counter = Service.getCounter();
Service.setCounter(++counter);
if (counter == elements.size())
Service.setCounter(0);
((ToolBehaviorProvider) editor.getDiagramTypeProvider().getFeatureProvider().getDiagramTypeProvider().getAvailableToolBehaviorProviders()[0]).animateElement(elements, counter);
try{
synchronized(this){
this.wait(1000);
}
}
catch(Exception ex){
}
}
return null;
}
In the TOOLBehavior provider, in the animateElement method the code to animate the element is in a recording command.
TransactionalEditingDomain domain = this.getDiagramTypeProvider()
.getDiagramEditor().getEditingDomain();
domain.getCommandStack().execute(new RecordingCommand(domain) {
@Override
protected void doExecute() {
//code here
}
});
So first why it is always waiting the execute method of the handler to finish before any pictogram element's modifications are visible on the diagram?
Second question is there a way to make it work? that is to do the full animation without being obliged to do it step by step or element by element?
Thanks in advance.
HB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05412 seconds