ptolemy.vergil.basic
Class BasicGraphFrame

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 ptolemy.gui.Top
                          extended by ptolemy.actor.gui.TableauFrame
                              extended by ptolemy.actor.gui.PtolemyFrame
                                  extended by ptolemy.vergil.basic.BasicGraphFrame
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, ChangeListener
Direct Known Subclasses:
EditIconFrame, ExtendedGraphFrame

public abstract class BasicGraphFrame
extends PtolemyFrame
implements java.awt.print.Printable, java.awt.datatransfer.ClipboardOwner, ChangeListener, java.awt.event.MouseWheelListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

A simple graph view for ptolemy models. This represents a level of the hierarchy of a ptolemy model as a diva graph. Cut, copy and paste operations are supported using MoML.

Since:
Ptolemy II 2.0
Version:
$Id: BasicGraphFrame.java 59439 2010-10-07 21:04:58Z cxh $
Author:
Steve Neuendorffer, Edward A. Lee, Contributors: Chad Berkeley (Kepler), Ian Brown (HSBC), Bert Rodiers
See Also:
Serialized Form
Accepted Rating:
Red (johnr)
Proposed Rating:
Red (neuendor)

Nested Class Summary
protected  class BasicGraphFrame.CopyAction
          Action to copy the current selection.
protected  class BasicGraphFrame.CutAction
          Action to copy and delete the current selection.
private  class BasicGraphFrame.DocumentationMenuItemFactory
          Create a menu item that will show documentation
protected  class BasicGraphFrame.EditPreferencesAction
          Action to edit the preferences.
private static class BasicGraphFrame.ElementInLinkType
          An enumerate to specifies what kind of element the element (head or tail) is in a link.
private static class BasicGraphFrame.LinkElementProperties
          A class that keeps stores basic properties of element (head, tail) in a link
protected  class BasicGraphFrame.MoveToBackAction
          Action to move the current selection to the back (which corresponds to first in the ordered list).
protected  class BasicGraphFrame.MoveToFrontAction
          Action to move the current selection to the back (which corresponds to first in the ordered list).
private  class BasicGraphFrame.OpenContainerAction
          An action to open the container of this entity.
private  class BasicGraphFrame.OpenLibraryMenuItemFactory
          Create a menu item that will open a library in editable form.
protected  class BasicGraphFrame.PasteAction
          Paste the current contents of the clipboard into the current model.
private  class BasicGraphFrame.PrintAction
          Print the current model.
private static class BasicGraphFrame.PtolemyLayout
          A layout algorithm for laying out ptolemy graphs.
private  class BasicGraphFrame.PtolemyLayoutTarget
          A layout target that translates locatable nodes.
private  class BasicGraphFrame.RedoAction
          Redo the last undone MoML change on the current current model.
private  class BasicGraphFrame.SaveAction
          Save the current model.
private  class BasicGraphFrame.UndoAction
          Undo the last undoable MoML change on the current current model.
private  class BasicGraphFrame.ZoomFitAction
          An action to zoom fit.
private  class BasicGraphFrame.ZoomInAction
          An action to zoom in.
private  class BasicGraphFrame.ZoomOutAction
          An action to zoom out.
private  class BasicGraphFrame.ZoomResetAction
          An action to reset zoom.
 
Nested classes/interfaces inherited from class ptolemy.actor.gui.TableauFrame
TableauFrame.ExtensionFileFilter
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.Action _copyAction
          The copy action.
protected  javax.swing.Action _cutAction
          The cut action.
protected  LibraryAttribute _defaultLibrary
          The default Library.
protected  EditorDropTarget _dropTarget
          The instance of EditorDropTarget associated with the JGraph.
protected  javax.swing.JMenu _editMenu
          The edit menu.
protected  BasicGraphFrame.EditPreferencesAction _editPreferencesAction
          The action to edit preferences.
protected  javax.swing.Action _exportPDFAction
          The export to PDF action.
protected  JCanvasPanner _graphPanner
          The panner.
protected  JGraph _jgraph
          The instance of JGraph for this editor.
