Package net.sf.jaxodraw.io
Class JaxoIO
java.lang.Object
net.sf.jaxodraw.io.JaxoIO
The class responsible for opening/saving JaxoGraphs.
Also contains utility methods for file name management etc.
- Since:
- 2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
absoluteName
(String fileName) Returns the absolute path of the given file name.static String
Basename: part before the last '.' that does not occur at the beginning, or the fileName itself if there is none.static String
Returns the current directory as a string.static String
directoryString
(String fileName) Returns the absolute path of he directory that contains the fgiven file.static String
Extension: part after the last '.' that does not occur at the beginning, or "" if there is none.open()
Opens a new JaxoGraph: asks for an open file.Opens a new JaxoGraph from the specified file.Opens a new JaxoGraph from the specified file.Opens a new JaxoGraph from the specified file fileName.void
Saves the specified JaxoGraph: if the current JaxoGraph has no save file associated with it, asks for a save file name.void
Saves the specified JaxoGraph: asks for a save file.static String
Returns the short name if the given file.static boolean
shouldOverwrite
(Component parent, File f) Show a dialog if 'f' exists, asking the user whether 'f' should be overwritten and return the result.static boolean
shouldOverwrite
(Component parent, File f, String dTitle) Show a dialog if 'f' exists, asking the user whether 'f' should be overwritten and return the result.static URL
Convert 'f' to URL, and MalformedURLExceptions to IOExceptions.static String
withExtension
(String name, String extension) fileName with "." + extension added unless it is already at the end or the fileName is empty.
-
Constructor Details
-
JaxoIO
Constructor.- Parameters:
parentc
- The parent component.
-
-
Method Details
-
toURL
Convert 'f' to URL, and MalformedURLExceptions to IOExceptions.- Parameters:
f
- The file to convert.- Returns:
- The URL of the file.
- Throws:
IOException
- If the file cannot be converted.
-
absoluteName
Returns the absolute path of the given file name.- Parameters:
fileName
- The file name.- Returns:
- The absolute path.
-
currentDirectoryString
Returns the current directory as a string.- Returns:
- The current directory.
-
directoryString
Returns the absolute path of he directory that contains the fgiven file.- Parameters:
fileName
- The file name.- Returns:
- The absolute path of the directory.
-
shortName
Returns the short name if the given file.- Parameters:
fileName
- The file name.- Returns:
- The short file name.
-
extension
Extension: part after the last '.' that does not occur at the beginning, or "" if there is none. Always:f.equals(baseName(f) + "." + extension(f))
- Parameters:
fileName
- The file name.- Returns:
- The file extension.
-
baseName
Basename: part before the last '.' that does not occur at the beginning, or the fileName itself if there is none.- Parameters:
fileName
- The file name.- Returns:
- The basename.
-
withExtension
fileName with "." + extension added unless it is already at the end or the fileName is empty.- Parameters:
name
- The file name.extension
- The extension to add.- Returns:
- The full file name.
-
save
Saves the specified JaxoGraph: if the current JaxoGraph has no save file associated with it, asks for a save file name. Othrewise saves the graph to the default file.- Parameters:
title
- title of graph (e.g. in tab)fileName
- suggested file name (if the graph does not have one)graph
- The graph to be saved.
-
saveAs
Saves the specified JaxoGraph: asks for a save file.- Parameters:
title
- title of graph (e.g. in tab)fileName
- suggested file name (if the graph does not have one)graph
- The graph to be saved.
-
shouldOverwrite
Show a dialog if 'f' exists, asking the user whether 'f' should be overwritten and return the result. Otherwise, return true.- Parameters:
parent
- parent component for the dialog.f
- The file to test.- Returns:
- True if the file should be overwritten.
-
shouldOverwrite
Show a dialog if 'f' exists, asking the user whether 'f' should be overwritten and return the result. Otherwise, return true.- Parameters:
parent
- parent component for the dialog.f
- The file to test.dTitle
- of the question dialog, may be 'null', then a default title will be used.- Returns:
- True if the file should be overwritten.
-
open
Opens a new JaxoGraph: asks for an open file.- Returns:
- The new JaxoGraph or null if the file could not be opened.
-
open
Opens a new JaxoGraph from the specified file fileName.- Parameters:
name
- An absolute path to the file to be opened.- Returns:
- The new JaxoGraph or null if the file could not be opened.
-
open
Opens a new JaxoGraph from the specified file.- Parameters:
f
- A file to be opened.- Returns:
- The new JaxoGraph or null if the file could not be opened.
-
open
Opens a new JaxoGraph from the specified file.- Parameters:
f
- A file to be opened.guiWarnings
- set to false to suppress any graphical warning dialogs.- Returns:
- The new JaxoGraph or null if the file could not be opened.
-