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  Data addableData
           
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  XMLControlElement control
           
protected  boolean controlContainsData
           
protected  javax.swing.JMenuItem copyDataItem
           
protected  javax.swing.JMenuItem copyImageItem
           
protected  javax.swing.JMenu copyMenu
           
protected  javax.swing.JMenuItem copyTabItem
           
protected  FunctionTool dataBuilder
           
protected static int defaultButtonHeight
           
protected  javax.swing.JMenuItem defaultFontSizeItem
           
protected static java.lang.String[] delimiters
           
protected static java.awt.Dimension dim
           
protected  javax.swing.JMenu displayMenu
           
protected  javax.swing.JMenu editMenu
           
protected  javax.swing.JMenu emptyEditMenu
           
protected  javax.swing.JMenuItem emptyExitItem
           
protected  javax.swing.JMenu emptyFileMenu
           
protected  javax.swing.JMenuBar emptyMenubar
           
protected  javax.swing.JMenuItem emptyNewTabItem
           
protected  javax.swing.JMenuItem emptyOpenItem
           
protected  javax.swing.JMenuItem emptyPasteItem
           
protected  javax.swing.JMenuItem exitItem
           
protected  boolean exitOnClose
           
protected  javax.swing.JMenuItem exportItem
           
protected  javax.swing.JMenu fileMenu
           
protected  int fontLevel
           
protected  javax.swing.JMenu fontSizeMenu
           
protected static java.lang.String helpBase
           
protected static TextFrame helpFrame
           
protected  javax.swing.JMenuItem helpItem
           
protected  javax.swing.JMenu helpMenu
           
protected static java.lang.String helpName
           
protected  javax.swing.JMenuItem importItem
           
protected  javax.swing.JMenuItem[] languageItems
           
protected  javax.swing.JMenu languageMenu
           
static boolean loadClass
           
protected  javax.swing.JMenuItem logItem
           
protected  javax.swing.JMenuBar menubar
           
protected  javax.swing.JMenuItem newTabItem
           
protected  javax.swing.JMenuItem openItem
           
protected  javax.swing.JMenuItem pasteColumnsItem
           
protected  javax.swing.JMenu pasteMenu
           
protected  javax.swing.JMenuItem pasteTabItem
           
protected  javax.swing.JMenuItem printItem
           
protected  javax.swing.JMenuItem redoItem
           
protected  javax.swing.JMenuItem saveAsItem
           
protected  boolean saveChangesOnClose
           
protected  javax.swing.JMenuItem saveItem
           
protected  java.beans.PropertyChangeSupport support
           
protected  javax.swing.JTabbedPane tabbedPane
           