protected  javax.swing.JTree _library
          The library display widget.
protected  PTreeMenuCreator _libraryContextMenuCreator
          The library context menu creator.
protected  EntityTreeModel _libraryModel
          The library model.
protected  javax.swing.JScrollPane _libraryScrollPane
          The library scroll pane.
protected  BasicGraphFrame.MoveToBackAction _moveToBackAction
          Action to move to the back.
protected  BasicGraphFrame.MoveToFrontAction _moveToFrontAction
          Action to move to the front.
private  javax.swing.Action _openContainerAction
          Action for opening the container, moving uplevel.
protected static java.util.LinkedList<BasicGraphFrame> _openGraphFrames
          List of references to graph frames that are open.
protected  javax.swing.JPanel _palettePane
          The library display panel.
protected  javax.swing.Action _pasteAction
          The paste action.
private  int _previousMouseX
          X coordinate of where we last processed a press or drag of the middle mouse button.
private  int _previousMouseY
          Y coordinate of where we last processed a press or drag of the middle mouse button.
private  javax.swing.Action _printAction
          Action to print the model.
private  javax.swing.Action _redoAction
          Action to redo the last undone MoML change.
protected  javax.swing.JComponent _rightComponent
          The right component for this editor.
private  javax.swing.Action _saveAction
          Action to save the model.
protected  javax.swing.JSplitPane _splitPane
          The split pane for library and editor.
protected  javax.swing.JToolBar _toolbar
          The toolbar.
protected  CompositeEntity _topLibrary
          The library.
private  javax.swing.Action _undoAction
          Action to undo the last MoML change.
protected  javax.swing.Action _zoomFitAction
          Action for zoom fitting.
protected  javax.swing.Action _zoomInAction
          Action for zooming in.
protected  javax.swing.Action _zoomOutAction
          Action for zooming out.
protected  javax.swing.Action _zoomResetAction
          Action for zoom reset.
static java.awt.Color BACKGROUND_COLOR
          Default background color is a light grey.
static java.lang.String VERGIL_USER_LIBRARY_NAME
          Deprecated. Use UserActorLibrary.USER_LIBRARY_NAME
 
Fields inherited from class ptolemy.actor.gui.PtolemyFrame
_query
 
Fields inherited from class ptolemy.actor.gui.TableauFrame
_initialSaveAsFileName, _viewMenu, aboutFile, helpFile
 
Fields inherited from class ptolemy.gui.Top
_CANCELED, _directory, _DISCARDED, _FAILED, _fileFilter, _fileMenu, _fileMenuItems, _helpMenu, _helpMenuItems, _menubar, _SAVED, _statusBar
 
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 java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
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
BasicGraphFrame(NamedObj entity, Tableau tableau)
          Construct a frame associated with the specified Ptolemy II model or object.
BasicGraphFrame(NamedObj entity, Tableau tableau, LibraryAttribute defaultLibrary)
          Construct a frame associated with the specified Ptolemy II model.
 
Method Summary
protected  void _addMenus()
          Create the menus that are used by this frame.
protected  boolean _checkForImplied(java.util.List<NamedObj> elements)
          Return true if any element of the specified list is implied.
protected  boolean _close()
          Override the base class to remove the listeners we have created when the frame closes.
protected  CompositeEntity _createDefaultLibrary(Workspace workspace)
          Create the default library to use if an entity has no LibraryAttribute.
protected  javax.swing.JMenuItem[] _createFileMenuItems()
          Create the items in the File menu.
protected abstract  GraphPane _createGraphPane(NamedObj entity)
          Create a new graph pane.
protected  javax.swing.JComponent _createRightComponent(NamedObj entity)
          Create the component that goes to the right of the library.
protected  SizeAttribute _createSizeAttribute()
          Create a SizeAttribute for the current model when it is being saved to a file.
protected  java.lang.StringBuffer _deleteMoML(AbstractBasicGraphModel graphModel, java.lang.Object[] selection, SelectionModel model)
          Return the MoML to delete the specified selection objects.
protected  void _exportDesignPattern(java.io.Writer writer, NamedObj model, java.lang.String name)
          Export the model into the writer with the given name.
