Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Animation on editparts
Animation on editparts [message #225325] Thu, 09 April 2009 19:05 Go to next message
BG is currently offline BGFriend
Messages: 45
Registered: July 2009
Member
Hi,
I have requirement to show animation on editparts. i,e i have set of
connections which has a source and traget node.
On a event i need to highlight the single node at a time till it reaches
its target point node

eq

A C1 B C2 D
where C1 and C2 are connections and A,B and D are the nodes

with the below implementationn it is all the nodes are get highlighted
together but what i need is first highlight the A,then some time interval
B and then C

private void blinkingFeature(Set<ConnectionEditPart> tracedConnEditParts)
{
for (ConnectionEditPart connectionEditPart : tracedConnEditParts)
{
final GraphicalEditPart targetEditPart =
(GraphicalEditPart)connectionEditPart.getTarget();
final GraphicalEditPart sourcEditPart =
(GraphicalEditPart)connectionEditPart.getSource();

Thread thread1 = new Thread(new AnimatePort(targetEditPart));
thread1.start();
Thread thread2 = new Thread(new AnimatePort(sourcEditPart));
thread2.start();
}
}



private class AnimatePort implements Runnable
{
GraphicalEditPart graphicalEditPart;
public AnimatePort(final GraphicalEditPart graphicalEditPart)
{
this.graphicalEditPart = graphicalEditPart;
}
public void run() {
for(int i = 1; i < 20;i++)
{
if(i % 2 == 0)
{
Display.getDefault().syncExec( new Runnable(){

@Override
public void run() {

setColorBorder(graphicalEditPart, ColorConstants.red);
}

});
}else
{
Display.getDefault().syncExec( new Runnable(){

@Override
public void run() {
setColorBorder(graphicalEditPart, ColorConstants.black);

}

});
}
try {
Thread.sleep(300);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}


I tried the thread join but it us blocking my UI update process. Any idea
how achive this ?

Regards
Byre
Re: Animation on editparts [message #225418 is a reply to message #225325] Fri, 10 April 2009 07:59 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Byre,

try moving following code into the end of


> Hi,
> I have requirement to show animation on editparts. i,e i have set of
> connections which has a source and traget node.
> On a event i need to highlight the single node at a time till it
> reaches
> its target point node
> eq
>
> A C1 B C2 D
> where C1 and C2 are connections and A,B and D are the nodes
> with the below implementationn it is all the nodes are get highlighted
> together but what i need is first highlight the A,then some time
> interval B and then C
>
> private void blinkingFeature(Set<ConnectionEditPart>
> tracedConnEditParts)
> {
> for (ConnectionEditPart connectionEditPart : tracedConnEditParts)
> {
> final GraphicalEditPart targetEditPart =
> (GraphicalEditPart)connectionEditPart.getTarget();
> final GraphicalEditPart sourcEditPart =
> (GraphicalEditPart)connectionEditPart.getSource();
> Thread thread1 = new Thread(new AnimatePort(targetEditPart));
> thread1.start();
> }
> }
> private class AnimatePort implements Runnable
> {
> GraphicalEditPart graphicalEditPart;
> public AnimatePort(final GraphicalEditPart graphicalEditPart)
> {
> this.graphicalEditPart = graphicalEditPart;
> }
> public void run() {
> for(int i = 1; i < 20;i++)
> {
> if(i % 2 == 0)
> {
> Display.getDefault().syncExec( new Runnable(){
> @Override
> public void run() {
> setColorBorder(graphicalEditPart, ColorConstants.red);
> }
> });
> }else
> {
> Display.getDefault().syncExec( new Runnable(){
> @Override
> public void run() {
> setColorBorder(graphicalEditPart, ColorConstants.black);
> }
>
> });
> }
> try {
> Thread.sleep(300);
> } catch (InterruptedException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
> }
> }
> I tried the thread join but it us blocking my UI update process. Any
> idea how achive this ?
>
> Regards
> Byre
-----------------
Alex Shatalin
Re: Animation on editparts [message #225427 is a reply to message #225325] Fri, 10 April 2009 08:02 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Byre,

(sorry for the prev. message - some problems with news reader i use.)

try moving following code into the end of first runnable (AnimatePort(sourcEditPart)):

Thread thread2 = new Thread(new AnimatePort(sourcEditPart));
thread2.start();

Or just create AnimatePort(sourcEditPart, targetEditPart, .....)
performing animation for 1, 2, .. eidt parts.

-----------------
Alex Shatalin
Re: Animation on editparts [message #225716 is a reply to message #225427] Mon, 13 April 2009 19:11 Go to previous message
BG is currently offline BGFriend
Messages: 45
Registered: July 2009
Member
Hi Alex,
Thanks,I tried your second suggestion.It is working fine.
Pls find modified code
for (final BorderedBorderItemEditPart borderedPort : bdList) {

for(int i = 1; i < 6;i++)
{
if(i % 2 == 0)
{
Display.getDefault().asyncExec( new Runnable(){

@Override
public void run() {

setColorBorder(borderedPort, ColorConstants.red);
}

});
}else
{
Display.getDefault().asyncExec( new Runnable(){

@Override
public void run() {

setColorBorder(borderedPort, ColorConstants.black);
}
});
}
borderedPort.refresh();
try {
Thread.sleep(300);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Additionally i had to call the refresh on editpart to reflect the change
in UI

Regards
Byre
Previous Topic:How to select a shape programmatically?
Next Topic:Missing attribute in domain model
Goto Forum:
  


Current Time: Fri Mar 29 01:09:38 GMT 2024

Powered by FUDForum. Page generated in 0.03025 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top