savi.visualization.support
Class SimPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by savi.visualization.support.TaskPanel
                  extended by savi.visualization.support.SimPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible
Direct Known Subclasses:
FunctionMin, Knapsack, MaxSAT3, TSP, WeightedSAT3

public abstract class SimPanel
extends TaskPanel
implements java.lang.Runnable

Main class providing settings control for simulation annealing, vizualization, graph and help.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  SimAnnealingStepSolver alg
          algorithm
protected  VisualizationPanel bestScreen
          panel for vizualization best solution
protected  StateSkeleton bestState
          best founded state
protected  VisualizationGraph graph
          graph visualization panel
protected  java.awt.Panel ide
          control environment panel
protected  VisualizationInfo infoPanel
          help panel
protected  boolean isRunning
          signalizes running of algorithm
protected  java.lang.Thread runThread
          run thread reference
protected  VisualizationPanel screen
          palace for visualization panel
protected  java.awt.Panel settings
          panel with settings controls
protected  StateSkeleton state
          state of problem
protected  boolean viewCurrent
          signalizes vizualization visiblity of current or best state
 
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
SimPanel(VisualizationPanel vp, double startTemp, double finalTemp, double coolingCoef, int innerLoops)
          Creates a new instance of SimPanel, initialize SA starting values.
 
Method Summary
 void activateScreenView()
          This method switch between best and current solution according to viewCurrent variable.
 void activateView(int v)
          Activate given view. 1 ... view current / best solution 2 ... graph of optimalization criterion 3 ... help
protected  void addEmptySpace()
          Adds empty space for correct alignment.
protected  java.awt.Button addInputButton(java.lang.String title)
          Adds button into settings panel.
protected  java.awt.TextField addInputField(java.lang.String title, java.lang.String initialValue)
          Adds input field (text field).
protected  java.awt.Label addOutputField(java.lang.String title, java.lang.String baseValue)
          Adds output field (label).
 void callSaveInstance()
          This method opens File save dialog and save current problem instance.
protected abstract  VisualizationInfo getInfoPanel()
          This method must be implemented.
protected  StateSkeleton getState()
          Return internal state.
protected  boolean initAlg()
          Initialize algorithm for solving.
protected  void initComponents()
          Initialize components.
protected abstract  void initState()
          This must be implemented, initialize problem state.
protected  void oneStep()
          Makes one step of algorithm.
protected  void oneStepAndUpdateView()
          Makes one step of algorithm and updates all information components.
 void run()
          Thread is constructed using a separate Runnable run object.
protected  void running(boolean r)
          Set components according to running state.
 void setEnableIDE(boolean e)
          Enables or disables the IDE (all components for input).
 void setViewCurrent(boolean vc)
          This method switch between best and current solution.
 void startAnimation()
          Starts visualization run.
protected  void traverseComponentsSetEnabled(java.awt.Component c, boolean e)
          Traverse container and set enabled to each component.
protected  void updateComponentsByState(savi.visualization.support.SimPanel.STATE s)
          Updates components by current simulation state (definition problem / running simulation).
protected  void updateDisplay()
          Update info panel (display) in dependence of best/current state.
protected  void updateDisplay(StateSkeleton s)
          Update info panel (display) with given state.
protected  void updateView()
          Update visualization panels (alert of state change).
 
Methods inherited from class savi.visualization.support.TaskPanel
getSimulationName
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, checkImage, checkImage, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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

settings

protected java.awt.Panel settings
panel with settings controls


ide

protected java.awt.Panel ide
control environment panel


isRunning

protected boolean isRunning
signalizes running of algorithm


runThread

protected java.lang.Thread runThread
run thread reference


state

protected StateSkeleton state
state of problem


screen

protected VisualizationPanel screen
palace for visualization panel


bestScreen

protected VisualizationPanel bestScreen
panel for vizualization best solution


graph

protected VisualizationGraph graph
graph visualization panel


infoPanel

protected VisualizationInfo infoPanel
help panel


alg

protected SimAnnealingStepSolver alg
algorithm


bestState

protected StateSkeleton bestState
best founded state


viewCurrent

protected boolean viewCurrent
signalizes vizualization visiblity of current or best state

Constructor Detail

SimPanel

public SimPanel(VisualizationPanel vp,
                double startTemp,
                double finalTemp,
                double coolingCoef,
                int innerLoops)
Creates a new instance of SimPanel, initialize SA starting values.

Parameters:
vp - reference to visualization panel
startTemp - starting temperature
finalTemp - final temperature
coolingCoef - cooling coeficient
innerLoops - number of inner loops
Method Detail

initComponents

protected void initComponents()
Initialize components.


getInfoPanel

protected abstract VisualizationInfo getInfoPanel()
This method must be implemented. It should prepare and return help panel.

Returns:
help panel (VisualizationInfo)

addOutputField

protected java.awt.Label addOutputField(java.lang.String title,
                                        java.lang.String baseValue)
Adds output field (label).

Parameters:
title - label caption
baseValue - initial value
Returns:
reference to output label

addInputField

protected java.awt.TextField addInputField(java.lang.String title,
                                           java.lang.String initialValue)
Adds input field (text field).

Parameters:
title - caption
initialValue - initial value
Returns:
reference to created input text field.

addInputButton

protected java.awt.Button addInputButton(java.lang.String title)
Adds button into settings panel.

Parameters:
title - caption
Returns:
button reference

addEmptySpace

protected void addEmptySpace()
Adds empty space for correct alignment.


initState

protected abstract void initState()
This must be implemented, initialize problem state.


getState

protected StateSkeleton getState()
Return internal state.

Returns:
state

updateView

protected void updateView()
Update visualization panels (alert of state change).


initAlg

protected boolean initAlg()
Initialize algorithm for solving.

Returns:
true if algorithm is properly initialized

updateDisplay

protected void updateDisplay(StateSkeleton s)
Update info panel (display) with given state.

Parameters:
s - state

updateDisplay

protected void updateDisplay()
Update info panel (display) in dependence of best/current state.


oneStep

protected void oneStep()
Makes one step of algorithm.


oneStepAndUpdateView

protected void oneStepAndUpdateView()
Makes one step of algorithm and updates all information components.


running

protected void running(boolean r)
Set components according to running state.

Parameters:
r - running state

run

public void run()
Thread is constructed using a separate Runnable run object. The thread is used for animation.

Specified by:
run in interface java.lang.Runnable

startAnimation

public void startAnimation()
Starts visualization run.


traverseComponentsSetEnabled

protected void traverseComponentsSetEnabled(java.awt.Component c,
                                            boolean e)
Traverse container and set enabled to each component. It is recursive method.

Parameters:
c - container to traverse
e - enable value

updateComponentsByState

protected void updateComponentsByState(savi.visualization.support.SimPanel.STATE s)
Updates components by current simulation state (definition problem / running simulation).

Parameters:
s - simulation state

setEnableIDE

public void setEnableIDE(boolean e)
Enables or disables the IDE (all components for input).

Parameters:
e - enables the IDE if true else disable it

setViewCurrent

public void setViewCurrent(boolean vc)
This method switch between best and current solution. Set viewCurrent variable and call activateScreenView.

Parameters:
vc - activates current solution view if true else best solution is activated

activateView

public void activateView(int v)
Activate given view. 1 ... view current / best solution 2 ... graph of optimalization criterion 3 ... help

Parameters:
v - view index

activateScreenView

public void activateScreenView()
This method switch between best and current solution according to viewCurrent variable.


callSaveInstance

public void callSaveInstance()
This method opens File save dialog and save current problem instance.