Package org.lemsml.jlems.viz.datadisplay
Class ControlPanel
- java.lang.Object
-
- org.lemsml.jlems.viz.datadisplay.ControlPanel
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.util.EventListener
public abstract class ControlPanel extends java.lang.Object implements java.awt.event.ActionListener
-
-
Field Summary
Fields Modifier and Type Field Description (package private) javax.swing.JButton
buttonReloadAndRun
(package private) Sim
curentSimulation
static java.lang.String
DEFAULT_NAME
private static java.lang.String
EXIT
(package private) javax.swing.JFrame
frame
(package private) javax.swing.JMenuItem
menuItemDump
(package private) javax.swing.JMenuItem
menuItemReloadAndRun
(package private) java.util.concurrent.ExecutorService
multiThreadService
private static java.lang.String
OPEN
(package private) javax.swing.JPanel
pmain
(package private) java.io.File
prevWorkingFile
(package private) java.util.Map<java.lang.Integer,RunConfig>
runConfigs
(package private) boolean
showGui
(package private) javax.swing.JLabel
statusLabel
(package private) java.util.Map<java.lang.String,java.awt.Rectangle>
viewerRects
(package private) java.awt.Dimension
windowDimension
(package private) java.io.File
workingFile
-
Constructor Summary
Constructors Constructor Description ControlPanel(java.lang.String name, boolean showGui)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
protected void
addToMenu(java.lang.String[] actions, javax.swing.JMenu jm)
protected javax.swing.JMenuItem
addToMenuWithShortcut(java.lang.String action, javax.swing.JMenu jm, int key, int modifier)
protected void
clearAll()
protected void
clearCurrentSimulation()
protected void
createToolbar()
The toolbar for the control panel - open, layer and run The buttons have matching menu items performing the same actionsprotected abstract Sim
importFile(java.io.File sourceFile)
Sim
initialise(java.io.File file)
protected void
loadRunConfigsFromSimulation()
load the runConfigs from the simulation into the runConfigs map.protected void
positionViewers()
Lay out the StandaloneViewer windows in aprotected void
registerSimulation(Sim sim, java.io.File simFile)
The control panel handles one simulation at a time, this should be "registered" using this method.protected void
restoreViewerWindows()
protected void
runSimulationInNewThread()
When simulation.run() is called from the actionPerformed method below, it holds up the Java Swing display thread and we don't get the nice animation, so call run() in its own thread here.protected void
setNewWorkingFile(java.io.File newfile)
protected void
setPrevWorkingFile()
protected void
setRunSimulationEnabled(boolean enabled)
void
setTitle(java.lang.String title)
void
show()
-
-
-
Field Detail
-
frame
javax.swing.JFrame frame
-
pmain
javax.swing.JPanel pmain
-
statusLabel
javax.swing.JLabel statusLabel
-
menuItemReloadAndRun
javax.swing.JMenuItem menuItemReloadAndRun
-
menuItemDump
javax.swing.JMenuItem menuItemDump
-
buttonReloadAndRun
javax.swing.JButton buttonReloadAndRun
-
workingFile
java.io.File workingFile
-
prevWorkingFile
java.io.File prevWorkingFile
-
curentSimulation
Sim curentSimulation
-
runConfigs
java.util.Map<java.lang.Integer,RunConfig> runConfigs
-
viewerRects
java.util.Map<java.lang.String,java.awt.Rectangle> viewerRects
-
windowDimension
java.awt.Dimension windowDimension
-
multiThreadService
java.util.concurrent.ExecutorService multiThreadService
-
showGui
boolean showGui
-
OPEN
private static final java.lang.String OPEN
- See Also:
- Constant Field Values
-
EXIT
private static final java.lang.String EXIT
- See Also:
- Constant Field Values
-
DEFAULT_NAME
public static final java.lang.String DEFAULT_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
setTitle
public void setTitle(java.lang.String title)
-
initialise
public Sim initialise(java.io.File file) throws LEMSException
- Throws:
LEMSException
-
registerSimulation
protected void registerSimulation(Sim sim, java.io.File simFile)
The control panel handles one simulation at a time, this should be "registered" using this method. Load all the windows, one per display- Parameters:
sim
- - simulation objectsimFile
- - new file to load (can be null)- Throws:
ConnectionError
ContentError
RuntimeError
ParseError
-
importFile
protected abstract Sim importFile(java.io.File sourceFile) throws LEMSException
- Throws:
LEMSException
-
createToolbar
protected final void createToolbar()
The toolbar for the control panel - open, layer and run The buttons have matching menu items performing the same actions
-
loadRunConfigsFromSimulation
protected void loadRunConfigsFromSimulation()
load the runConfigs from the simulation into the runConfigs map. The runConfigs map is indexed for easy referencing
-
positionViewers
protected void positionViewers()
Lay out the StandaloneViewer windows in a
-
setRunSimulationEnabled
protected final void setRunSimulationEnabled(boolean enabled)
-
addToMenu
protected final void addToMenu(java.lang.String[] actions, javax.swing.JMenu jm)
-
addToMenuWithShortcut
protected final javax.swing.JMenuItem addToMenuWithShortcut(java.lang.String action, javax.swing.JMenu jm, int key, int modifier)
- Parameters:
action
- - The name of the action itemjm
- - the menu for this item to be added tokey
- - int representing the ID of KeyEvent (eg KeyEvent.VK_F6)modifier
- - int representing the ID of ActionEvent (eg ActionEvent.ALT_MASK , 0 for no modifier)- Returns:
- JMenuItem
-
show
public final void show()
-
runSimulationInNewThread
protected void runSimulationInNewThread()
When simulation.run() is called from the actionPerformed method below, it holds up the Java Swing display thread and we don't get the nice animation, so call run() in its own thread here.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
clearCurrentSimulation
protected void clearCurrentSimulation()
-
restoreViewerWindows
protected void restoreViewerWindows()
-
clearAll
protected void clearAll()
-
setNewWorkingFile
protected void setNewWorkingFile(java.io.File newfile)
-
setPrevWorkingFile
protected void setPrevWorkingFile()
-
-