protected  void _finishExportDesignPattern()
          Finish exporting a design pattern.
protected  java.io.File _getDirectory()
          Get the directory that was last accessed by this window.
protected  GraphController _getGraphController()
          Return the graph controller associated with this frame.
protected  AbstractBasicGraphModel _getGraphModel()
          Return the graph model associated with this frame.
protected  javax.swing.JComponent _getRightComponent()
          Return the right component on which graph editing occurs.
protected  java.util.HashSet<NamedObj> _getSelectionSet()
          Return a set of instances of NamedObj representing the objects that are currently selected.
protected  void _initBasicGraphFrame()
          Initialize this BasicGraphFrame.
protected  boolean _isDesignPattern()
          Return true if this is a design pattern.
protected  void _prepareExportDesignPattern()
          Prepare to export a design pattern.
protected  javax.swing.JFileChooser _saveAsFileDialog()
          Create and return a file dialog for the "Save As" command.
protected  void _setDirectory(java.io.File directory)
          Set the directory that was last accessed by this window.
protected  void _setDropIntoEnabled(boolean enable)
          Enable or disable drop into.
protected  void _writeFile(java.io.File file)
          Write the model to the specified file.
 void changeExecuted(ChangeRequest change)
          React to the fact that a change has been successfully executed by marking the data associated with this window modified.
 void changeFailed(ChangeRequest change, java.lang.Exception exception)
          React to the fact that a change has triggered an error by doing nothing (the effigy is also listening and will report the error).
 void clearSelection()
          Clear the selected objects in this frame.
 void copy()
          Get the currently selected objects from this document, if any, and place them on the clipboard in MoML format.
 void createHierarchy()
          Create a typed composite actor that contains the selected actors and connections.
 void cut()
          Remove the currently selected objects from this document, if any, and place them on the clipboard.
 void delete()
          Delete the currently selected objects from this document.
 void dispose()
          Dispose of this frame.
 void disposeSuper()
          Invoke the dispose() method of the superclass, PtolemyFrame.
 void expandAllLibraryRows()
          Expand all the rows of the library.
 void exportDesignPattern()
          Export the current submodel as a design pattern using a method similar to Save As.
 java.awt.geom.Point2D getCenter()
          Return the center location of the visible part of the pane.
 JCanvasPanner getGraphPanner()
          Return the JCanvasPanner instance.
 JGraph getJGraph()
          Return the JGraph instance that this view uses to represent the ptolemy model.
 java.util.HashSet<NamedObj> getSelectionSet()
          Return a set of instances of NamedObj representing the objects that are currently selected.
 java.awt.geom.Rectangle2D getVisibleCanvasRectangle()
          Return the rectangle representing the visible part of the pane, transformed into canvas coordinates.
 java.awt.geom.Rectangle2D getVisibleRectangle()
          Return the rectangle representing the visible part of the pane, in pixel coordinates on the screen.
 void importDesignPattern()
          Import a design pattern into the current design.
 void layoutGraph()
          Layout the graph view.
 void layoutGraphWithPtolemyLayout()
          Layout the graph view using the default PtolemyLayout.
 void lostOwnership(java.awt.datatransfer.Clipboard clipboard, java.awt.datatransfer.Transferable transferable)
          Do nothing.
 void mouseClicked(java.awt.event.MouseEvent event)
          Called when the mouse is clicked.
 void mouseDragged(java.awt.event.MouseEvent event)
          Transform the graph by the amount the mouse is dragged while the middle mouse button is held down.
 void mouseEntered(java.awt.event.MouseEvent event)
          Called when the mouse enters this component.
 void mouseExited(java.awt.event.MouseEvent event)
          Called when the mouse leaves this component.
 void mouseMoved(java.awt.event.MouseEvent event)
          Called when the mouse is moved.
 void mousePressed(java.awt.event.MouseEvent event)
          Store the location of the middle mouse event.
 void mouseReleased(java.awt.event.MouseEvent event)
          Called when the mouse is released.
 void mouseWheelMoved(java.awt.event.MouseWheelEvent event)
          Scroll in when the mouse wheel is moved.
 void openContainer()
          Open the container, if any, of the entity.
 void paste()
          Assuming the contents of the clipboard is MoML code, paste it into the current model by issuing a change request.
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat format, int index)
          Print the visible portion of the graph to a printer, which is represented by the specified graphics object.
 void redo()
          Redo the last undone change on the model.
 void saveComponentInFile(Entity entity)
          Open a file browser and save the given entity in the file specified by the user.
