haifa.shopsim.UI.shopanim
Class MachineAnimIcon

java.lang.Object
  |
  +--haifa.shopsim.UI.shopanim.ShopAnimIcon
        |
        +--haifa.shopsim.UI.shopanim.MachineAnimIcon
All Implemented Interfaces:
javax.swing.Icon, ShopAnimConstants

public class MachineAnimIcon
extends ShopAnimIcon

Icon representing machine, responsible for drawing machine, buffers and jobs.

Version:
1.1

Field Summary
protected  int[] angles
          Stores the angle (A multiple of 30 degrees) at which the each of the buffers is drawn.
(package private) static int BUFFER_ANGLE_SPREAD
           
(package private) static java.awt.Color BUFFER_COLOR
           
(package private) static int BUFFER_RECT_HEIGHT
           
protected  int circleHeight
           
protected  int circleWidth
           
(package private) static java.awt.Color IDLE_CIRCLE_COLOR
           
protected  int machineNumber
           
(package private) static int MAX_JOBS_TO_DRAW
          If there are more jobs than that in Q then they are not drawn.
protected  int numBuffers
          The number of buffers/queues/classes that this machine supports.
protected  int processingBuffer
          The index of the processing buffer (0,...,numBuffers-1) or -1 if machine is idle.
protected  int[] queueSizes
          Says how many jobs in each buffer.
(package private) static int SIZE_AROUND_CIRCLE
           
(package private) static int STEP_Q
           
(package private) static int STEP_START_Q
           
(package private) static java.awt.Color WORKING_CIRCLE_COLOR
           
 
Fields inherited from class haifa.shopsim.UI.shopanim.ShopAnimIcon
height, JOB_CROSS_SIZE, orientation, random, width
 
Fields inherited from interface haifa.shopsim.UI.shopanim.ShopAnimConstants
EAST, NORTH, NOT_SET, NUM_MACHINE_SPOTS_HEIGHT, NUM_MACHINE_SPOTS_WIDTH, SOUTH, WEST
 
Constructor Summary
MachineAnimIcon()
           
MachineAnimIcon(int numBuffers_)
          Creates new MachineAnimIcon with numBuffers_ buffers.
MachineAnimIcon(int numBuffers_, int[] angles_)
          Creates new MachineAnimIcon with numBuffers_ buffers.
 
Method Summary
private  void drawBuffer(int x, int y, int r, int bufferIndex, java.awt.Graphics g)
           
 java.awt.Point getOperationPoint(int bufferIndex, int x, int y)
           
 void paintIcon(java.awt.Component comp, java.awt.Graphics g, int x, int y)
          Should be implemented by the baseclasses.
 void setAngles(int[] angles_)
           
 void setIconHeight(int height_)
           
 void setIconWidth(int width_)
           
 void setMachineNumber(int machineNumber_)
           
 void setNumBuffers(int numBuffers_)
          Sets the number of buffers.
 void setProcessingBuffer(int buffer)
          Set the buffer which is processing.
 void setQueueSize(int queueIndex, int numInQ)
           
 void setQueueSizes(int[] queueSizes_)
           
 
Methods inherited from class haifa.shopsim.UI.shopanim.ShopAnimIcon
drawCross, getIconHeight, getIconWidth, getOrientation, getRandomPoint, setOrientation
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

numBuffers

protected int numBuffers
The number of buffers/queues/classes that this machine supports.

machineNumber

protected int machineNumber

angles

protected int[] angles
Stores the angle (A multiple of 30 degrees) at which the each of the buffers is drawn.

queueSizes

protected int[] queueSizes
Says how many jobs in each buffer. If a buffer is processing, the job is still counted.

processingBuffer

protected int processingBuffer
The index of the processing buffer (0,...,numBuffers-1) or -1 if machine is idle.

circleWidth

protected int circleWidth

circleHeight

protected int circleHeight

SIZE_AROUND_CIRCLE

static final int SIZE_AROUND_CIRCLE

BUFFER_RECT_HEIGHT

static final int BUFFER_RECT_HEIGHT

BUFFER_ANGLE_SPREAD

static final int BUFFER_ANGLE_SPREAD

STEP_START_Q

static final int STEP_START_Q

STEP_Q

static final int STEP_Q

MAX_JOBS_TO_DRAW

static final int MAX_JOBS_TO_DRAW
If there are more jobs than that in Q then they are not drawn.

IDLE_CIRCLE_COLOR

static final java.awt.Color IDLE_CIRCLE_COLOR

WORKING_CIRCLE_COLOR

static final java.awt.Color WORKING_CIRCLE_COLOR

BUFFER_COLOR

static final java.awt.Color BUFFER_COLOR
Constructor Detail

MachineAnimIcon

public MachineAnimIcon()

MachineAnimIcon

public MachineAnimIcon(int numBuffers_)
Creates new MachineAnimIcon with numBuffers_ buffers. The angles are set to 0,30,60,90,120,...,30*(numBuffers-1)

MachineAnimIcon

public MachineAnimIcon(int numBuffers_,
                       int[] angles_)
Creates new MachineAnimIcon with numBuffers_ buffers. The angles are set from the angles array.
Method Detail

setMachineNumber

public void setMachineNumber(int machineNumber_)

setNumBuffers

public void setNumBuffers(int numBuffers_)
Sets the number of buffers. It also resets all queues to 0, and causes machine to be not processing. The angles are set to 0,30,60,90,120,...,30*(numBuffers-1).

setAngles

public void setAngles(int[] angles_)

setIconWidth

public void setIconWidth(int width_)
Overrides:
setIconWidth in class ShopAnimIcon

setIconHeight

public void setIconHeight(int height_)
Overrides:
setIconHeight in class ShopAnimIcon

setQueueSizes

public void setQueueSizes(int[] queueSizes_)

setQueueSize

public void setQueueSize(int queueIndex,
                         int numInQ)

setProcessingBuffer

public void setProcessingBuffer(int buffer)
Set the buffer which is processing. Pass -1 if machine is idle.

getOperationPoint

public java.awt.Point getOperationPoint(int bufferIndex,
                                        int x,
                                        int y)

paintIcon

public void paintIcon(java.awt.Component comp,
                      java.awt.Graphics g,
                      int x,
                      int y)
Description copied from class: ShopAnimIcon
Should be implemented by the baseclasses. Must not paint outside of the range (x,y) -- (x+width-1,y+height-1).
Overrides:
paintIcon in class ShopAnimIcon

drawBuffer

private void drawBuffer(int x,
                        int y,
                        int r,
                        int bufferIndex,
                        java.awt.Graphics g)