protected  javax.swing.JMenuItem undoItem
           
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(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
 void addTab(DataToolTab tab)
          Adds a tab.
 java.util.ArrayList<DataToolTab> addTabs(XMLControl control)
          Adds tabs loaded with data from an xml control.
 void clearData()
          Clears data by removing all tabs.
protected static boolean containsDuplicateValues(double[] values)
          Determines if an array contains any duplicate or Double.NaN values.
protected static void copy(java.lang.String text)
          Copies text to the clipboard.
protected static javax.swing.JButton createButton(java.lang.String text)
          Creates a button with a specified text.
protected  void createGUI()
          Creates the GUI.
static java.util.ArrayList<DataToolTab> createTabs(Data source)
          Creates a tab for each Data object returned by DataTool.getDataList(source).
protected static java.util.ArrayList<DataColumn> getAllDataColumns(Data source)
          Gets a list of all DataColumns from any Data object.
static java.util.ArrayList<Dataset> getAllDatasets(Data source)
          Gets a list of all Datasets from any Data object.
protected  FunctionTool getDataBuilder()
          Gets the data builder for defining custom data functions.
protected static java.util.ArrayList<DataColumn> getDataColumns(Data source)
          Gets a list of DataColumns from a self-contained Data object.
static java.util.ArrayList<Dataset> getDatasets(Data source)
          Gets a list of Datasets from a self-contained source Data object.
protected static int getIndex(double value, double[] array, int ignoreIndex)
          Gets the first array index at which the specified value is found.
protected static double[] getRowArray(int rowCount)
          Returns an array of row numbers.
 DataToolTab getSelectedTab()
          Gets the currently selected DataToolTab, if any.
protected static java.util.ArrayList<Data> getSelfContainedData(Data container)
          Gets a list of self-contained Data objects.
 DataToolTab getTab(Data data)
          Returns the tab associated with 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.
protected  int getTabIndex(DataToolTab tab)
          Returns the index of a specified tab.
static DataTool getTool()
          Gets the shared DataTool.
protected  java.lang.String getUniqueTabName(java.lang.String proposed)
          Gets a unique name.
protected  boolean hasPastableColumns(DataToolTab tab)
          Determines if the clipboard has columns that are pastable into a specified tab.
protected  boolean hasPastableData()
          Determines if the clipboard has pastable data.
protected  java.lang.String importFileIntoTab(DataToolTab tab)
          Imports an xml or data file selected with a chooser into a specified tab.
 java.lang.String importFileIntoTab(DataToolTab tab, java.lang.String fileName)
          Imports an xml or data file into an existing tab.
protected static double[] insert(double input, double[] array, int trend)
          Inserts a specified value into an array.
 boolean isUseChooser()
          Gets the useChooser flag.
 DataToolTab loadData(Data... data)
          Loads multiple Data objects into a single existing or newly created tab.
 java.util.ArrayList<DataToolTab> loadData(Data data)
          Loads a Data object into existing tabs and/or newly created tabs as needed.
static void main(java.lang.String[] args)
          Main entry point when used as application.
protected  java.lang.String open()
          Opens an xml or data file selected with a chooser.
 java.lang.String open(java.lang.String fileName)
          Opens an xml or data file specified by name.
static DatasetManager parseData(java.lang.String dataString, java.lang.String fileName)
          Parses character-delimited data from a string.
protected static double[] parseDoubles(java.lang.String[] strings)
          Parses a String array into doubles.
protected static double[] parseDoubles(java.lang.String text, java.lang.String delimiter)
          Parses a String into doubles separated by a specified delimiter.
protected static double[][] parseDoubles(java.lang.String text, java.lang.String rowDelimiter, java.lang.String colDelimiter)
          Parses a String into doubles separated by specified row and column delimiters.
protected static java.lang.String[] parseStrings(java.lang.String text, java.lang.String delimiter)
          Parses a String into tokens separated by a specified delimiter.
protected static java.lang.String[][] parseStrings(java.lang.String text, java.lang.String rowDelimiter, java.lang.String colDelimiter)
          Parses a String into tokens separated by specified row and column delimiters.
protected static java.lang.String paste()
          Pastes from the clipboard and returns the pasted string.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Listens for property changes "function"
protected  java.lang.String readFirstLine(java.io.Reader in)
           
protected  void refreshDataBuilder()
          Refreshes the data builder.
protected  void refreshGUI()
          Refreshes the GUI.
protected  void refreshMenubar()
           
protected  void refreshTabTitles()
           
protected  boolean removeAllButTab(int index)
          Removes all tabs except the specified index.
protected  boolean removeAllTabs()
          Removes all tabs.
 DataToolTab removeTab(DataToolTab tab)
          Removes a specified tab.
 DataToolTab removeTab(int index, boolean saveChanges)
          Removes the tab at the specified index.
protected  java.lang.String save(DataToolTab tab, java.lang.String fileName)
          Saves a tab to the specified file.
protected  java.lang.String save(java.lang.String fileName)
          Saves the current tab to the specified file.
protected  java.lang.String saveAs()
          Saves the current tab to a file selected with a chooser.
protected  boolean saveChangesAt(int i)
          Offers to save changes to the tab at the specified index.
 void send(Job job, Tool replyTo)
          Sends a job to this tool and specifies a tool to reply to.
 void setDefaultCloseOperation(int operation)
          Overrides OSPFrame method.
 void setFontLevel(int level)
          Sets the font level.
 void setSaveChangesOnClose(boolean save)
          Sets the saveChangesOnClose flag.
 void setSelectedTab(DataToolTab tab)
          Selects a DataToolTab.
 void setUseChooser(boolean useChooser)
          Sets the useChooser flag.
protected  void showAboutDialog()
          Shows the about dialog.
protected static void showHelp(java.lang.String fileName)
          Shows the help frame and displays the specified help file.
protected static java.lang.String write(java.lang.String text, java.lang.String fileName)
          Writes text to a file with the specified name.
protected static void write(java.lang.String text, java.io.Writer out)
          Writes text to a Writer.
 
Methods inherited from class org.opensourcephysics.display.OSPFrame
addButton, addChildFrame, bufferStrategyShow, clearChildFrames, clearDataAndRepaint, createBufferStrategy, dispose, getChildFrames, getChooser, getConstructorThreadGroup, getMenu, invalidateImage, isAnimated, isAutoclear, isIconified, isKeepHidden, loadDisplayMenu, loadToolsMenu, parseXMLMenu, parseXMLMenu, removeMenu, removeMenuItem, render, setAnimated, setAutoclear, 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, 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, paint, 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

dim

protected static java.awt.Dimension dim

defaultButtonHeight

protected static final int defaultButtonHeight
See Also:
Constant Field Values

buttonHeight

protected static int buttonHeight

delimiters

protected static java.lang.String[] delimiters

helpFrame

protected static TextFrame helpFrame

helpName

protected static java.lang.String helpName

helpBase

protected static java.lang.String helpBase

tabbedPane

protected javax.swing.JTabbedPane tabbedPane

useChooser

protected boolean useChooser

contentPane

protected javax.swing.JPanel contentPane

support

protected java.beans.PropertyChangeSupport support

control

protected XMLControlElement control

addableData

protected Data addableData

controlContainsData

protected boolean controlContainsData

emptyMenubar

protected javax.swing.JMenuBar emptyMenubar

emptyFileMenu

protected javax.swing.JMenu emptyFileMenu

emptyNewTabItem

protected javax.swing.JMenuItem emptyNewTabItem

emptyOpenItem

protected javax.swing.JMenuItem emptyOpenItem

emptyExitItem

protected javax.swing.JMenuItem emptyExitItem

emptyEditMenu

protected javax.swing.JMenu emptyEditMenu

emptyPasteItem

protected javax.swing.JMenuItem emptyPasteItem

menubar

protected javax.swing.JMenuBar menubar

fileMenu

protected javax.swing.JMenu fileMenu

newTabItem

protected javax.swing.JMenuItem newTabItem

openItem

protected javax.swing.JMenuItem openItem

importItem

protected javax.swing.JMenuItem importItem

exportItem

protected javax.swing.JMenuItem exportItem

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

undoItem

protected javax.swing.JMenuItem undoItem

redoItem

protected javax.swing.JMenuItem redoItem

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

pasteTabItem

protected javax.swing.JMenuItem pasteTabItem

pasteColumnsItem

protected javax.swing.JMenuItem pasteColumnsItem

displayMenu

protected javax.swing.JMenu displayMenu

languageMenu

protected javax.swing.JMenu languageMenu

languageItems

protected javax.swing.JMenuItem[] languageItems

fontSizeMenu

protected javax.swing.JMenu fontSizeMenu

defaultFontSizeItem

protected javax.swing.JMenuItem defaultFontSizeItem

helpMenu

protected javax.swing.JMenu helpMenu

helpItem

protected javax.swing.JMenuItem helpItem

logItem

protected javax.swing.JMenuItem logItem

aboutItem

protected javax.swing.JMenuItem aboutItem

dataBuilder

protected FunctionTool dataBuilder

fontLevel

protected int fontLevel

exitOnClose

protected boolean exitOnClose

saveChangesOnClose

protected boolean saveChangesOnClose
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

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

main

public static void main(java.lang.String[] args)
Main entry point when used as application.

Parameters:
args - args[0] may be a data or xml file name

setSaveChangesOnClose

public void setSaveChangesOnClose(boolean save)
Sets the saveChangesOnClose flag.

Parameters:
save - true to save changes when exiting

addTabs

public java.util.ArrayList<DataToolTab> addTabs(XMLControl control)
Adds tabs loaded with data from an xml control.

Parameters:
control - the xml control
Returns:
a list of newly added tabs, or null if failed

createTabs

public static java.util.ArrayList<DataToolTab> createTabs(Data source)
Creates a tab for each Data object returned by DataTool.getDataList(source). The tab names will be those of the Data objects in the list if they define a getName() method.

Parameters:
source - the source Data
Returns:
a list of new tabs

removeTab

public DataToolTab removeTab(int index,
                             boolean saveChanges)
Removes the tab at the specified index.

Parameters:
index - the tab number
Returns:
the removed tab, or null if none removed

removeTab

public DataToolTab removeTab(DataToolTab tab)
Removes a specified tab.

Parameters:
tab - the tab
Returns:
the removed tab, or null if none removed

loadData

public java.util.ArrayList<DataToolTab> loadData(Data data)
Loads a Data object into existing tabs and/or newly created tabs as needed.

Parameters:
data - the Data
Returns:
a list of the loaded tabs

loadData

public DataToolTab loadData(Data... data)
Loads multiple Data objects into a single existing or newly created tab.

Parameters:
data - one or more Data objects
Returns:
the loaded tab

getTab

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

Parameters:
data - the Data
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 or data file specified by name.

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

importFileIntoTab

public java.lang.String importFileIntoTab(DataToolTab tab,
                                          java.lang.String fileName)
Imports an xml or data file into an existing tab.

Parameters:
tab - the tab
fileName - the file name
Returns:
the file name, if successfully imported (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"

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

containsDuplicateValues

protected static boolean containsDuplicateValues(double[] values)
Determines if an array contains any duplicate or Double.NaN values.

Parameters:
values - the array
Returns:
true if at least one duplicate is found

getIndex

protected static int getIndex(double value,
                              double[] array,
                              int ignoreIndex)
Gets the first array index at which the specified value is found.

Parameters:
value - the value to find
array - the array to search
ignoreIndex - an array index to ignore
Returns:
the index, or -1 if not found

getRowArray

protected static double[] getRowArray(int rowCount)
Returns an array of row numbers.

Parameters:
rowCount - length of the array
Returns:
the array

parseStrings

protected static java.lang.String[] parseStrings(java.lang.String text,
                                                 java.lang.String delimiter)
Parses a String into tokens separated by a specified delimiter. A token may be "".

Parameters:
text - the text to parse
delimiter - the delimiter
Returns:
an array of String tokens

parseDoubles

protected static double[] parseDoubles(java.lang.String text,
                                       java.lang.String delimiter)
Parses a String into doubles separated by a specified delimiter. Unparsable strings are set to Double.NaN.

Parameters:
text - the text to parse
delimiter - the delimiter
Returns:
an array of doubles

parseDoubles

protected static double[] parseDoubles(java.lang.String[] strings)
Parses a String array into doubles. Unparsable strings are set to Double.NaN.

Parameters:
strings - the String array to parse
Returns:
an array of doubles

parseStrings

protected static java.lang.String[][] parseStrings(java.lang.String text,
                                                   java.lang.String rowDelimiter,
                                                   java.lang.String colDelimiter)
Parses a String into tokens separated by specified row and column delimiters.

Parameters:
text - the text to parse
rowDelimiter - the column delimiter
colDelimiter - the column delimiter
Returns:
a 2D array of String tokens

parseDoubles

protected static double[][] parseDoubles(java.lang.String text,
                                         java.lang.String rowDelimiter,
                                         java.lang.String colDelimiter)
Parses a String into doubles separated by specified row and column delimiters.

Parameters:
text - the text to parse
rowDelimiter - the column delimiter
colDelimiter - the column delimiter
Returns:
a 2D array of doubles

parseData

public static DatasetManager parseData(java.lang.String dataString,
                                       java.lang.String fileName)
Parses character-delimited data from a string. This attempts to extract the following information from the string: 1. A title to be used for the tab name 2. One or more columns of double data values 3. Column names for the data columns

Parameters:
dataString - the data string
fileName - name of file containing the data string (may be null)
Returns:
DatasetManager with parsed data, or null if none found

readFirstLine

protected java.lang.String readFirstLine(java.io.Reader in)

getUniqueTabName

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

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

getDatasets

public static java.util.ArrayList<Dataset> getDatasets(Data source)
Gets a list of Datasets from a self-contained source Data object.

Parameters:
source - the self-contained Data
Returns:
a list of Datasets

getAllDatasets

public static java.util.ArrayList<Dataset> getAllDatasets(Data source)
Gets a list of all Datasets from any Data object.

Parameters:
source - a self-contained or container Data object
Returns:
a list of all Datasets

getSelfContainedData

protected static java.util.ArrayList<Data> getSelfContainedData(Data container)
Gets a list of self-contained Data objects.

Parameters:
container - the container Data
Returns:
a list of self-contained Data objects

getDataColumns

protected static java.util.ArrayList<DataColumn> getDataColumns(Data source)
Gets a list of DataColumns from a self-contained Data object.

Parameters:
source - a self-contained Data object
Returns:
a list of DataColumns

getAllDataColumns

protected static java.util.ArrayList<DataColumn> getAllDataColumns(Data source)
Gets a list of all DataColumns from any Data object.

Parameters:
source - a self-contained or container Data object
Returns:
a list of all DataColumns

insert

protected static double[] insert(double input,
                                 double[] array,
                                 int trend)
Inserts a specified value into an array.

Parameters:
input - the value to insert
array - the array into which the value is inserted
trend - positive if array is ascending, negative if descending, 0 if neither
Returns:
an array containing the inserted value

addTab

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

Parameters:
tab - a DataToolTab

saveChangesAt

protected boolean saveChangesAt(int i)
Offers to save changes to the tab at the specified index.

Parameters:
i - the tab index
Returns:
true unless canceled by the user

getSelectedTab

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

Returns:
the selected tab

setSelectedTab

public void setSelectedTab(DataToolTab tab)
Selects a DataToolTab.

Parameters:
tab - the tab to select

clearData

public void clearData()
Clears data by removing all tabs.

Overrides:
clearData in class OSPFrame

setFontLevel

public void setFontLevel(int level)
Sets the font level.

Overrides:
setFontLevel in class OSPFrame
Parameters:
level - the level

write

protected static java.lang.String write(java.lang.String text,
                                        java.lang.String fileName)
Writes text to a file with the specified name.

Parameters:
text - the text
fileName - the file name
Returns:
the path of the saved document or null if failed

write

protected static void write(java.lang.String text,
                            java.io.Writer out)
Writes text to a Writer.

Parameters:
text - the text
out - the Writer

open

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

Returns:
the name of the opened file

importFileIntoTab

protected java.lang.String importFileIntoTab(DataToolTab tab)
Imports an xml or data file selected with a chooser into a specified tab.

Parameters:
tab - the tab to import into
Returns:
the name of the imported file

save

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

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

save

protected java.lang.String save(DataToolTab tab,
                                java.lang.String fileName)
Saves a tab to the specified file.

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

saveAs

protected java.lang.String saveAs()
Saves the current tab 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 Data
Returns:
the index, or -1 if not found

getTabIndex

protected int getTabIndex(DataToolTab tab)
Returns the index of a specified tab.

Parameters:
tab - the tab
Returns:
the index, or -1 if not found

removeAllButTab

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

Parameters:
index - the tab number
Returns:
true if tabs removed

removeAllTabs

protected boolean removeAllTabs()
Removes all tabs.

Returns:
true if all tabs removed

refreshTabTitles

protected void refreshTabTitles()

refreshMenubar

protected void refreshMenubar()

getDataBuilder

protected FunctionTool getDataBuilder()
Gets the data builder for defining custom data functions.


refreshDataBuilder

protected void refreshDataBuilder()
Refreshes the data builder.


copy

protected static void copy(java.lang.String text)
Copies text to the clipboard.

Parameters:
text - the string to copy

paste

protected static java.lang.String paste()
Pastes from the clipboard and returns the pasted string.

Returns:
the pasted string, or null if none

showHelp

protected static void showHelp(java.lang.String fileName)
Shows the help frame and displays the specified help file.

Parameters:
fileName - the name of the help file

setDefaultCloseOperation

public void setDefaultCloseOperation(int operation)
Overrides OSPFrame method. This converts EXIT_ON_CLOSE to DO_NOTHING_ON_CLOSE and sets the exitOnClose flag.

Specified by:
setDefaultCloseOperation in interface AppFrame
Overrides:
setDefaultCloseOperation in class OSPFrame
Parameters:
operation - the operation
See Also:
AppFrame.getDefaultCloseOperation()

createGUI

protected void createGUI()
Creates the GUI.


refreshGUI

protected void refreshGUI()
Refreshes the GUI.

Overrides:
refreshGUI in class OSPFrame

hasPastableData

protected boolean hasPastableData()
Determines if the clipboard has pastable data.

Returns:
true if data is pastable

hasPastableColumns

protected boolean hasPastableColumns(DataToolTab tab)
Determines if the clipboard has columns that are pastable into a specified tab.

Parameters:
tab - the tab
Returns:
true if clipboard has pastable columns

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 text.

Parameters:
text - the button text
Returns:
the button