static void saveComponentInLibrary(Configuration configuration, Entity entity)
          Deprecated. Use UserActorLibrary.saveComponentInLibrary(Configuration, Entity)
 void setCenter(java.awt.geom.Point2D center)
          Set the center location of the visible part of the pane.
 void setJGraph(JGraph jgraph)
          Set the JGraph instance that this view uses to represent the ptolemy model.
 void undo()
          Undo the last undoable change on the model.
 void zoom(double factor)
          Zoom in or out to magnify by the specified factor, from the current magnification.
 void zoomFit()
          Zoom to fit the current figures.
 void zoomReset()
          Set zoom to the nominal.
 
Methods inherited from class ptolemy.actor.gui.PtolemyFrame
_clear, _help, _print, _saveAs, getEffigy, getModel, setModel
 
Methods inherited from class ptolemy.actor.gui.TableauFrame
_about, _confirmFile, _exit, _getDefaultIconImage, _getName, _read, _save, _saveAs, _saveAsHelper, getAlternateTopPack, getConfiguration, getDirectory, getEffigy, getTableau, isModified, pack, printPDF, setModified, setTableau
 
Methods inherited from class ptolemy.gui.Top
_getCurrentDirectory, _open, _openURL, _printCrossPlatform, _printNative, _printPDF, _queryForSave, centerOnScreen, close, deferIfNecessary, getCentering, hideMenuBar, isMenuPopulated, report, report, report, setBackground, setCentering, setDirectory, show
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, 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, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

BACKGROUND_COLOR

public static final java.awt.Color BACKGROUND_COLOR
Default background color is a light grey.


VERGIL_USER_LIBRARY_NAME

public static java.lang.String VERGIL_USER_LIBRARY_NAME
Deprecated. Use UserActorLibrary.USER_LIBRARY_NAME
The name of the user library. The default value is "UserLibrary". The value of this variable is what appears in the Vergil left hand tree menu.


_defaultLibrary

protected LibraryAttribute _defaultLibrary
The default Library.


_cutAction

protected javax.swing.Action _cutAction
The cut action.


_copyAction

protected javax.swing.Action _copyAction
The copy action.


_editMenu

protected javax.swing.JMenu _editMenu
The edit menu.


_editPreferencesAction

protected BasicGraphFrame.EditPreferencesAction _editPreferencesAction
The action to edit preferences.


_exportPDFAction

protected javax.swing.Action _exportPDFAction
The export to PDF action.


_graphPanner

protected JCanvasPanner _graphPanner
The panner.


_library

protected javax.swing.JTree _library
The library display widget.


_libraryContextMenuCreator

protected PTreeMenuCreator _libraryContextMenuCreator
The library context menu creator.


_libraryModel

protected EntityTreeModel _libraryModel
The library model.


_libraryScrollPane

protected javax.swing.JScrollPane _libraryScrollPane
The library scroll pane.


_moveToBackAction

protected BasicGraphFrame.MoveToBackAction _moveToBackAction
Action to move to the back.


_moveToFrontAction

protected BasicGraphFrame.MoveToFrontAction _moveToFrontAction
Action to move to the front.


_palettePane

protected javax.swing.JPanel _palettePane
The library display panel.


_pasteAction

protected javax.swing.Action _pasteAction
The paste action.


_splitPane

protected javax.swing.JSplitPane _splitPane
The split pane for library and editor.


_toolbar

protected javax.swing.JToolBar _toolbar
The toolbar.


_topLibrary

protected CompositeEntity _topLibrary
The library.


_dropTarget

