simulator
Class VSSimulatorVisualization

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by simulator.VSSimulatorVisualization
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible, VSSerializable

public class VSSimulatorVisualization
extends java.awt.Canvas
implements java.lang.Runnable, VSSerializable

The class VSSimulatorVisualization. An instance of this object represents the graphical paint area of a simulator. It contains all graphic calculations. Also the simulator thread takes place in this class in a loop! This class is probably the most cryptic of the whole simulator source code. This is this way in order to gain more performance of the painting area!

Author:
Paul C. Buetow
See Also:
Serialized Form

Nested Class Summary
 class VSSimulatorVisualization.VSMessageLine
          The class VSMessageLine, an object of this class represents a message line drawn into the painting area.
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
VSSimulatorVisualization(VSPrefs prefs, VSSimulator simulator, VSLogging loging)
          Instantiates a new VSSimulatorVisualization object.
 
Method Summary
 void deserialize(VSSerialize serialize, java.io.ObjectInputStream objectInputStream)
          Deserializes
 void editProcess(int processNum)
          Edits the process.
 void editProcess(VSInternalProcess process)
          Edits the process.
 void finish()
          Called if the simulator has finished.
 int getNumProcesses()
          Gets the num of processes.
 VSInternalProcess getProcess(int processNum)
          Gets the specified process.
 java.util.ArrayList<VSInternalProcess> getProcesses()
          Gets the processes.
 java.util.ArrayList<VSInternalProcess> getProcessesArray()
          Gets the processes array.
 java.lang.Integer[] getProcessIDs()
          Gets the processes IDs.
 long getStartTime()
          Gets the start time.
 VSTaskManager getTaskManager()
          Gets the task manager.
 long getTime()
          Gets the time.
 long getUntilTime()
          Gets the until time.
 boolean hasThreadStopped()
          Checks if the thread has been stopped.
 void isAntiAliased(boolean isAntiAliased)
          Sets if the simulator graphics are anti aliased.
 void paint()
          Paints the simulator.
 void pause()
          Call this, in order to pause the simulator.
 void play()
          Starts/plays the simulator.
 int processIDCount()
          Gets the next process id.
 void reset()
          Call this, in order to reset the simulator.
 void run()
           
 void sendMessage(VSMessage message)
          Sends a message.
 void serialize(VSSerialize serialize, java.io.ObjectOutputStream objectOutputStream)
          Serializes
 void showLamport(boolean showLamport)
          Sets, if the the lamport time should be shown.
 void showVectorTime(boolean showVectorTime)
          Sets, if the vector time should be shown.
 void stopThread()
          Stops the thread of the simulator.
 void updateFromPrefs()
          Updates from the prefs.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VSSimulatorVisualization

public VSSimulatorVisualization(VSPrefs prefs,
                                VSSimulator simulator,
                                VSLogging loging)
Instantiates a new VSSimulatorVisualization object.

Parameters:
prefs - the prefs
simulator - the simulator
loging - the loging
Method Detail

paint

public void paint()
Paints the simulator.


getTime

public long getTime()
Gets the time.

Returns:
the time

getUntilTime

public long getUntilTime()
Gets the until time.

Returns:
the until time

getStartTime

public long getStartTime()
Gets the start time.

Returns:
the start time

processIDCount

public int processIDCount()
Gets the next process id.

Returns:
the next process id

getTaskManager

public VSTaskManager getTaskManager()
Gets the task manager.

Returns:
the task manager

getNumProcesses

public int getNumProcesses()
Gets the num of processes.

Returns:
the num of processes

getProcess

public VSInternalProcess getProcess(int processNum)
Gets the specified process.

Parameters:
processNum - the process num to get the process of
Returns:
the process

run

public void run()
Specified by:
run in interface java.lang.Runnable

play

public void play()
Starts/plays the simulator.


finish

public void finish()
Called if the simulator has finished.


pause

public void pause()
Call this, in order to pause the simulator.


reset

public void reset()
Call this, in order to reset the simulator.


stopThread

public void stopThread()
Stops the thread of the simulator.


hasThreadStopped

public boolean hasThreadStopped()
Checks if the thread has been stopped.

Returns:
true, if is thread has stopped

showLamport

public void showLamport(boolean showLamport)
Sets, if the the lamport time should be shown. It implicitly disables the vector time.

Parameters:
showLamport - true, if the lamport time should be shown

showVectorTime

public void showVectorTime(boolean showVectorTime)
Sets, if the vector time should be shown. It implicitly disables the lamport time.

Parameters:
showVectorTime - true, if the vector time should be shown

isAntiAliased

public void isAntiAliased(boolean isAntiAliased)
Sets if the simulator graphics are anti aliased.

Parameters:
isAntiAliased - true, if the simulator is anti aliased

sendMessage

public void sendMessage(VSMessage message)
Sends a message.

Parameters:
message - the message

editProcess

public void editProcess(int processNum)
Edits the process.

Parameters:
processNum - the process num

editProcess

public void editProcess(VSInternalProcess process)
Edits the process.

Parameters:
process - the process

getProcessesArray

public java.util.ArrayList<VSInternalProcess> getProcessesArray()
Gets the processes array.

Returns:
the processes array

getProcessIDs

public java.lang.Integer[] getProcessIDs()
Gets the processes IDs.

Returns:
the processes IDs

getProcesses

public java.util.ArrayList<VSInternalProcess> getProcesses()
Gets the processes.

Returns:
the processes

updateFromPrefs

public void updateFromPrefs()
Updates from the prefs. Called by the VSSimulatorEditor if values have been saved.


serialize

public void serialize(VSSerialize serialize,
                      java.io.ObjectOutputStream objectOutputStream)
               throws java.io.IOException
Description copied from interface: VSSerializable
Serializes

Specified by:
serialize in interface VSSerializable
Parameters:
serialize - The serialize object
objectOutputStream - The object output stream
Throws:
java.io.IOException

deserialize

public void deserialize(VSSerialize serialize,
                        java.io.ObjectInputStream objectInputStream)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Description copied from interface: VSSerializable
Deserializes

Specified by:
deserialize in interface VSSerializable
Parameters:
serialize - The serialize object
objectInputStream - The object input stream
Throws:
java.io.IOException
java.lang.ClassNotFoundException