org.opensourcephysics.tools
Class DataTool

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.opensourcephysics.display.OSPFrame
                          extended by org.opensourcephysics.tools.DataTool
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.rmi.Remote, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, AppFrame, Hidable, Tool
Direct Known Subclasses:
FourierTool

public class DataTool
extends OSPFrame
implements Tool, java.beans.PropertyChangeListener

This provides a GUI for analyzing OSP Data objects.

Version:
1.0
Author:
Douglas Brown
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JMenuItem aboutItem
           
protected  javax.swing.JMenu addMenu
           
protected static int buttonHeight
           
protected static javax.swing.JFileChooser chooser
           
protected  javax.swing.JMenuItem closeAllItem
           
protected  javax.swing.JMenuItem closeItem
           
protected  javax.swing.JPanel contentPane
           
protected  XMLControl control
           
protected  javax.swing.JMenuItem copyDataItem
           
protected  javax.swing.JMenuItem copyImageItem
           
protected  javax.swing.JMenu copyMenu
           
protected  javax.swing.JMenuItem copyTabItem
           
protected  FunctionTool dataFunctionTool
           
protected static java.awt.Dimension dim
           
protected  javax.swing.JMenu divideMenu
           
protected  javax.swing.JMenu editMenu
           
protected  javax.swing.JMenuItem exitItem
           
protected  javax.swing.JMenu fileMenu
           
protected  java.lang.String helpBase
           
protected  TextFrame helpFrame
           
protected  javax.swing.JMenuItem helpItem
           
protected  javax.swing.JLabel helpLabel
           
protected  javax.swing.JMenu helpMenu
           
protected  java.lang.String helpPath
           
protected  JobManager jobManager
           
static boolean loadClass
           
protected static OSPLog log
           
protected  javax.swing.JMenuItem logItem
           
protected  javax.swing.JMenu multiplyMenu
           
protected  javax.swing.JMenuItem openItem
           
protected  javax.swing.JMenuItem pasteColumnsItem
           
protected  javax.swing.JMenu pasteMenu
           
protected  javax.swing.JMenuItem pasteNewTabItem
           
protected  javax.swing.JMenuItem printItem
           
protected  javax.swing.JMenuItem saveAsItem
           
protected  javax.swing.JMenuItem saveItem
           
protected  javax.swing.JMenu subtractMenu
           
protected  java.beans.PropertyChangeSupport support
           
protected  javax.swing.JTabbedPane tabbedPane
           
protected  boolean useChooser
           
 
Fields inherited from class org.opensourcephysics.display.OSPFrame
animated, autoclear, buttonPanel, childFrames, constructorThreadGroup, customButtons, keepHidden, strategy
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
  DataTool()
          Constructs a blank DataTool.
  DataTool(Data data)
          Constructs a DataTool and loads the specified data object.
  DataTool(Data data, java.lang.String name)
          Constructs a DataTool and loads a data object into a named tab.
  DataTool(java.lang.String fileName)
          Constructs a DataTool and opens the specified xml file.
protected DataTool(java.lang.String title, java.lang.String name)
          Constructs a DataTool with title and name.
  DataTool(XMLControl control)
          Constructs a DataTool and loads data from an xml control.
 
Method Summary
 DataToolTab addTab(Data data)
          Adds a tab for the specified Data object.
 DataToolTab addTab(Data data, java.lang.String name)
          Adds a tab for the specified Data object and proposes a name for the tab.
protected  void addTab(DataToolTab tab)
          Adds a tab.
 DataToolTab addTab(XMLControl control)
          Adds a tab and loads data from an xml control.
protected static javax.swing.JButton createButton(java.lang.String text)
          Creates a button with a specified maximum height.
protected  void createGUI()
          Creates the GUI.
protected  FunctionTool getDataFunctionTool()
          Gets the function tool for defining custom data functions.
protected  DataToolTab getSelectedTab()
          Gets the currently selected DataToolTab, if any.
 DataToolTab getTab(Data data)
          Returns the tab containing the specified Data object.
 DataToolTab getTab(int index)
          Returns the tab at the specified index.
 int getTabCount()
          Returns the tab count.
protected  int getTabIndex(Data data)
          Returns the index of the tab containing the specified Data object.
static DataTool getTool()
          Gets the shared DataTool.
protected  java.lang.String getUniqueName(java.lang.String proposed)
          Gets a unique name.
 boolean isUseChooser()
          Gets the useChooser flag.
protected  DataToolTab loadData(Data data, DataToolTab tab)
          Loads data into a specified tab.
protected  DataToolTab loadData(DataToolTab tab, XMLControl control, boolean useChooser)
          Loads data from an xml control into a specified tab.
protected  java.lang.String open()
          Opens an xml file selected with a chooser.
 java.lang.String open(java.lang.String fileName)
          Opens an xml file specified by name.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Listens for property changes "function" and "visible"
protected  void refreshFunctionTool()
          Refreshes the function tool.
