Class JobAnimation

java.lang.Object
common.animation.JobAnimation
All Implemented Interfaces:
Animation

public class JobAnimation extends Object implements Animation
Created by IntelliJ IDEA. User: orsotronIII Date: 17-gen-2005 Time: 13.53.44 Represents a job to be routed through the queue net. Paths to be followed must be specified. If more than one path is defined, this class randomly decides which path to follow next when the current one is completed.
  • Field Details

    • position

      protected double position
      current symbolic position. Represents a coordinate calculated along the line of an edge.
    • timeOfEntrance

      protected long timeOfEntrance
      timer that keeps trace of the millisecs passed by the time this job entered the element (e.g. edge or station) it is going through
  • Constructor Details

    • JobAnimation

      public JobAnimation(double speed, JobPath[] jps, Rectangle bounds)
      Creates a new instance of JobAnimation initialized with specified default paths to be followed by the job and specified speed.
      Parameters:
      speed - : speed this job must keep following its paths. It is measured in pixels per second
      jps - : paths this Job can go through
      bounds - : default size for this job
    • JobAnimation

      public JobAnimation(JobAnimation job)
      Creates a new instance of JobAnimation initialized with specified values of another job.
      Parameters:
      job - : job wanted to be copied.
    • JobAnimation

      public JobAnimation(double speed, JobPath[] jps, Rectangle bounds, IconsToolkit toolkit)
      Creates a new instance of JobAnimation initialized with specified default paths to be followed by the job and specified speed.
      Parameters:
      speed - : speed this job must keep following its paths. It is measured in pixels per second
      jps - : paths this Job can go through
      bounds - : default size for this job
      toolkit - : Image toolkit for customized renderization of job image
  • Method Details

    • refresh

      public void refresh()
      Description copied from interface: Animation
      Called when an animation needs to be refreshed. This method should update image currently handled by the animation
      Specified by:
      refresh in interface Animation
    • init

      public void init()
      Description copied from interface: Animation
      Initialization method for implementing class. The implementation of this method should prepare images for the animation, if this has not been done within constructor.
      Specified by:
      init in interface Animation
    • paint

      public void paint(Graphics g, ImageObserver io)
      Description copied from interface: Animation
      Paints image currently handled in a rectangle defined within Animation.setBounds(Rectangle) method
      Specified by:
      paint in interface Animation
    • getBGImage

      public Image getBGImage()
      Description copied from interface: Animation
      returns background image for this animation.
      Specified by:
      getBGImage in interface Animation
      Returns:
      :Background image for this animation
    • setBGImage

      public void setBGImage(Image img)
      Description copied from interface: Animation
      sets background image for this animation.
      Specified by:
      setBGImage in interface Animation
      Parameters:
      img - : background image for this animation
    • setBounds

      public void setBounds(Rectangle r)
      Description copied from interface: Animation
      Sets bounding box for this animation. If this box is set, animation will update only this certain area of the Graphics object passed within Animation.paint(Graphics, ImageObserver) method.
      Specified by:
      setBounds in interface Animation
      Parameters:
      r - : Bounding box for this animation.
    • getBounds

      public Rectangle getBounds()
      Description copied from interface: Animation
      Returns bounding box for this animation, e.g. the rectangle within which the frames for this animation will be painted
      Specified by:
      getBounds in interface Animation
      Returns:
      : Bounding box for this animation.
    • setRepaint

      public void setRepaint(boolean repaint)
      Tells this class to show or hide itself.
      Parameters:
      repaint - : true if this class must show itself, false otherwise.
    • getRepaint

      public boolean getRepaint()
      Tells whether this job was set to be hidden or to be shown.
      Returns:
      true if this job must be shown, false otherwise
    • getSpeed

      public double getSpeed()
    • getPosition

      public double getPosition()
    • setPosition

      public void setPosition(double newPosition)
    • getNextElement

      public JobContainer getNextElement()
      Returns next queue net element this job must be routed to.
    • resetTimeOfEntrance

      public void resetTimeOfEntrance()
      Resets the time of entrance of this job in the element that currently contains it. every class that accepts jobs must call this method whenever a a new job is added, in order to calculate the correct position once the job speed is known.
    • getTimeOfEntrance

      public long getTimeOfEntrance()
      returns system timestamp (in millisecs) for the time of entrance in an element of the queuenet.
      Returns:
      :number of system millisecs time.