Package org.opensourcephysics.tools
Class FunctionTool
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
org.opensourcephysics.tools.FunctionTool
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,PropertyChangeListener
,Serializable
,EventListener
,Accessible
,RootPaneContainer
,WindowConstants
- Direct Known Subclasses:
DataBuilder
,FitBuilder
,ModelBuilder
,TrackDataBuilder
This tool allows users to create and manage editable Functions.
OSP DataBuilder, DataToolTab.dataBuilder, FitBuilder
Tracker ModelBuilder and TrackDataBuilder
- Author:
- Douglas Brown
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Custom renderer to show name and icon in dropdown list itemsstatic class
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set<DatasetCurveFitter>
protected JToolBar
protected String
protected String
protected int
protected ActionListener
protected String
protected String
static String[]
static String[]
static final String
static final String
static final String
protected boolean
protected FunctionPanel
protected String
protected Map<String,
FunctionPanel> Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
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
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionTool
(Component comp) Constructs a tool for the specified component (may be null)FunctionTool
(Component comp, boolean isFitBuilder, boolean lazyGUI) Constructor allowing for a fitBuilder flag and lazyGUI option -
Method Summary
Modifier and TypeMethodDescriptionvoid
addForbiddenNames
(String[] names) Adds names to the forbidden set.void
addPanel
(String name, FunctionPanel panel) Adds a FunctionPanel.static boolean
arrayContains
(String[] s, String name) void
checkGUI()
void
Clears all FunctionPanels.protected void
Creates the GUI.void
dispose()
protected void
firePropertyChange
(String name, Object oldObj, Object newObj) Fires a property change.void
int
Gets the font level.static XML.ObjectLoader
Returns an ObjectLoader to save and load data for this class.Returns the named FunctionPanel.Returns the set of all panel names.protected String
Gets the selected dropdown item name.Returns the name of the selected FunctionPanel.Returns the selected FunctionPanel.Gets the toolbar.Gets the custom buttons or other components.protected String
getUniqueName
(String proposedName) Gets a unique name.boolean
protected boolean
haveGUI()
protected void
init()
boolean
isEmpty()
Reports if this is empty.static boolean
isReservedName
(String name) Returns true if name is reserved by the OSP parser.boolean
Overrides JDialog isVisible method.void
Responds to property change events from TrackerPanel.void
refreshDropdown
(String name) Refreshes the dropdown and selects a specified panel.protected void
Refreshes the GUI.removePanel
(String name) Removes a named FunctionPanel.renamePanel
(String prevName, String newName) Renames a FunctionPanel.void
setButtonBar
(Object[] btns) void
setDefaultVariables
(String[] vars) Sets the independent variables of all function panels.void
setFontLevel
(int level) Sets the font level.void
setHelpAction
(ActionListener action) Sets the help action.void
setHelpPath
(String path) Sets the path of the help file.void
setSelectedPanel
(String name) Selects a FunctionPanel by name.protected void
void
setToolbarComponents
(Component[] toolbarItems) Sets the custom buttons or other components.void
setVisible
(boolean vis) Overrides JDialog setVisible method.Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, 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, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
PROPERTY_FUNCTIONTOOL_PANEL
- See Also:
-
PROPERTY_FUNCTIONTOOL_VISIBLE
- See Also:
-
PROPERTY_FUNCTIONTOOL_FUNCTION
- See Also:
-
parserNames
-
parserOperators
-
forbiddenNames
-
curveFitters
-
trackFunctionPanels
-
selectedPanel
-
helpPath
-
helpBase
-
helpAction
-
fontLevel
protected int fontLevel -
refreshing
protected boolean refreshing -
dropdownbar
-
dropdownTipText
-
titleText
-
dropdownLabelText
-
-
Constructor Details
-
FunctionTool
Constructs a tool for the specified component (may be null)- Parameters:
comp
- Component used to get Frame owner of this Dialog
-
FunctionTool
Constructor allowing for a fitBuilder flag and lazyGUI option- Parameters:
comp
-isFitBuilder
-lazyGUI
-
-
-
Method Details
-
checkGUI
public void checkGUI() -
init
protected void init() -
haveGUI
protected boolean haveGUI() -
createGUI
protected void createGUI()Creates the GUI. -
setTitles
protected void setTitles() -
refreshGUI
protected void refreshGUI()Refreshes the GUI. -
setToolbarComponents
Sets the custom buttons or other components.- Parameters:
toolbarItems
- an array of components (may be null)
-
getToolbarComponents
Gets the custom buttons or other components.- Returns:
- an array of components (may be null)
-
getToolbar
Gets the toolbar.- Returns:
- the toolbar
-
addPanel
Adds a FunctionPanel.- Parameters:
name
- a descriptive namepanel
- the FunctionPanel
-
removePanel
Removes a named FunctionPanel.- Parameters:
name
- the name- Returns:
- the removed panel, if any
-
renamePanel
Renames a FunctionPanel.- Parameters:
prevName
- the previous namenewName
- the new name- Returns:
- the renamed panel
-
setSelectedPanel
Selects a FunctionPanel by name.- Parameters:
name
- the name
-
getSelectedName
Returns the name of the selected FunctionPanel.- Returns:
- the name
-
getSelectedPanel
Returns the selected FunctionPanel.- Returns:
- the FunctionPanel
-
getPanel
Returns the named FunctionPanel.- Parameters:
name
- the name- Returns:
- the FunctionPanel
-
getPanelNames
Returns the set of all panel names.- Returns:
- a set of names
-
clearPanels
public void clearPanels()Clears all FunctionPanels. -
propertyChange
Responds to property change events from TrackerPanel.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
e
- the property change event
-
addForbiddenNames
Adds names to the forbidden set.- Parameters:
names
- the names to add
-
setVisible
public void setVisible(boolean vis) Overrides JDialog setVisible method.- Overrides:
setVisible
in classDialog
- Parameters:
vis
- true to show this tool
-
isVisible
public boolean isVisible()Overrides JDialog isVisible method. -
setHelpPath
Sets the path of the help file.- Parameters:
path
- a filename or url
-
setHelpAction
Sets the help action. this will replace the current help action- Parameters:
action
- a custom help action
-
isEmpty
public boolean isEmpty()Reports if this is empty.- Returns:
- true if empty
-
setFontLevel
public void setFontLevel(int level) Sets the font level.- Parameters:
level
- the level
-
getFontLevel
public int getFontLevel()Gets the font level.- Returns:
- the level
-
setDefaultVariables
Sets the independent variables of all function panels.- Parameters:
vars
- the independent variable names
-
firePropertyChange
Fires a property change. This makes this method visible to the tools package.- Overrides:
firePropertyChange
in classComponent
-
getSelectedDropdownName
Gets the selected dropdown item name.- Returns:
- the selected name
-
refreshDropdown
Refreshes the dropdown and selects a specified panel. If name is null, the current selection is retained if possible.- Parameters:
name
- the name of the panel to select
-
getUniqueName
Gets a unique name.- Parameters:
proposedName
- the proposed name- Returns:
- the unique name
-
getLoader
Returns an ObjectLoader to save and load data for this class.- Returns:
- the object loader
-
setButtonBar
-
hasButton
-
focusHelp
public void focusHelp() -
dispose
public void dispose() -
arrayContains
-
isReservedName
Returns true if name is reserved by the OSP parser.- Parameters:
name
- the proposed name- Returns:
- true if reserved
-