protected  void refreshGUI()
          Refreshes the GUI.
protected  void refreshTabTitles()
           
protected  void removeAllButTab(int index)
          Removes all tabs except the specified index.
protected  void removeAllTabs()
          Removes all tabs.
 DataToolTab removeTab(Data data)
          Adds a tab for the specified Data object.
 void removeTab(int index)
          Removes the tab at the specified index.
protected  java.lang.String save(java.lang.String fileName)
          Saves the current xml control to the specified file.
protected  java.lang.String saveAs()
          Saves the currently displayed xml control to a file selected with a chooser.
 void send(Job job, Tool replyTo)
          Sends a job to this tool and specifies a tool to reply to.
protected  void setSelectedTab(DataToolTab tab)
          Selects a DataToolTab.
 void setUseChooser(boolean useChooser)
          Sets the useChooser flag.
protected  void showAboutDialog()
          Shows the about dialog.
 void update(Data data)
          Updates the data.
 
Methods inherited from class org.opensourcephysics.display.OSPFrame
addButton, addChildFrame, bufferStrategyShow, clearChildFrames, clearData, clearDataAndRepaint, createBufferStrategy, dispose, getChildFrames, getChooser, getConstructorThreadGroup, getMenu, invalidateImage, isAnimated, isAutoclear, isIconified, isKeepHidden, loadDisplayMenu, loadToolsMenu, parseXMLMenu, parseXMLMenu, removeMenu, removeMenuItem, render, setAnimated, setAutoclear, setDefaultCloseOperation, setFontLevel, setKeepHidden, setSize, setTitle, setVisible, show, wishesToExit
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, toBack, 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, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, isOpaque, isPreferredSizeSet, isValid, isVisible, 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, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opensourcephysics.display.AppFrame
getDefaultCloseOperation
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

loadClass

public static boolean loadClass

chooser

protected static javax.swing.JFileChooser chooser

log

protected static OSPLog log

dim

protected static java.awt.Dimension dim

buttonHeight

protected static int buttonHeight

tabbedPane

protected javax.swing.JTabbedPane tabbedPane

useChooser

protected boolean useChooser

contentPane

protected javax.swing.JPanel contentPane

support

protected java.beans.PropertyChangeSupport support

control

protected XMLControl control

jobManager

protected JobManager jobManager

addMenu

protected javax.swing.JMenu addMenu

subtractMenu

protected javax.swing.JMenu subtractMenu

multiplyMenu

protected javax.swing.JMenu multiplyMenu

divideMenu

protected javax.swing.JMenu divideMenu

fileMenu

protected javax.swing.JMenu fileMenu

openItem

protected javax.swing.JMenuItem openItem

saveItem

protected javax.swing.JMenuItem saveItem

saveAsItem

protected javax.swing.JMenuItem saveAsItem

closeItem

protected javax.swing.JMenuItem closeItem

closeAllItem

protected javax.swing.JMenuItem closeAllItem

printItem

protected javax.swing.JMenuItem printItem

exitItem

protected javax.swing.JMenuItem exitItem

editMenu

protected javax.swing.JMenu editMenu

copyMenu

protected javax.swing.JMenu copyMenu

copyImageItem

protected javax.swing.JMenuItem copyImageItem

copyTabItem

protected javax.swing.JMenuItem copyTabItem

copyDataItem

protected javax.swing.JMenuItem copyDataItem

pasteMenu

protected javax.swing.JMenu pasteMenu

pasteNewTabItem

protected javax.swing.JMenuItem pasteNewTabItem

pasteColumnsItem

protected javax.swing.JMenuItem pasteColumnsItem

helpMenu

protected javax.swing.JMenu helpMenu

helpItem

protected javax.swing.JMenuItem helpItem

logItem

protected javax.swing.JMenuItem logItem

aboutItem

protected javax.swing.JMenuItem aboutItem

dataFunctionTool

protected FunctionTool dataFunctionTool

helpLabel

protected javax.swing.JLabel helpLabel

helpFrame

protected TextFrame helpFrame

helpPath

protected java.lang.String helpPath

helpBase

protected java.lang.String helpBase
Constructor Detail

DataTool

public DataTool()
Constructs a blank DataTool.


DataTool

public DataTool(java.lang.String fileName)
Constructs a DataTool and opens the specified xml file.

Parameters:
fileName - the name of the xml file

DataTool

public DataTool(XMLControl control)
Constructs a DataTool and loads data from an xml control.

Parameters:
control - the xml control

DataTool

public DataTool(Data data)
Constructs a DataTool and loads the specified data object.

Parameters:
data - the data

DataTool

public DataTool(Data data,
                java.lang.String name)
Constructs a DataTool and loads a data object into a named tab.

Parameters:
data - the data
name - the tab name

DataTool

protected DataTool(java.lang.String title,
                   java.lang.String name)
Constructs a DataTool with title and name.

Method Detail

getTool

public static DataTool getTool()
Gets the shared DataTool.

