Class MotionKiller

  • All Implemented Interfaces:
    Runnable

    public class MotionKiller
    extends 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 Detail

      • 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 Runnable
        Specified by:
        run in class 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)