protected EditorDropTarget _dropTarget
The instance of EditorDropTarget associated with the JGraph.


_jgraph

protected JGraph _jgraph
The instance of JGraph for this editor.


_openContainerAction

private javax.swing.Action _openContainerAction
Action for opening the container, moving uplevel.


_openGraphFrames

protected static java.util.LinkedList<BasicGraphFrame> _openGraphFrames
List of references to graph frames that are open.


_previousMouseX

private int _previousMouseX
X coordinate of where we last processed a press or drag of the middle mouse button.


_previousMouseY

private int _previousMouseY
Y coordinate of where we last processed a press or drag of the middle mouse button.


_printAction

private javax.swing.Action _printAction
Action to print the model.


_redoAction

private javax.swing.Action _redoAction
Action to redo the last undone MoML change.


_rightComponent

protected javax.swing.JComponent _rightComponent
The right component for this editor.


_saveAction

private javax.swing.Action _saveAction
Action to save the model.


_undoAction

private javax.swing.Action _undoAction
Action to undo the last MoML change.


_zoomInAction

protected javax.swing.Action _zoomInAction
Action for zooming in.


_zoomResetAction

protected javax.swing.Action _zoomResetAction
Action for zoom reset.


_zoomFitAction

protected javax.swing.Action _zoomFitAction
Action for zoom fitting.


_zoomOutAction

protected javax.swing.Action _zoomOutAction
Action for zooming out.

Constructor Detail

BasicGraphFrame

public BasicGraphFrame(NamedObj entity,
                       Tableau tableau)
Construct a frame associated with the specified Ptolemy II model or object. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This is typically done by calling show() on the controlling tableau. This constructor results in a graph frame that obtains its library either from the model (if it has one) or the default library defined in the configuration.

Parameters:
entity - The model or object to put in this frame.
tableau - The tableau responsible for this frame.
See Also:
Tableau.show()

BasicGraphFrame

public BasicGraphFrame(NamedObj entity,
                       Tableau tableau,
                       LibraryAttribute defaultLibrary)
Construct a frame associated with the specified Ptolemy II model. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This is typically done by calling show() on the controlling tableau. This constructor results in a graph frame that obtains its library either from the model (if it has one), or the defaultLibrary argument (if it is non-null), or the default library defined in the configuration.

Parameters:
entity - The model or object to put in this frame.
tableau - The tableau responsible for this frame.
defaultLibrary - An attribute specifying the default library to use if the model does not have a library. The defaultLibrary attribute is only read if the model does not have a LibraryAttribute with the name "_library", or if the LibraryAttribute cannot be read.
See Also:
Tableau.show()
Method Detail

changeExecuted

public void changeExecuted(ChangeRequest change)
React to the fact that a change has been successfully executed by marking the data associated with this window modified. This will trigger a dialog when the window is closed, prompting the user to save the data.

Specified by:
changeExecuted in interface ChangeListener
Parameters:
change - The change that has been executed.

changeFailed

public void changeFailed(ChangeRequest change,
                         java.lang.Exception exception)
React to the fact that a change has triggered an error by doing nothing (the effigy is also listening and will report the error).

Specified by:
changeFailed in interface ChangeListener
Parameters:
change - The change that was attempted.
exception - The exception that resulted.

clearSelection

public void clearSelection()
Clear the selected objects in this frame.


copy

public void copy()
Get the currently selected objects from this document, if any, and place them on the clipboard in MoML format.


createHierarchy

public void createHierarchy()
Create a typed composite actor that contains the selected actors and connections. The created typed composite actor is transparent. The resulting topology is the same in the sense of deep connectivities.


cut

public void cut()
Remove the currently selected objects from this document, if any, and place them on the clipboard.


delete

public void delete()
Delete the currently selected objects from this document.


dispose

public void dispose()
Dispose of this frame. Override this dispose() method to unattach any listeners that may keep this model from getting garbage collected. This method calls disposeSuper().

Overrides:
dispose in class java.awt.Window

disposeSuper

public void disposeSuper()
Invoke the dispose() method of the superclass, PtolemyFrame.


expandAllLibraryRows

