net.talvi.puffinplot
Class PuffinApp

java.lang.Object
  extended by net.talvi.puffinplot.PuffinApp

public final class PuffinApp
extends java.lang.Object

This class constitutes the main PuffinPlot application. Instantiating it starts the PuffinPlot desktop application and opens the main window. Most of PuffinApp's functionality involves interfacing the user interface to the classes which handle the actual data. Most of the actions defined in PuffinActions act as thin wrappers around one or a few calls to PuffinApp. Most of PuffinApp's interaction with the data is via the Suite, Site, and Sample classes.


Nested Class Summary
 class PuffinApp.Version
           
 
Constructor Summary
PuffinApp()
          Instantiates a new PuffinPlot application object.
 
Method Summary
 void about()
          Shows the application's ‘About’ dialog box, giving brief information about PuffinPlot.
 void calculateGreatCirclesDirections(boolean popUpWindow)
          For all selected sites, calculates the site mean direction by best-fit intersection of great circles fitted to that site's samples.
 void calculateMultiSuiteMeans()
           
 void clearAmsCalcs()
          Clears the results of any AMS calculations for the current suite.
 void clearPreferences()
          Shows a confirmation dialog.
 void clearSiteCalculations()
          Clears any previously calculated Fisherian or great-circle site directions.
 void closeCurrentSuite()
          Closes the suite whose data is currently being displayed.
 void copyPointSelection()
          Copies the current pattern of selected points to a clipboard.
 void doAmsCalc(Suite.AmsCalcType calcType, java.lang.String scriptName)
          Performs statistical calculations on AMS data using a script from Lisa Tauxe's pmagpy software suite.
 void doPcaOnSelection()
          For all selected samples, determine a best-fit line to the selected points by principal component analysis.
 void errorDialog(java.lang.String title, PuffinUserException ex)
          Displays a dialog box reporting an error.
 void errorDialog(java.lang.String title, java.lang.String message)
          Displays a dialog box reporting an error.
 void exportPdfFreehep(java.io.File pdfFile)
          Writes a PDF file containing data plots with the current layout for all selected samples.
 void exportPdfItext(java.io.File pdfFile)
          Writes a PDF file containing data plots with the current layout for all selected samples.
 void fitGreatCirclesToSelection()
          For all selected samples, fit a great circle to the selected points.
 void flipSelectedSamples(MeasurementAxis axis)
          For all selected samples, rotates magnetization data 180° around the specified axis.
 PuffinActions getActions()
          Returns the actions associated with this PuffinApp.
 java.util.List<Sample> getAllSamplesInSelectedSites()
          Gets all the samples in all the sites having at least one selected sample.
 java.lang.String getBuildProperty(java.lang.String key)
          Reads values from the build.properties file.
 CiteWindow getCiteWindow()
          Returns this PuffinApp's citation window
 Correction getCorrection()
          Returns the correction currently being applied to the data displayed by this PuffinApp.
 CorrectionWindow getCorrectionWindow()
          Returns the window for user editing of correction data (sample orientation, formation orientation, geomagnetic declination)
 java.awt.print.PageFormat getCurrentPageFormat()
          Returns the current page format.
 Site getCurrentSite()
          Returns the site for which data is currently being displayed.
static PuffinApp getInstance()
          Returns the single instance of PuffinApp.
 MainWindow getMainWindow()
          Returns this PuffinApp's main window
 int getOsxPointVersion()
          If this PuffinApp is running on Mac OS X, this method returns the point version (minor version) of the operating system.
 PuffinPrefs getPrefs()
          Returns the preferences for this PuffinApp.
 RecentFileList getRecentFiles()
          Returns the list of recently used files.
 Sample getSample()
          Gets the current Sample
 java.util.List<Sample> getSelectedSamples()
          Gets all the currently selected samples.
 java.util.List<Site> getSelectedSites()
          Gets all the sites containing any of the currently selected samples.
 SiteMeanWindow getSiteEqAreaWindow()
          Returns the great-circle statistics window.
 Suite getSuite()
          Returns the current Suite.
 SuiteEqAreaWindow getSuiteEqAreaWindow()
          Returns the suite equal-area plot window.
 java.util.List<Suite> getSuites()
          Returns all the Suites currently open within this PuffinApp.
 TableWindow getTableWindow()
          Returns the data table window.
 PuffinApp.Version getVersion()
           
 void importAmsWithDialog()
          Shows an open files dialog box; if the user selects any files, AMS data will be imported from them.
 void importPreferencesWithDialog()
          Shows an open file dialog box; if the user select a file, the current preferences will be overwritten with preferences data from that file.
 void importTabularDataWithFormat(FileFormat format)
           
 boolean isEmptyCorrectionActive()
          Reports whether the empty-slot correction is currently active.
 boolean isOnOsX()
          Reports whether this PuffinApp is running on Mac OS X.
