0

I'm currently working on Uniform cost algorithm "Calculates the shortest path". Why i've mentioned this because it gives me a series of locations on map "GUI"

For example: running UCA(V1,V4) would return an array of locations' let's suppose it returns V1 V2 V3 V4 shortest path from V1 to V4.

& let's suppose V1,V2,V3, and V4 located at

V1.setBounds(10, 10, 50, 50);
V2.setBounds(20, 10, 50, 50);
V3.setBounds(30, 10, 50, 50);
V4.setBounds(40, 10, 50, 50);

What i'm trying to do, let's suppose i have another object let's assume it's a truck object.

This truck is going to visit V1 then go to V2 up to v4 according to UCA function, but setting truck.setBounds(10,10,50,50) then up to V4 truck.setBounds(40,10,50,50) the truck would move to V1 and etc... but it will only appear on V4, it will never appears on screen that it has visited V1, V2, nor V3.

I could have use timers i mean when it visits V1 sleep <- 3 seconds and so on. But this is an inefficient way.

Is there some kind of animation that i can use to move truck object from one location to various locations ?

Mohamed Horani
  • 544
  • 3
  • 9
  • 23
  • Depending on how complex a solution you're after, you could use a time line/key frame based solution like [this](http://stackoverflow.com/questions/26898536/moving-jlabel-to-other-jlabels-gui/26899099#26899099) or [this](http://stackoverflow.com/questions/28619150/move-image-in-a-spiral-fashion-in-java/28619554#28619554) or [this](http://stackoverflow.com/questions/30433074/jpanel-image-flies-from-the-screen/30433207#30433207) – MadProgrammer Mar 06 '16 at 09:36
  • Or you could do something like [this](http://stackoverflow.com/questions/31041991/moving-a-square-from-a-starting-point-to-the-position-of-a-mouse-click-at-a-fixe/31042775#31042775) or something like [this](http://stackoverflow.com/questions/32392095/how-to-rotate-a-rectangle-after-reaching-specified-position/32397121#32397121) – MadProgrammer Mar 06 '16 at 09:37

0 Answers0