public void expandAllLibraryRows()
Expand all the rows of the library. Expanding all the rows is useful for testing.

Overrides:
expandAllLibraryRows in class PtolemyFrame

exportDesignPattern

public void exportDesignPattern()
Export the current submodel as a design pattern using a method similar to Save As.


getCenter

public java.awt.geom.Point2D getCenter()
Return the center location of the visible part of the pane.

Returns:
The center of the visible part.
See Also:
setCenter(Point2D)

getJGraph

public JGraph getJGraph()
Return the JGraph instance that this view uses to represent the ptolemy model.

Returns:
the JGraph.
See Also:
setJGraph(JGraph)

getGraphPanner

public JCanvasPanner getGraphPanner()
Return the JCanvasPanner instance.

Returns:
the JCanvasPanner

getSelectionSet

public java.util.HashSet<NamedObj> getSelectionSet()
Return a set of instances of NamedObj representing the objects that are currently selected. This set has no particular order to it. If you need the selection objects in proper order, as defined by the container, then call sortContainedObjects() on the container to sort the result.

Returns:
The set of selected objects.

getVisibleCanvasRectangle

public java.awt.geom.Rectangle2D getVisibleCanvasRectangle()
Return the rectangle representing the visible part of the pane, transformed into canvas coordinates. This is the range of locations that are visible, given the current pan and zoom.

Returns:
The rectangle representing the visible part.

getVisibleRectangle

public java.awt.geom.Rectangle2D getVisibleRectangle()
Return the rectangle representing the visible part of the pane, in pixel coordinates on the screen.

Returns:
A rectangle whose upper left corner is at (0, 0) and whose size is the size of the canvas component.

importDesignPattern

public void importDesignPattern()
Import a design pattern into the current design.


layoutGraph

public void layoutGraph()
Layout the graph view. If the configuration contains a parameter named _layoutGraphDialog, the that parameter is assumed to name a class that creates a modal dialog that displays controls to change the layout. The class should have a constructor that takes a Frame argument. If the parameter cannot be read, then the default Ptolemy layout mechanism in layoutGraphWithPtolemyLayout() is used.


layoutGraphWithPtolemyLayout

public void layoutGraphWithPtolemyLayout()
Layout the graph view using the default PtolemyLayout.


lostOwnership

public void lostOwnership(java.awt.datatransfer.Clipboard clipboard,
                          java.awt.datatransfer.Transferable transferable)
Do nothing.

Specified by:
lostOwnership in interface java.awt.datatransfer.ClipboardOwner

openContainer

public void openContainer()
Open the container, if any, of the entity. If this entity has no container, then do nothing.


paste

public void paste()
Assuming the contents of the clipboard is MoML code, paste it into the current model by issuing a change request.


print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat format,
                 int index)
          throws java.awt.print.PrinterException
Print the visible portion of the graph to a printer, which is represented by the specified graphics object.

Specified by:
print in interface java.awt.print.Printable
Parameters:
graphics - The context into which the page is drawn.
format - The size and orientation of the page being drawn.
index - The zero based index of the page to be drawn.
Returns:
PAGE_EXISTS if the page is rendered successfully, or NO_SUCH_PAGE if pageIndex specifies a non-existent page.
Throws:
java.awt.print.PrinterException - If the print job is terminated.

redo

public void redo()
Redo the last undone change on the model.

See Also:
undo()

saveComponentInFile

public void saveComponentInFile(Entity entity)
                         throws java.lang.Exception
Open a file browser and save the given entity in the file specified by the user.

Parameters:
entity - The entity to save.
Throws:
java.lang.Exception - If there is a problem saving the component.
Since:
Ptolemy 4.0

saveComponentInLibrary

public static void saveComponentInLibrary(Configuration configuration,
                                          Entity entity)
Deprecated. Use UserActorLibrary.saveComponentInLibrary(Configuration, Entity)

Save the given entity in the user library in the given configuration.

Parameters:
configuration - The configuration.
entity - The entity to save.
Since:
Ptolemy 2.1

setCenter