static void main(java.lang.String[] args)
          Instantiates and starts a new PuffinApp.
 void openFiles(java.util.List<java.io.File> files)
           
 void openFiles(java.util.List<java.io.File> files, FileFormat format)
          Creates a new suite and reads data into it from the specified files.
 void openFilesWithDialog()
          Shows an ‘open files’ dialog box; if the user selects any files, they will be opened in a new suite.
 void openWebPage(java.lang.String uriString)
           
 void pastePointSelection()
          For each selected sample, selects the points corresponding to those last copied to the clipboard.
 void quit()
          Terminates this instance of PuffinApp immediately.
 void redoCalculations()
          Recalculates all sample and site calculations in all currently open suites; intended to be called when the correction (none/sample/formation) has changed.
 void rescaleMagSus()
          Scales all magnetic susceptibility values in the current suite by a user-specified factor.
 void runPythonScript(java.lang.String scriptPath)
          Runs a specified Python script
 void runPythonScriptWithDialog()
          Opens a file selection dialog and runs the Python script (if any) which the user selects from that dialog.
 void setCorrection(Correction correction)
          Sets the correction to apply to the displayed data.
 void setEmptyCorrectionActive(boolean b)
          Activates or deactivates the empty-slot correction.
 void setRecentFiles(RecentFileList recentFiles)
          Sets the list of recently used files (allowing it to be restored after restarting the application).
 void setSuite(int index)
          Sets the currently displayed Suite.
 void showCustomFlagsWindow()
          Shows the window for editing the titles of the custom flags.
 void showCustomNotesWindow()
          Shows the window for editing the titles of the custom notes.
 void showPageSetupDialog()
          Opens the page setup dialog box.
 void showPreferences()
          Opens the preferences window.
 void showTabularImportDialog()
           
 void updateDisplay()
          Updates the main window and table window to reflect any changes in the currently displayed data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PuffinApp

public PuffinApp()
Instantiates a new PuffinPlot application object. Instantiating PuffinApp will cause the main PuffinPlot window to be opened immediately.

Method Detail

main

public static void main(java.lang.String[] args)
Instantiates and starts a new PuffinApp.

Parameters:
args - command-line arguments for the application

isOnOsX

public boolean isOnOsX()
Reports whether this PuffinApp is running on Mac OS X.

Returns:
true if this PuffinApp is running on Mac OS X

getOsxPointVersion

public int getOsxPointVersion()
If this PuffinApp is running on Mac OS X, this method returns the point version (minor version) of the operating system. Thus, for example, it would return 5 if the PuffinApp is running on Mac OS X version 10.5 or any sub-version thereof (10.5.1, 10.5.2, etc.). If PuffinApp is not running on Mac OS X, or if the version cannot be determined, this method returns −1.

Returns:
the OS X minor version number, or −1 if it cannot be determined

getInstance

public static PuffinApp getInstance()
Returns the single instance of PuffinApp. Only one instance of PuffinApp can exist at a time, and it may always be found using this method.

Returns:
the single instance of PuffinApp

isEmptyCorrectionActive

public boolean isEmptyCorrectionActive()
Reports whether the empty-slot correction is currently active. The empty-slot correction is not currently used, and this method is reserved for a future re-implementation of the feature.

Returns:
true if the empty-slot correction is active

setEmptyCorrectionActive

public void setEmptyCorrectionActive(boolean b)
Activates or deactivates the empty-slot correction.

Parameters:
b - true to activate the empty-slot correction; false to deactivate it.

redoCalculations

public void redoCalculations()
Recalculates all sample and site calculations in all currently open suites; intended to be called when the correction (none/sample/formation) has changed.


getBuildProperty

public java.lang.String getBuildProperty(java.lang.String key)
Reads values from the build.properties file. This is a properties file written into the PuffinPlot jar at build time, and currently contains the keys build.date and build.year.