Returns:
the shared DataTool

addTab

public DataToolTab addTab(XMLControl control)
Adds a tab and loads data from an xml control.

Parameters:
control - the xml control
Returns:
a collection of newly loaded Data objects

addTab

public DataToolTab addTab(Data data)
Adds a tab for the specified Data object. The tab name will be that of the Data object if it defines a getName() method.

Parameters:
data - the Data
Returns:
the newly added tab

addTab

public DataToolTab addTab(Data data,
                          java.lang.String name)
Adds a tab for the specified Data object and proposes a name for the tab. The name will be modified if not unique.

Parameters:
data - the Data
name - a proposed tab name
Returns:
the newly added tab

removeTab

public DataToolTab removeTab(Data data)
Adds a tab for the specified Data object. The tab name will be that of the Data object if it defines a getName() method.

Parameters:
data - the Data
Returns:
the newly added tab

removeTab

public void removeTab(int index)
Removes the tab at the specified index.

Parameters:
index - the tab number

update

public void update(Data data)
Updates the data.

Parameters:
data - the Data

getTab

public DataToolTab getTab(Data data)
Returns the tab containing the specified Data object. May return null.

Parameters:
data - the Dataset
Returns:
the tab

getTab

public DataToolTab getTab(int index)
Returns the tab at the specified index. May return null.

Parameters:
index - the tab index
Returns:
the tab

getTabCount

public int getTabCount()
Returns the tab count.

Returns:
the number of tabs

open

public java.lang.String open(java.lang.String fileName)
Opens an xml file specified by name.

Parameters:
fileName - the file name
Returns:
the file name, if successfully opened (datasets loaded)

send

public void send(Job job,
                 Tool replyTo)
          throws java.rmi.RemoteException
Sends a job to this tool and specifies a tool to reply to.

Specified by:
send in interface Tool
Parameters:
job - the Job
replyTo - the tool to notify when the job is complete (may be null)
Throws:
java.rmi.RemoteException

setUseChooser

public void setUseChooser(boolean useChooser)
Sets the useChooser flag.

Parameters:
useChooser - true to load datasets with a chooser

isUseChooser

public boolean isUseChooser()
Gets the useChooser flag.

Returns:
true if loading datasets with a chooser

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Listens for property changes "function" and "visible"

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the event

getUniqueName

protected java.lang.String getUniqueName(java.lang.String proposed)
Gets a unique name.

Parameters:
proposed - the proposed name
Returns:
the unique name

loadData

protected DataToolTab loadData(DataToolTab tab,
                               XMLControl control,
                               boolean useChooser)
Loads data from an xml control into a specified tab. If no tab is specified, then a new one is created.

Parameters:
tab - the tab to load (may be null)
control - the xml control describing the data
useChooser - true to present data choices to user
Returns:
the loaded tab

loadData

protected DataToolTab loadData(Data data,
                               DataToolTab tab)
Loads data into a specified tab. If tab is null, a new one is created.

Parameters:
tab - the tab to load (may be null)
Returns:
the loaded tab

addTab

protected void addTab(DataToolTab tab)
Adds a tab. The tab should be named before calling this method.

Parameters:
tab - a DataToolTab

getSelectedTab

protected DataToolTab getSelectedTab()
Gets the currently selected DataToolTab, if any.

Returns:
the selected tab

setSelectedTab

protected void setSelectedTab(DataToolTab tab)
Selects a DataToolTab.

Parameters:
tab - the tab to select

open

protected java.lang.String open()
Opens an xml file selected with a chooser.

Returns:
the name of the opened file

save

protected java.lang.String save(java.lang.String fileName)
Saves the current xml control to the specified file.

Parameters:
fileName - the file name
Returns:
the name of the saved file, or null if not saved

saveAs

protected java.lang.String saveAs()
Saves the currently displayed xml control to a file selected with a chooser.

Returns:
the name of the saved file, or null if not saved

getTabIndex

protected int getTabIndex(Data data)
Returns the index of the tab containing the specified Data object.

Parameters:
data - the Dataset
Returns:
the name of the opened file

removeAllButTab

protected void removeAllButTab(int index)
Removes all tabs except the specified index.

Parameters:
index - the tab number

removeAllTabs

protected void removeAllTabs()
Removes all tabs.


refreshTabTitles

protected void refreshTabTitles()

getDataFunctionTool

protected FunctionTool getDataFunctionTool()
Gets the function tool for defining custom data functions.


refreshFunctionTool

protected void refreshFunctionTool()
Refreshes the function tool.


createGUI

protected void createGUI()
Creates the GUI.


refreshGUI

protected void refreshGUI()
Refreshes the GUI.

Overrides:
refreshGUI in class OSPFrame

showAboutDialog

protected void showAboutDialog()
Shows the about dialog.


createButton

protected static javax.swing.JButton createButton(java.lang.String text)
Creates a button with a specified maximum height.

Parameters:
text - the button text
h - the button height
Returns:
the button