public void setCenter(java.awt.geom.Point2D center)
Set the center location of the visible part of the pane. This will cause the panner to center on the specified location with the current zoom factor.

Parameters:
center - The center of the visible part.
See Also:
getCenter()

setJGraph

public void setJGraph(JGraph jgraph)
Set the JGraph instance that this view uses to represent the ptolemy model.

Parameters:
jgraph - The JGraph.
See Also:
getJGraph()

undo

public void undo()
Undo the last undoable change on the model.

See Also:
redo()

zoom

public void zoom(double factor)
Zoom in or out to magnify by the specified factor, from the current magnification.

Parameters:
factor - The magnification factor (relative to 1.0).

zoomFit

public void zoomFit()
Zoom to fit the current figures.


zoomReset

public void zoomReset()
Set zoom to the nominal.


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Called when the mouse is clicked. This base class does nothing when the mouse is clicked. However, events _are_ handled by the components within this component.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
event - The mouse event.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Transform the graph by the amount the mouse is dragged while the middle mouse button is held down.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
event - The drag event.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)
Called when the mouse enters this component. This base class does nothing when the enters this component. However, events _are_ handled by the components within this component.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
event - The mouse event.

mouseExited

public void mouseExited(java.awt.event.MouseEvent event)
Called when the mouse leaves this component. This base class does nothing when the exits this component. However, events _are_ handled by the components within this component.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
event - The mouse event.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
Called when the mouse is moved. This base class does nothing when the mouse is moved.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
event - Contains details of the movement event. However, events _are_ handled by the components within this component.

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
Store the location of the middle mouse event.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
event - The mouse event.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent event)
Called when the mouse is released. This base class does nothing when the mouse is moved. However, events _are_ handled by the components within this component.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
event - The mouse event.

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent event)
Scroll in when the mouse wheel is moved.

Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener
Parameters:
event - The mouse wheel event.

_initBasicGraphFrame

protected void _initBasicGraphFrame()
Initialize this BasicGraphFrame. Derived classes may call this method in their constructors.


_addMenus

protected void _addMenus()
Create the menus that are used by this frame.

Overrides:
_addMenus in class TableauFrame

_checkForImplied

protected boolean _checkForImplied(java.util.List<NamedObj> elements)
Return true if any element of the specified list is implied. An element is implied if its getDerivedLevel() method returns anything smaller than Integer.MAX_VALUE.

Parameters:
elements - A list of instances of NamedObj.
Returns:
True if any element in the list is implied.
See Also:
NamedObj.getDerivedLevel()

_close

protected boolean _close()
Override the base class to remove the listeners we have created when the frame closes. Specifically, remove our panner-updating listener from the entity. Also remove the listeners our graph model has created.

Overrides:
_close in class PtolemyFrame
Returns:
True if the close completes, and false otherwise.

_createDefaultLibrary

protected CompositeEntity _createDefaultLibrary(Workspace workspace)
Create the default library to use if an entity has no LibraryAttribute. Note that this is called in the constructor and therefore overrides in subclasses should not refer to any members that may not have been initialized. If no library is found in the configuration, then an empty one is created in the specified workspace.

Parameters:
workspace - The workspace in which to create the library, if one needs to be created.
Returns:
The new library, or null if there is no configuration.

_createFileMenuItems

protected javax.swing.JMenuItem[] _createFileMenuItems()
Create the items in the File menu. A null element in the array represents a separator in the menu. In this class, if the configuration contains a StringParmeter with the name "_exportPDFActionClassName", the then value of that parameter is assumed to name a class that extends AbstractAction and that export PDF. If there is no parameter by that name, then value returned by super._createFileMenuItems is returned.

Overrides:
_createFileMenuItems in class Top
Returns:
The items in the File menu, optionally include an "Export PDF" menu choice.

_createGraphPane

protected abstract GraphPane _createGraphPane(NamedObj entity)
Create a new graph pane. Subclasses will override this to change the pane that is created. Note that this method is called in constructor, so derived classes must be careful to not reference local variables that may not have yet been created.

Parameters:
entity - The object to be displayed in the pane.
Returns:
The pane that is created.

