Getting a Polyline's endpoints without a visual refresh [message #188523] |
Wed, 20 July 2005 23:59 |
Emerson Murphy-Hill Messages: 22 Registered: July 2009 |
Junior Member |
|
|
I am trying to make my connections animate, which seems to be going
smoothly, except for one small problem. My intent is that when a
connection is first made visible, it will be drawn from source to target
in small steps (as if you were drawing it with a pencil).
However, just before the animation begins, the whole line flashes on the
screen. For the visual among us, at each step it is drawn like so:
-----
-
--
---
----
-----
The code:
public static void connect(PolylineConnection connection,
int iterations,
int stepMilliSeconds) {
//dilemma here...
connection.getUpdateManager().performUpdate();
// backup
Point trueEndPoint = connection.getEnd();
Point trueStartPoint = connection.getStart();
connection.setVisible(true);
//animate!
for (double count = 0; count < 1;
count = count + 1.0 / iterations) {
Point newEndPoint = trueEndPoint.getCopy().translate(
trueStartPoint.getCopy().negate());
newEndPoint.scale(count);
newEndPoint.translate(trueStartPoint);
connection.setEnd(newEndPoint);
connection.getUpdateManager().performUpdate();
sleep(stepMilliSeconds);
}
// restore
connection.setEnd(trueEndPoint);
connection.getUpdateManager().performUpdate();
}
The problem can be corrected if I remove the line marked "dilemma," but
I will not get the correct start and end points on the next two lines.
I have tried validate(), but the start and endpoints are relative to
thier parents, not absolute as they are after performUpdate(). Updating
the figure seems to be the only way to go.
So the question is: how do I either hide the first draw, or get the
absolute endpoints without updating?
Thanks!
e
|
|
|
Powered by
FUDForum. Page generated in 0.03888 seconds