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.JButtonbuttonReloadAndRun(package private) SimcurentSimulationstatic java.lang.StringDEFAULT_NAMEprivate static java.lang.StringEXIT(package private) javax.swing.JFrameframe(package private) javax.swing.JMenuItemmenuItemDump(package private) javax.swing.JMenuItemmenuItemReloadAndRun(package private) java.util.concurrent.ExecutorServicemultiThreadServiceprivate static java.lang.StringOPEN(package private) javax.swing.JPanelpmain(package private) java.io.FileprevWorkingFile(package private) java.util.Map<java.lang.Integer,RunConfig>runConfigs(package private) booleanshowGui(package private) javax.swing.JLabelstatusLabel(package private) java.util.Map<java.lang.String,java.awt.Rectangle>viewerRects(package private) java.awt.DimensionwindowDimension(package private) java.io.FileworkingFile
-
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 voidactionPerformed(java.awt.event.ActionEvent e)protected voidaddToMenu(java.lang.String[] actions, javax.swing.JMenu jm)protected javax.swing.JMenuItemaddToMenuWithShortcut(java.lang.String action, javax.swing.JMenu jm, int key, int modifier)protected voidclearAll()protected voidclearCurrentSimulation()protected voidcreateToolbar()The toolbar for the control panel - open, layer and run The buttons have matching menu items performing the same actionsprotected abstract SimimportFile(java.io.File sourceFile)Siminitialise(java.io.File file)protected voidloadRunConfigsFromSimulation()load the runConfigs from the simulation into the runConfigs map.protected voidpositionViewers()Lay out the StandaloneViewer windows in aprotected voidregisterSimulation(Sim sim, java.io.File simFile)The control panel handles one simulation at a time, this should be "registered" using this method.protected voidrestoreViewerWindows()protected voidrunSimulationInNewThread()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 voidsetNewWorkingFile(java.io.File newfile)protected voidsetPrevWorkingFile()protected voidsetRunSimulationEnabled(boolean enabled)voidsetTitle(java.lang.String title)voidshow()
-
-
-
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:
ConnectionErrorContentErrorRuntimeErrorParseError
-
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:
actionPerformedin 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()
-
-