Within our application I want to draw the links between some nodes with a small animation e.g. moving dots.
Does anybody has some sample code for subclassing JGoPen for drawing an animation?
Thanks in advance,
I don’t know if anyone has done this before, but the basic idea would be to regularly modify those links so that they get redrawn.
So, set up a single Swing Timer to set the pen of each JGoLink to a new pen that you allocate to draw appropriately. I think you should be able to subclass JGoPen and override getStroke to produce different offsets for the dots or dashes.
Make sure you call JGoDrawable.setPen while the skipsUndoManager property is true:
so that document changes that are meant to be transient are not recorded by the JGoUndoManager.
For efficiency reasons, don’t create a Timer per link. Remember that the interval need only be a few times per second–anything faster is likely to be wasted since the user can’t appreciate it, and since it might greatly increase the CPU/IO requirements.