Class Edge

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, JobContainer

public class Edge extends JComponent implements JobContainer
Class for an edge in the animation. Edges can only be straight from a start point to a finish point, so be careful when creating them, they must have either start.x = finish.x or start.y = finish.y When a job arrives to the finish point then it is routed to the next element associated to this edge.
Author:
Lorenzo Torri Date: 26-mar-2024 Time: 13.40
See Also:
  • Constructor Details

    • Edge

      public Edge(AnimationClass anim, JPanel container, boolean centered, boolean isArrow, Point[] points, JobContainer next)
      Constructor
      Parameters:
      anim - AnimationClass which the edge is part of
      container - , JPanel that contains this edge
      centered - , if the edge is y centered with respect to the JPanel or not
      isArrow - , if the edge is an arrow and not a simple line
      points - , points of the edge
      next - , JobContainer next to this edge
    • Edge

      public Edge(AnimationClass anim, JPanel container, boolean centered, boolean isArrow, Point[] points, JobContainer next, int speed)
      Constructor for Edges with higher speed
      Parameters:
      speed -
  • Method Details

    • paint

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

      public void paintPercentage(double p, int index)
      Method to paint the percentage near the edge. This method is useful for Routing Probabilistic policy
      Parameters:
      p - percentage
      index - value of the i-th edge
    • getDirection

      public jmt.jmch.animation.Direction getDirection(Point start, Point finish)
      Method to understand the direction of the segment defined by two points
    • refresh

      public void refresh()
      Specified by:
      refresh in interface JobContainer
    • 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
    • routeJob

      public void routeJob(int i)
      Route a job to the next JobContainer since it has arrived to the final point of the edge
      Parameters:
      i - , index of the job inside the JobList of the edge
    • nextEvent

      public void nextEvent()
      Set the Step simulation on
    • resetNextEvent

      public void resetNextEvent()
      Set the Step simulation off
    • getSpeed

      public double getSpeed()
    • setSpeed

      public void setSpeed(double sp)
    • highlightON

      public void highlightON(Color jobColor)
    • highlight

      public void highlight()
    • getTotalLength

      public int getTotalLength()
    • setXFinish

      public void setXFinish(int xpos)
    • setXStart

      public void setXStart(int xpos)
    • setYFinish

      public void setYFinish(int ypos)
    • setYStart

      public void setYStart(int ypos)
    • setYPoint

      public void setYPoint(int ypos, int i)
    • setXPoint

      public void setXPoint(int xpos, int i)