Parameters:
key - the property key to read
Returns:
the value of the key

calculateGreatCirclesDirections

public void calculateGreatCirclesDirections(boolean popUpWindow)
For all selected sites, calculates the site mean direction by best-fit intersection of great circles fitted to that site's samples.

Parameters:
popUpWindow - if true, open a new window showing great circle directions

fitGreatCirclesToSelection

public void fitGreatCirclesToSelection()
For all selected samples, fit a great circle to the selected points.


doPcaOnSelection

public void doPcaOnSelection()
For all selected samples, determine a best-fit line to the selected points by principal component analysis.


getPrefs

public PuffinPrefs getPrefs()
Returns the preferences for this PuffinApp.

Returns:
the preferences for this PuffinApp

getMainWindow

public MainWindow getMainWindow()
Returns this PuffinApp's main window

Returns:
this PuffinApp's main window

getCiteWindow

public CiteWindow getCiteWindow()
Returns this PuffinApp's citation window

Returns:
this PuffinApp's citation window

getCorrection

public Correction getCorrection()
Returns the correction currently being applied to the data displayed by this PuffinApp.

Returns:
the correction currently being applied to the displayed data

setCorrection

public void setCorrection(Correction correction)
Sets the correction to apply to the displayed data.

Parameters:
correction - the correction to apply to the displayed data

updateDisplay

public void updateDisplay()
Updates the main window and table window to reflect any changes in the currently displayed data.


closeCurrentSuite

public void closeCurrentSuite()
Closes the suite whose data is currently being displayed.


openFiles

public void openFiles(java.util.List<java.io.File> files)

openFiles

public void openFiles(java.util.List<java.io.File> files,
                      FileFormat format)
Creates a new suite and reads data into it from the specified files.

Parameters:
files - the files from which to read data

errorDialog

public void errorDialog(java.lang.String title,
                        java.lang.String message)
Displays a dialog box reporting an error.

Parameters:
title - the title for the dialog box
message - the message to be displayed

errorDialog

public void errorDialog(java.lang.String title,
                        PuffinUserException ex)
Displays a dialog box reporting an error. The text of the error box is taken from the supplied exception.

Parameters:
title - the title for the dialog box
ex - the exception from which to take the message text

getSuites

public java.util.List<Suite> getSuites()
Returns all the Suites currently open within this PuffinApp.

Returns:
all the currently open suites as an unmodifiable list

getSuite

public Suite getSuite()
Returns the current Suite.

Returns:
the current Suite

setSuite

public void setSuite(int index)
Sets the currently displayed Suite.

Parameters:
index - the index of the suite to be displayed within PuffinApp's list of suites

getSample

public Sample getSample()
Gets the current Sample

Returns:
the current Sample

getSelectedSamples

public java.util.List<Sample> getSelectedSamples()
Gets all the currently selected samples.

Returns:
the currently selected samples

getCurrentSite

public Site getCurrentSite()
Returns the site for which data is currently being displayed.

Returns:
the current site

getSelectedSites

public java.util.List<Site> getSelectedSites()
Gets all the sites containing any of the currently selected samples.

Returns:
all the sites which contain any of the currently selected samples

getAllSamplesInSelectedSites

public java.util.List<Sample> getAllSamplesInSelectedSites()
Gets all the samples in all the sites having at least one selected sample.

Returns:
all the samples contained in any site containing at least one selected sample

quit

public void quit()
Terminates this instance of PuffinApp immediately.


about

public void about()
Shows the application's ‘About’ dialog box, giving brief information about PuffinPlot.


showPreferences

public void showPreferences()
Opens the preferences window.


showPageSetupDialog

public void showPageSetupDialog()
Opens the page setup dialog box.


getCurrentPageFormat

public java.awt.print.PageFormat getCurrentPageFormat()
Returns the current page format.

Returns:
the current page format

getTableWindow

public TableWindow getTableWindow()
Returns the data table window.

Returns:
the data tabe window

getActions

public PuffinActions getActions()
Returns the actions associated with this PuffinApp.

Returns:
the action associated with this PuffinApp

getSuiteEqAreaWindow

public SuiteEqAreaWindow getSuiteEqAreaWindow()
Returns the suite equal-area plot window.

Returns:
the suite equal-area plot window

