net.ontopia.topicmaps.viz
Class MotionKiller

java.lang.Object
  extended by java.util.TimerTask
      extended by net.ontopia.topicmaps.viz.MotionKiller
All Implemented Interfaces:
java.lang.Runnable

public class MotionKiller
extends java.util.TimerTask

Stops the motion of the nodes in Vizigator at certain intervals. Has methods for that lets the MotionKiller waits for a given amount of time before stopping the motion, so that the nodes can be arranged reasonably first. Also has a counter that helps operations outside the OKS, which cannot call the waitFor() operation, so that these operations are given a bit more time (on average) to finish. WEAKNESSES: There are some weaknesses to this approach. First of all, MotionKiller may run immediately after operations that are outside the OKS, since these cannot ask MotionKiller to wait. - This would be easily solvable if we modified the TouchGraph code. Another disadvantage is that MotionKiller compromised with the algorithm in TouchGraph which makes sure nodes and edges are arranged optimally to avoid clutter. For small graphs this is normally not a problem, but large graphs which take time to arrange optimally may end up much more cluttered than necessary. Possible solutions to this problem are: - Let the user control the parameters of this class (easy to implement) - Improve the layout algorithm of TouchGraph (probably hard) - Hope that TouchGraph has/will implement an improved layout algorithm.


Field Summary
protected  int cycle
           
protected  boolean enabled
           
static boolean INITIALLY_ENABLED
           
protected  int maxCycle
           
protected  com.touchgraph.graphlayout.TGPanel tgPanel
           
protected  long waitUntil1
           
protected  long waitUntil2
           
 
Constructor Summary
MotionKiller(com.touchgraph.graphlayout.TGPanel tgPanel, long millis)
          Create a MotionKiller for the given tgPanel, scheduled to run every 'millis' number of milliseconds after creation.
 
Method Summary
 boolean getEnabled()
           
 void run()
          This method is called on schedula by the timer.
 void setEnabled(boolean enabled)
          Enables/disables this motion killer.
protected  void setMaxCycle(int maxCycle)
           
 void waitFor(long duration1, long duration2)
          Wait for 'duration1' milliseconds before slowing down the motion, then wait for 'duration2' milliseconds before stopping the motion,
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIALLY_ENABLED

public static final boolean INITIALLY_ENABLED
See Also:
Constant Field Values

tgPanel

protected com.touchgraph.graphlayout.TGPanel tgPanel

waitUntil1

protected long waitUntil1

waitUntil2

protected long waitUntil2

cycle

protected int cycle

maxCycle

protected int maxCycle

enabled

protected boolean enabled
Constructor Detail

MotionKiller

public MotionKiller(com.touchgraph.graphlayout.TGPanel tgPanel,
                    long millis)
Create a MotionKiller for the given tgPanel, scheduled to run every 'millis' number of milliseconds after creation.

Parameters:
tgPanel - The TGPanel for which to stop the motion.
millis - The milliseconds between every time the motion is stopped
Method Detail

waitFor

public void waitFor(long duration1,
                    long duration2)
Wait for 'duration1' milliseconds before slowing down the motion, then wait for 'duration2' milliseconds before stopping the motion,


run

public void run()
This method is called on schedula by the timer.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask

setEnabled

public void setEnabled(boolean enabled)
Enables/disables this motion killer. Note: VizPanel uses the value of enabled to build menus, so this method should only be changed (indirectly) from there.


getEnabled

public boolean getEnabled()

setMaxCycle

protected void setMaxCycle(int maxCycle)


Copyright © 2000-2012 Ontopia.