_createRightComponent

protected javax.swing.JComponent _createRightComponent(NamedObj entity)
Create the component that goes to the right of the library.

Parameters:
entity - The entity to display in the component.
Returns:
The component that goes to the right of the library.

_createSizeAttribute

protected SizeAttribute _createSizeAttribute()
                                      throws IllegalActionException,
                                             NameDuplicationException
Create a SizeAttribute for the current model when it is being saved to a file. The size recorded in the SizeAttribute is the size of the current canvas.

Returns:
The SizeAttribute.
Throws:
IllegalActionException - If "_vergilSize" is found but is not an instance of SizeAttribute, or if a SizeAttribute is not accepted by the current model.
NameDuplicationException - If the name "_vergilSize" is already used when trying to create the SizeAttribute.

_exportDesignPattern

protected void _exportDesignPattern(java.io.Writer writer,
                                    NamedObj model,
                                    java.lang.String name)
                             throws java.io.IOException
Export the model into the writer with the given name. If ptolemy.vergil.basic is set to true, then only the selected named objects are exported; otherwise, the whole model is exported with its exportMoML() method.

Parameters:
writer - The writer.
model - The model to export.
name - The name of the exported model.
Throws:
java.io.IOException - If an I/O error occurs.

_finishExportDesignPattern

protected void _finishExportDesignPattern()
Finish exporting a design pattern.


_getDirectory

protected java.io.File _getDirectory()
Get the directory that was last accessed by this window.

Returns:
The directory last accessed.
See Also:
_setDirectory(java.io.File)

_getGraphController

protected GraphController _getGraphController()
Return the graph controller associated with this frame.

Returns:
The graph controller associated with this frame.

_getGraphModel

protected AbstractBasicGraphModel _getGraphModel()
Return the graph model associated with this frame.

Returns:
The graph model associated with this frame.

_getRightComponent

protected javax.swing.JComponent _getRightComponent()
Return the right component on which graph editing occurs.

Returns:
The JGraph on which graph editing occurs.

_getSelectionSet

protected java.util.HashSet<NamedObj> _getSelectionSet()
Return a set of instances of NamedObj representing the objects that are currently selected. This set has no particular order to it. If you need the selection objects in proper order, as defined by the container, then call sortContainedObjects() on the container to sort the result.

Returns:
The set of selected objects.

_isDesignPattern

protected boolean _isDesignPattern()
Return true if this is a design pattern.

Returns:
true if the model corresponding to this object has a DesignPatternIcon attribute.

_prepareExportDesignPattern

protected void _prepareExportDesignPattern()
Prepare to export a design pattern. In this base class, do nothing.


_saveAsFileDialog

protected javax.swing.JFileChooser _saveAsFileDialog()
Create and return a file dialog for the "Save As" command. This overrides the base class to add options to the dialog.

Overrides:
_saveAsFileDialog in class PtolemyFrame
Returns:
A file dialog for save as.

_setDirectory

protected void _setDirectory(java.io.File directory)
Set the directory that was last accessed by this window.

Parameters:
directory - The directory last accessed.
See Also:
_getDirectory()

_setDropIntoEnabled

protected void _setDropIntoEnabled(boolean enable)
Enable or disable drop into.

Parameters:
enable - False to disable.

_writeFile

protected void _writeFile(java.io.File file)
                   throws java.io.IOException
Write the model to the specified file. This overrides the base class to record the current size and position of the window in the model.

Overrides:
_writeFile in class PtolemyFrame
Parameters:
file - The file to write to.
Throws:
java.io.IOException - If the write fails.

_deleteMoML

protected java.lang.StringBuffer _deleteMoML(AbstractBasicGraphModel graphModel,
                                             java.lang.Object[] selection,
                                             SelectionModel model)
Return the MoML to delete the specified selection objects. This has the side effect of unselecting the objects. It also deletes edges that are not fully connected (these deletions cannot be done through MoML, and cannot be undone).

Parameters:
graphModel - The graph model.
selection - The selection.
model - The selection model.
Returns:
The MoML to delete the selected objects.