getSiteEqAreaWindow

public SiteMeanWindow getSiteEqAreaWindow()
Returns the great-circle statistics window.

Returns:
the great-circle statistics window

getCorrectionWindow

public CorrectionWindow getCorrectionWindow()
Returns the window for user editing of correction data (sample orientation, formation orientation, geomagnetic declination)

Returns:
the correction editing window

getRecentFiles

public RecentFileList getRecentFiles()
Returns the list of recently used files.

Returns:
the list of recently used files

setRecentFiles

public void setRecentFiles(RecentFileList recentFiles)
Sets the list of recently used files (allowing it to be restored after restarting the application).

Parameters:
recentFiles - the list of recently used files

showCustomFlagsWindow

public void showCustomFlagsWindow()
Shows the window for editing the titles of the custom flags.


showCustomNotesWindow

public void showCustomNotesWindow()
Shows the window for editing the titles of the custom notes.


doAmsCalc

public void doAmsCalc(Suite.AmsCalcType calcType,
                      java.lang.String scriptName)
Performs statistical calculations on AMS data using a script from Lisa Tauxe's pmagpy software suite.

Parameters:
calcType - the type of calculation to perform
scriptName - the external script which will perform the calculations

openFilesWithDialog

public void openFilesWithDialog()
Shows an ‘open files’ dialog box; if the user selects any files, they will be opened in a new suite.


importAmsWithDialog

public void importAmsWithDialog()

Shows an open files dialog box; if the user selects any files, AMS data will be imported from them. The files are expected to be in Agico ASC format.


importPreferencesWithDialog

public void importPreferencesWithDialog()

Shows an open file dialog box; if the user select a file, the current preferences will be overwritten with preferences data from that file. The file is expected to contain Java Preferences data in XML format.


clearPreferences

public void clearPreferences()
Shows a confirmation dialog. If the user confirms, all user preferences data is deleted and preferences revert to default values.


copyPointSelection

public void copyPointSelection()
Copies the current pattern of selected points to a clipboard.

See Also:
pastePointSelection()

pastePointSelection

public void pastePointSelection()
For each selected sample, selects the points corresponding to those last copied to the clipboard.

See Also:
copyPointSelection()

flipSelectedSamples

public void flipSelectedSamples(MeasurementAxis axis)
For all selected samples, rotates magnetization data 180° around the specified axis. The intended use is to correct erroneous data caused by incorrect sample orientation during measurement.

Parameters:
axis - the axis around which to flip the selected samples

rescaleMagSus

public void rescaleMagSus()
Scales all magnetic susceptibility values in the current suite by a user-specified factor.


clearSiteCalculations

public void clearSiteCalculations()
Clears any previously calculated Fisherian or great-circle site directions.


clearAmsCalcs

public void clearAmsCalcs()
Clears the results of any AMS calculations for the current suite.


exportPdfItext

public void exportPdfItext(java.io.File pdfFile)
                    throws java.io.FileNotFoundException,
                           com.lowagie.text.DocumentException
Writes a PDF file containing data plots with the current layout for all selected samples. One page is produced per selected sample.

Parameters:
pdfFile - the PDF file to which to write the plots
Throws:
com.lowagie.text.DocumentException - if an error occurred while writing the PDF
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

exportPdfFreehep

public void exportPdfFreehep(java.io.File pdfFile)
                      throws java.io.IOException
Writes a PDF file containing data plots with the current layout for all selected samples. One page is produced per selected sample.

Parameters:
pdfFile - the PDF file to which to write the plots
Throws:
java.io.IOException - if there was an error during file writing

calculateMultiSuiteMeans

public void calculateMultiSuiteMeans()

runPythonScript

public void runPythonScript(java.lang.String scriptPath)
                     throws org.python.core.PyException
Runs a specified Python script

Parameters:
scriptPath - the path to the script
Throws:
org.python.core.PyException - if an error occurred while running the script

runPythonScriptWithDialog

public void runPythonScriptWithDialog()
Opens a file selection dialog and runs the Python script (if any) which the user selects from that dialog.


showTabularImportDialog

public void showTabularImportDialog()

importTabularDataWithFormat

public void importTabularDataWithFormat(FileFormat format)

getVersion

public PuffinApp.Version getVersion()

openWebPage

public void openWebPage(java.lang.String uriString)