|
JGraphpad Pro
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavax.swing.AbstractAction
com.jgraph.editor.JGraphEditorAction
com.jgraph.pad.action.JGraphpadFileAction
Implements all actions of the file menu. The openRecent menu is implemented
using the JGraphpadOpenRecentMenu class, and the import/export
actions are added to the file menu by plugins, so look for their
implementations there.
| Nested Class Summary | |
static class |
JGraphpadFileAction.AllActions
Bundle of all actions in this class. |
| Nested classes inherited from class com.jgraph.editor.JGraphEditorAction |
JGraphEditorAction.Bundle |
| Field Summary | |
protected static JGraphpadDialogs |
dlgs
Shortcut to the shared JGraphpad dialogs. |
protected JGraphEditor |
editor
References the enclosing editor. |
static String |
KEY_EDGEPROTOTYPE
Import actions require the action values for this key to be assigned. |
static String |
KEY_MAINWINDOW
Defines the key for the main windows object. |
static String |
KEY_RECENTFILES
Defines the key for the recent files user settings. |
static String |
KEY_VERTEXPROTOTYPE
Import actions require the action value for this key to be assigned. |
protected File |
lastDirectory
Holds the last directory for file operations. |
static int |
MAX_RECENTFILES
Defines the maximum number of recent files to store under the KEY_RECENTFILES in the user settings file. |
static String |
MIME_HTML
Defines the text/plain mime-type. |
static String |
MIME_PLAINTEXT
Defines the text/plain mime-type. |
static String |
NAME_CLOSE
Specifies the name for the close action. |
static String |
NAME_CLOSEALL
Specifies the name for the closeAll action. |
static String |
NAME_DOWNLOAD
Specifies the name for the download action. |
static String |
NAME_EXIT
Specifies the name for the exit action. |
static String |
NAME_IMPORTCSV
Specifies the name for the importCSV action. |
static String |
NAME_NEWDIAGRAM
Specifies the name for the newDiagram action. |
static String |
NAME_NEWDOCUMENT
Specifies the name for the newDocument action. |
static String |
NAME_NEWLIBRARY
Specifies the name for the newLibrary action. |
static String |
NAME_OPEN
Specifies the name for the open action. |
static String |
NAME_PAGESETUP
Specifies the name for the pageSetup action. |
static String |
NAME_PRINT
Specifies the name for the print action. |
static String |
NAME_REMOVEDIAGRAM
Specifies the name for the removeDiagram action. |
static String |
NAME_RENAMEDIAGRAM
Specifies the name for the renameDiagram action. |
static String |
NAME_SAVE
Specifies the name for the save action. |
static String |
NAME_SAVEALL
Specifies the name for the saveAll action. |
static String |
NAME_SAVEAS
Specifies the name for the saveAs action. |
static String |
NAME_SAVEIMAGE
Specifies the name for the saveImage action. |
static String |
NAME_UPLOADAS
Specifies the name for the uploadAs action. |
| Fields inherited from class com.jgraph.editor.JGraphEditorAction |
isToggleAction, PROPERTY_ISSELECTED, PROPERTY_ISVISIBLE |
| Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
| Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
| Constructor Summary | |
JGraphpadFileAction(String name,
JGraphEditor editor)
Constructs a new file action for the specified name and editor. |
|
| Method Summary | |
void |
actionPerformed(ActionEvent event)
Executes the action based on the action name. |
static String |
convert(OutputStream data,
String mime)
Converts the specified data stream into a string assuming the data stream is of the specified mime type. |
protected void |
doCloseAll()
Closes all open files using doCloseFile(JGraphEditorFile, boolean) giving the user a chance
to save unsaved changes before closing each file. |
protected void |
doCloseFile(JGraphEditorFile file,
boolean remove)
Closes the specified file by removing it from the parent. |
protected void |
doExit()
Closes all open files using doCloseAll(), saves the user
settings and terminates the program using System.exit(int). |
protected void |
doImportCSV(org.jgraph.graph.GraphLayoutCache cache,
String filename)
Displays a file- or URL-dialog and loads the selected file or URL into the specified diagram as a comma separated value file (CSV) using importCSVFile(GraphLayoutCache, InputStream, String, Object, Object, String). |
protected void |
doNewDiagram(JGraphEditorFile file)
Inserts a new empty diagram into the specified file. |
protected void |
doNewDocument()
Inserts a new empty document into the document model. |
protected void |
doNewLibrary()
Inserts a new library into the given file. |
protected void |
doOpenFile(String filename,
JGraphEditorFile file)
Opens the specified filename using JGraphEditorModel.addFile(String) if a file for the specified
name is not already open. |
protected void |
doPageSetup(JGraphEditorDiagramPane diagramPane)
Displays the system page format dialog and updates the pageformat on the specified diagram pane. |
protected void |
doPrintDiagramPane(JGraphEditorDiagramPane diagramPane)
Displays a system print dialog and prints the specified diagram pane. |
protected void |
doRemoveDiagram(JGraphEditorDiagram diagram)
Removes the specified diagram from the parent file if the parent file contains at least one diagram after the removal. |
protected void |
doRenameDiagram(JGraphEditorDiagram diagram)
Displays a dialog to enter the new name for the specified diagram and updates the name of the diagram using JGraphEditorModel.setName(JGraphEditorDiagram, String). |
void |
doSave(String filename,
byte[] data)
Saves the specified byte array to the specified file. |
protected void |
doSaveAll()
Saves all open files using doSaveFile(JGraphEditorFile, boolean, boolean) showing file
dialogs for files whose filename has not been assigned. |
protected void |
doSaveFile(JGraphEditorFile file,
boolean forceFilenameDialog,
boolean urlDialog)
Saves the specified file displaying a filename dialog if the filename is not set or if forceFilenameDialog is true. |
protected void |
doSaveImage(JGraphEditorDiagramPane diagramPane,
int inset,
String filename)
Saves the specified graph as an image using inset as the
size of the empty border around the image. |
static Object |
getCellForKey(org.jgraph.graph.GraphModel model,
Object prototype,
Hashtable map,
String key,
int cols,
int w,
int h,
int offset,
boolean image)
Utility method to return the cell stored under key in the specified map or create the cell using the specified prototype and model and put it into the map under key. |
protected int |
getFileCount(boolean countLibraries)
Uses isLibrary(JGraphEditorFile) to find the number of roots
that are instances of JGraphEditorFile. |
protected int |
getFileCount(Object root,
boolean countLibraries)
Uses isLibrary(JGraphEditorFile) to find the number of roots
that are instances of JGraphEditorFile. |
static JGraphEditorFile |
getPermanentFocusOwnerFile()
Returns the diagram for the permanent focus owner diagram pane. |
static JGraphpadLibraryPane |
getPermanentFocusOwnerLibraryPane()
Returns the permanent focus owner library pane. |
static void |
importCSVFile(org.jgraph.graph.GraphLayoutCache cache,
InputStream fstream,
String delim,
Object vertexPrototype,
Object edgePrototype,
String defaultEdgeLabel)
Reads the specified input stream as a comma-delimeted file, using the following format: a,b[,c] where a and b are vertices and c is the label of the edge to be inserted between a and b. |
protected boolean |
isLibrary(JGraphEditorFile file)
Returns true if the specified file is a library. |
static String |
makeMimeForm(String fileName,
String type,
String path,
String content,
String comment,
String sep)
Returns a mime form using the specified parameters. |
static boolean |
post(URL url,
String path,
String mime,
OutputStream data)
Posts the data to the specified url using path to specify
the filename in the mime response for the specified mime type. |
static boolean |
post(URL url,
String path,
String mime,
String data)
Posts the data to the specified url using path to specify
the filename in the mime response for the specified mime type. |
static boolean |
postPlain(URL url,
String path,
OutputStream data)
Posts the data to the specified url using path to specify
the filename in the mime response using for type MIME_PLAINTEXT. |
| Methods inherited from class com.jgraph.editor.JGraphEditorAction |
getActiveFrame, getFrame, getJGraphpadPane, getJGraphpadPane, getName, getParentGraph, getPermanentFocusOwner, getPermanentFocusOwnerDiagram, getPermanentFocusOwnerDiagramPane, getPermanentFocusOwnerGraph, getPermanentFocusOwnerOrParent, getString, isSelected, isToggleAction, isVisible, setEnabled, setSelected, setToggleAction, setVisible |
| Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String MIME_PLAINTEXT
public static final String MIME_HTML
protected static JGraphpadDialogs dlgs
public static final String KEY_VERTEXPROTOTYPE
Action.putValue(java.lang.String, java.lang.Object),
Constant Field Valuespublic static final String KEY_EDGEPROTOTYPE
Action.putValue(java.lang.String, java.lang.Object),
Constant Field Valuespublic static final String KEY_MAINWINDOW
JGraphpad.PATH_USERSETTINGS on program termination.
public static final String KEY_RECENTFILES
JGraphpad.PATH_USERSETTINGS on program termination.
public static int MAX_RECENTFILES
KEY_RECENTFILES in the user settings file. Default is 6.
public static final String NAME_NEWDOCUMENT
newDocument action.
public static final String NAME_NEWDIAGRAM
newDiagram action.
public static final String NAME_RENAMEDIAGRAM
renameDiagram action.
public static final String NAME_REMOVEDIAGRAM
removeDiagram action.
public static final String NAME_NEWLIBRARY
newLibrary action.
public static final String NAME_OPEN
open action.
public static final String NAME_DOWNLOAD
download action.
public static final String NAME_CLOSE
close action.
public static final String NAME_CLOSEALL
closeAll action.
public static final String NAME_SAVE
save action.
public static final String NAME_SAVEAS
saveAs action.
public static final String NAME_UPLOADAS
uploadAs action.
public static final String NAME_SAVEALL
saveAll action.
public static final String NAME_SAVEIMAGE
saveImage action.
public static final String NAME_IMPORTCSV
importCSV action.
public static final String NAME_PAGESETUP
pageSetup action.
public static final String NAME_PRINT
print action.
public static final String NAME_EXIT
exit action.
protected JGraphEditor editor
protected File lastDirectory
| Constructor Detail |
public JGraphpadFileAction(String name,
JGraphEditor editor)
name - The name of the action to be created.editor - The enclosing editor for the action.| Method Detail |
public void actionPerformed(ActionEvent event)
event - The object that describes the event.
protected void doSaveAll()
throws IOException
doSaveFile(JGraphEditorFile, boolean, boolean) showing file
dialogs for files whose filename has not been assigned.
IOException - If there was an error saving the files.
protected void doSaveFile(JGraphEditorFile file,
boolean forceFilenameDialog,
boolean urlDialog)
throws IOException
forceFilenameDialog is true. If
urlDialog is true, then the dialog will ask for an URL
instead of a local file.
file - The file to be saved.forceFilenameDialog - Whether to display a dialog regardless of the filename.urlDialog - Whether to display an URL dialog to specifiy the filename.
IOException - If the file cannot be saved.JGraphEditorModel.getOutputStream(String),
postPlain(URL, String, OutputStream)
protected void doSaveImage(JGraphEditorDiagramPane diagramPane,
int inset,
String filename)
throws IOException
inset as the
size of the empty border around the image. This implementation displays a
dialog to ask for transparency-support if the chosen fileformat supports
it (eg. PNG, GIF). If filename is an URL it tries to upload the data to
that URL.
diagramPane - The diagram pane to save to the image for.inset - The size of the empty border around the image.filename - The filename to save or upload the image to.
IOException - If the image cannot be saved.
IllegalArgumentException - If the graph contains no cells.JGraph.getImage(Color, int),
ImageIO.write(java.awt.image.RenderedImage, java.lang.String,
java.io.OutputStream),
JGraphEditorModel.getOutputStream(String),
post(URL, String, String, OutputStream)
public void doSave(String filename,
byte[] data)
throws Exception
filename - The filename of the file to be written.data - The array of bytes to write to the file.
Exception
protected void doImportCSV(org.jgraph.graph.GraphLayoutCache cache,
String filename)
throws IOException
importCSVFile(GraphLayoutCache, InputStream, String, Object, Object, String).
cache - The graph layout cache to import into.filename - The filename to import from.
IOException - If the file cannot be read.JGraphEditorModel.getInputStream(String)
protected void doPrintDiagramPane(JGraphEditorDiagramPane diagramPane)
throws PrinterException
diagramPane - The diagram pane to be printed.
PrinterException - If the document can not be printed.protected void doPageSetup(JGraphEditorDiagramPane diagramPane)
diagramPane - The diagram pane to set the page format.
protected void doOpenFile(String filename,
JGraphEditorFile file)
throws MalformedURLException,
IOException
JGraphEditorModel.addFile(String) if a file for the specified
name is not already open.
filename - The name of the file to be opened.
IOException - If there was an error reading the file.
MalformedURLException - If the filename is an URL but the URL is invalid.
protected void doExit()
throws IOException
doCloseAll(), saves the user
settings and terminates the program using System.exit(int). This
implementation allows the JGraphpad.PATH_USERSETTINGS to be a
URL.
IOException - If there was an error saving unsaved changes.
protected void doCloseAll()
throws IOException
doCloseFile(JGraphEditorFile, boolean) giving the user a chance
to save unsaved changes before closing each file.
IOException - If there was an error saving unsaved changes.
protected void doCloseFile(JGraphEditorFile file,
boolean remove)
throws IOException
doSaveFile(JGraphEditorFile, boolean, boolean) if the user
chooses to save the changes.
file - The file to be closed.remove - Whether the file should be removed from the model.
IOException - If the unsaved changes can not be saved.protected void doNewDocument()
getFileCount(boolean).
protected void doNewDiagram(JGraphEditorFile file)
TreeModel.getChildCount(java.lang.Object) for the file.
file - The file to add the diagram to.protected void doNewLibrary()
getFileCount(boolean).
protected void doRemoveDiagram(JGraphEditorDiagram diagram)
diagram - The diagram to be removed from its parent file.JGraphpadDialogs.confirmDialog(Component, String, boolean, boolean)protected void doRenameDiagram(JGraphEditorDiagram diagram)
JGraphEditorModel.setName(JGraphEditorDiagram, String).
diagram - The diagram to be renamed.JGraphpadDialogs.valueDialog(String, String)protected int getFileCount(boolean countLibraries)
isLibrary(JGraphEditorFile) to find the number of roots
that are instances of JGraphEditorFile. If
countLibraries is true, then the number of libraries is
returned. getFileCount(false) + getFileCount(true) ==
getChildCount(getRoot())
countLibraries - Whether libraries or non-libraries should be counted.
protected int getFileCount(Object root,
boolean countLibraries)
isLibrary(JGraphEditorFile) to find the number of roots
that are instances of JGraphEditorFile. If
countLibraries is true, then the number of libraries is
returned. getFileCount(false) + getFileCount(true) ==
getChildCount(getRoot())
countLibraries - Whether libraries or non-libraries should be counted.
protected boolean isLibrary(JGraphEditorFile file)
JGraphpadLibrary.
file - The file to be checked.
file is a library.public static JGraphEditorFile getPermanentFocusOwnerFile()
public static void importCSVFile(org.jgraph.graph.GraphLayoutCache cache,
InputStream fstream,
String delim,
Object vertexPrototype,
Object edgePrototype,
String defaultEdgeLabel)
throws IOException
cache - The layout cache to import the file into.fstream - The stream to import the cells from.delim - The delimeter to parse the tokens.vertexPrototype - The prototype to create new vertices with.edgePrototype - The prototype to create new edges with.defaultEdgeLabel - The default label to use for edges if none is specified.
IOException
public static Object getCellForKey(org.jgraph.graph.GraphModel model,
Object prototype,
Hashtable map,
String key,
int cols,
int w,
int h,
int offset,
boolean image)
cols columns and entries of size (w,h).
model - The model to use for cloning the prototype.prototype - The prototype to use for creating new cells.map - The map to check whether the cell exists for key.key - The key to return the cell for.cols - The number of columns for the matrix.w - The width of the entries.h - The height of the entries.offset - The offset from the top left.image - Whether to insert image or text cells.
public static boolean postPlain(URL url,
String path,
OutputStream data)
throws IOException
path to specify
the filename in the mime response using for type MIME_PLAINTEXT.
url - The url to post the mime response to.path - The filename to use in the mime response.data - The binary data to send with the mime response.
IOException
public static boolean post(URL url,
String path,
String mime,
OutputStream data)
throws IOException
path to specify
the filename in the mime response for the specified mime type.
url - The url to post the mime response to.path - The filename to use in the mime response.mime - The mime type to use for the response.data - The binary data to send with the mime response.
IOException
public static String convert(OutputStream data,
String mime)
MIME_PLAINTEXT.
data - The data to be converted.mime - The mime type to assume for the data.
public static boolean post(URL url,
String path,
String mime,
String data)
throws IOException
path to specify
the filename in the mime response for the specified mime type.
url - The url to post the mime response to.path - The filename to use in the mime response.mime - The mime type to use for the response.data - The binary data to send with the mime response.
IOException
public static String makeMimeForm(String fileName,
String type,
String path,
String content,
String comment,
String sep)
public static JGraphpadLibraryPane getPermanentFocusOwnerLibraryPane()
|
JGraphpad Pro
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||