Class Source

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, GraphicComponent, JobContainer

public class Source extends JComponent implements JobContainer, GraphicComponent
This class is responsible for creating the jobs and routing them to the first edge of the animation
Author:
Lorenzo Torri Date: 31-mar-2024 Time: 11.30
See Also:
  • Constructor Details

    • Source

      public Source(AnimationClass anim, JPanel container, boolean centered, Point pos, JobContainer next, DistributionJMCH interArrival, DistributionJMCH service)
      Constructor
      Parameters:
      anim - , AnimationClass associated to this component. It is needed in order to remove the job arrived to the sink also from the list of jobs of the AnimationClass
      container - , JPanel that contains this sink
      centered - , if the component is centered with respect to the Jpanel
      pos - , position of the component. If it is centered then this pos is not important, it can be anything
      next - , next JContainer linked to the source
      interArrival - , distribution of the interarrival time
  • Method Details

    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class JComponent
    • refresh

      public void refresh()
      Specified by:
      refresh in interface JobContainer
    • setStart

      public void setStart(long time)
      Method used by the AnimationClass to set the starting timer of the animation and to set the new randomValue
      Parameters:
      time - start time of the animation
    • routeJob

      public void routeJob(int i)
    • addJob

      public void addJob(JobContainer prec, Job newJob)
      Description copied from interface: JobContainer
      Add a new Job to this JobContainer
      Specified by:
      addJob in interface JobContainer
      Parameters:
      newJob - Job to add to this Container
    • updatePause

      public void updatePause(long pause)
    • updateDistribution

      public void updateDistribution(DistributionJMCH service, DistributionJMCH interA)
      Update the Service time and InterArrival time distribution. Called from the AnimationClass
      Parameters:
      service - new distribution for service time
      interA - new distribution for inter arrival time
    • updateMaxJobs

      public void updateMaxJobs(int maxJobs)
    • updateNextContainer

      public void updateNextContainer(JobContainer next)
    • getMaxJobs

      public int getMaxJobs()
    • getGeneratedJobs

      public int getGeneratedJobs()
    • getXPos

      public int getXPos()
      Description copied from interface: GraphicComponent
      Return the drawing starting position in the panel of a component
      Specified by:
      getXPos in interface GraphicComponent
    • getYPos

      public int getYPos()
      Specified by:
      getYPos in interface GraphicComponent
    • getTotalLenght

      public int getTotalLenght()
      Description copied from interface: GraphicComponent
      Get the total length of a component when drawn
      Specified by:
      getTotalLenght in interface GraphicComponent
    • setYPos

      public void setYPos(int yPos)
      Specified by:
      setYPos in interface GraphicComponent
    • setXPos

      public void setXPos(int xPos)
      Specified by:
      setXPos in interface GraphicComponent