verinec.netsim.gui
Class SimulationToolbar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JToolBar
                  extended by verinec.netsim.gui.SimulationToolbar
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, SwingConstants

public class SimulationToolbar
extends JToolBar
implements ActionListener, ChangeListener

Acts a a controlcenter for the simulation. The user can control the simulaiton via the buttons and silders of this class.

Author:
Renato Loeffel
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JToolBar
JToolBar.AccessibleJToolBar, JToolBar.Separator
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private static String BACK_ICON
          Icon location for back command.
private  JButton backward
           
private  JTextField currentTime
           
private  Element events
          The simulation result currently beeing played.
private  JButton forward
           
private static String FORWARD_ICON
          Icon location for forward command.
private  JButton pause
           
private static String PAUSE_ICON
          Icon location for pause command.
private  JButton play
           
private  JSlider progress
           
private  Simulator simulator
           
private  SimulatorThread simuThread
           
private  JSlider speed
           
private static String START_ICON
          Icon location for start command.
private  JButton stop
           
private static String STOP_ICON
          Icon location for stop command.
private  VerinecStudio verinecStudio
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SimulationToolbar(VerinecStudio parent, Simulator simu)
          Initializes buttons and sliders.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Handles the events of the buttons.
 int getProgress()
          Returns the current value of the progressbar.
 void initProgress(int start, int end)
          Sets up progressbar.
 void setEvents(Element e)
          Set the simulation events to play.
 void setProgress(int value)
          Sets the progressbar to a new value.
 void startPlayer(Element e)
          Start playing the simulation of the events.
 void stateChanged(ChangeEvent e)
          Handles the events of the silders.
 void terminateSimulation()
          Terminates the simulation.
 
Methods inherited from class javax.swing.JToolBar
add, addImpl, addSeparator, addSeparator, createActionChangeListener, createActionComponent, getAccessibleContext, getComponentAtIndex, getComponentIndex, getMargin, getOrientation, getUI, getUIClassID, isBorderPainted, isFloatable, isRollover, paintBorder, paramString, setBorderPainted, setFloatable, setLayout, setMargin, setOrientation, setRollover, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

verinecStudio

private VerinecStudio verinecStudio

simulator

private Simulator simulator

play

private JButton play

pause

private JButton pause

stop

private JButton stop

backward

private JButton backward

forward

private JButton forward

speed

private JSlider speed

progress

private JSlider progress

currentTime

private JTextField currentTime

simuThread

private SimulatorThread simuThread

events

private Element events
The simulation result currently beeing played.


START_ICON

private static String START_ICON
Icon location for start command.


PAUSE_ICON

private static String PAUSE_ICON
Icon location for pause command.


STOP_ICON

private static String STOP_ICON
Icon location for stop command.


FORWARD_ICON

private static String FORWARD_ICON
Icon location for forward command.


BACK_ICON

private static String BACK_ICON
Icon location for back command.

Constructor Detail

SimulationToolbar

public SimulationToolbar(VerinecStudio parent,
                         Simulator simu)
Initializes buttons and sliders.

Parameters:
parent - Reference to the main application window.
simu - The simulator instance.
Method Detail

setEvents

public void setEvents(Element e)
Set the simulation events to play. If you set this to null, the control buttons will get disabled.

Parameters:
e - The events in the <events> tag.

startPlayer

public void startPlayer(Element e)
Start playing the simulation of the events.

Parameters:
e - The events to play.

initProgress

public void initProgress(int start,
                         int end)
Sets up progressbar.

Parameters:
start - the startpoint of the progressbar.
end - the endpoint of the progressbar.

terminateSimulation

public void terminateSimulation()
Terminates the simulation. Stops the simulation thread and disables the progress slider.


setProgress

public void setProgress(int value)
Sets the progressbar to a new value.

Parameters:
value - The new value as for JSlider.setValue(int).

getProgress

public int getProgress()
Returns the current value of the progressbar.

Returns:
the current time.

actionPerformed

public void actionPerformed(ActionEvent e)
Handles the events of the buttons. The corresponding message is sent to its thread.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - The event to treat.

stateChanged

public void stateChanged(ChangeEvent e)
Handles the events of the silders. The corresponding message is sent to its thread.

Specified by:
stateChanged in interface ChangeListener
Parameters:
e - The event to treat.

Copyright © 2005 Verinec, DIUF