Class AnimationClass

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Animation
Direct Known Subclasses:
MultipleQueueNetAnimation, SingleQueueNetAnimation

public class AnimationClass extends JComponent implements Animation
This class is a super class for all the animations.
Author:
Lorenzo Torri Date: 22-mar-2024 Time: 10.30
See Also:
  • Field Details

    • jobSet

      protected Set<Job> jobSet
    • anim

      protected Animator anim
    • animPanel

      protected AnimationPanel animPanel
    • parent

      protected JPanel parent
    • simulation

      protected Simulation simulation
    • velocityFactor

      protected int velocityFactor
    • source

      protected Source source
    • sink

      protected Sink sink
    • edgeList

      protected List<Edge> edgeList
    • stationList

      protected List<Station> stationList
  • Constructor Details

  • Method Details

    • restartAnimator

      public void restartAnimator()
    • initGUI

      public void initGUI(JPanel container)
      Description copied from interface: Animation
      Paint for the first time the model
      Specified by:
      initGUI in interface Animation
    • refresh

      public void refresh()
      Description copied from interface: Animation
      Method for updating some values inside the class. It is crucial since when we call the repaint() method and start the chain of calls of the paint() methods of each JComponent, those paint() method use some local variables of the clasess. If we change those variables with this method, then we can obtain some changes also in the graphics
      Specified by:
      refresh in interface Animation
    • paint

      public void paint(Graphics g)
      Description copied from interface: Animation
      Paint is a method for all JComponents. It is called when the class is istanciated, and called again when the repaint() method is invoked inside the class. Each paint of an animation recall then all the paint() of the subcomponents of an Animation. Repaint() must be called only once inside the Animation class, never on the subcomponents
      Specified by:
      paint in interface Animation
      Overrides:
      paint in class JComponent
      Parameters:
      g -
    • start

      public void start()
      Description copied from interface: Animation
      Start the animation
      Specified by:
      start in interface Animation
    • pause

      public void pause()
      Description copied from interface: Animation
      Pause the animation
      Specified by:
      pause in interface Animation
    • reload

      public void reload()
      Description copied from interface: Animation
      Reload the animation if it was paused
      Specified by:
      reload in interface Animation
    • stop

      public void stop()
      Description copied from interface: Animation
      Stop the animation. It is used when a maximum number of jobs is reached and nothing can be done
      Specified by:
      stop in interface Animation
    • next

      public void next()
      Description copied from interface: Animation
      Next event in the animation. The simulation time is increased (whenever System.currentMillis() is used, multiply it for a factor > 1), and the simulation pauses when a new event occurs
      Specified by:
      next in interface Animation
    • resetNextEvent

      public void resetNextEvent()
      To set all the subcomponents with nextEvent = false (because we want, after an event, the possibility to continue the simulation in normal mode or with nextEvent way)
    • setVelocityFactor

      public void setVelocityFactor(int velocity)
      Description copied from interface: Animation
      Set the velocity Factor of the animation
      Specified by:
      setVelocityFactor in interface Animation
    • isPaused

      public boolean isPaused()
    • updatePause

      public void updatePause(long pause)
      Description copied from interface: Animation
      This method is important for udpdating all those components inside the Animation that are affected by a pause of the Animator. One example is the CircleStation, in which the amount of progression is computed as the difference between the current time and the time of entrance of the job in the circle. But if the animator was paused, then this amount does not have to be computed in the difference of before, so it is crucial to pass to the Circle this value and remove it from the difference
      Specified by:
      updatePause in interface Animation
      Parameters:
      pause - the amount of time during which the animator was paused
    • addNewJob

      public void addNewJob(Job job)
      This method adds a new job inside the list of jobs of the Animation. It is usually called by the source of the Animation
      Parameters:
      job - to add in the list
    • removeJob

      public void removeJob(Job job)
      This method removes a job inside the list of jobs of the Animation. It is usually called by the sink of the Animation
      Parameters:
      job - to remove from the list
    • updateSingle

      public void updateSingle(Simulation sim, int nservers, DistributionJMCH serviceTime, DistributionJMCH interArrivalTime, int maxJobs, boolean isGraphicalAnimation)
      Method for updating the SingleQueue
      Parameters:
      sim - new info about the simulation
      nservers - number of servers
      serviceTime - distribution of the service time
      interArrivalTime - distribution of the inter-arrival time
      maxJobs - max number of generated jobs
      isGraphicalAnimation - if the edge between the source and the station is there or not
    • updateMultiple

      public void updateMultiple(Simulation sim, DistributionJMCH serviceTime, DistributionJMCH interArrivalTime, int maxJobs, boolean isGraphicalAnimation)
      Method for updating the MultipleQueue
      Parameters:
      sim - new info about the simulation
      serviceTime - distribution of the service time
      interArrivalTime - distribution of the inter-arrival time
      maxJobs - max number of generated jobs
      isGraphicalAnimation - if the edge between the source and the station is there or not
    • updateMultiple

      public void updateMultiple(Simulation sim, double[] percentages, DistributionJMCH serviceTime, DistributionJMCH interArrivalTime, int maxJobs, boolean isGraphicalAnimation)
      Method for updating the MultipleQueue with routing Policy = PROBABILISTIC
      Parameters:
      sim - new info about the simulation
      percentages - new array of percentages associated to the outgoing arcs from the router
      serviceTime - distribution of the service time
      interArrivalTime - distribution of the inter-arrival time
      maxJobs - max number of generated jobs
      isGraphicalAnimation - if the edge between the source and the station is there or not
    • getAnimator

      public Animator getAnimator()
    • getSimulation

      public Simulation getSimulation()
    • getSolverAnimation

      public AnimationSolver getSolverAnimation()
    • getVelocityFactor

      public int getVelocityFactor()
    • getListJobSize

      public int getListJobSize()
    • getSource

      public Source getSource()
    • getSingleStation

      public Station getSingleStation()
    • updateAnimResults

      public void updateAnimResults()
      Description copied from interface: Animation
      Called by the animator each time is paused. Update the results in the Result table for the ANIM row.
      Specified by:
      updateAnimResults in interface Animation