com.nwoods.jgo
Class JGoView

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended bycom.nwoods.jgo.JGoView
All Implemented Interfaces:
org.eclipse.swt.events.ControlListener, org.eclipse.swt.events.DisposeListener, org.eclipse.swt.dnd.DragSourceListener, org.eclipse.swt.graphics.Drawable, org.eclipse.swt.dnd.DropTargetListener, java.util.EventListener, JGoDocumentListener, JGoObjectCollection, JGoObjectSimpleCollection, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.events.PaintListener, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.events.ShellListener, org.eclipse.swt.internal.SWTEventListener
Direct Known Subclasses:
JGoOverview, JGoPalette

public class JGoView
extends org.eclipse.swt.widgets.Composite
implements JGoObjectCollection, JGoDocumentListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.events.DisposeListener, org.eclipse.swt.events.PaintListener, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.dnd.DragSourceListener, org.eclipse.swt.dnd.DropTargetListener, org.eclipse.swt.events.ControlListener, org.eclipse.swt.events.ShellListener

JGoView is an SWT Control that supports the display and editing of graphical objects such as nodes and links.

JGoView supports the model-view-controller paradigm. JGoDocument is the model for JGoView.

JGoView supports many basic features:

Display

The primary purpose of JGoView is to display a JGoDocument and its JGoObjects. You can use the default JGoDocument that is created for the default JGoView constructor, or you can supply your own, either at construction or later.

A JGoView is just a regular SWT Control. The part of a JGoView that shows the document is called the canvas. A view can also have scroll bars. A view can have a border, but the canvas does not support one.

JGoView also supports the display of its own view-specific objects. Thus each view on the same document can have its own set of JGoObjects. These view objects will appear in front of all document objects. The most common example of view object is a selection handle (JGoHandle).

Painting

As an SWT Control, JGoView implements a PaintListener, paintControl, to render the view. It is responsible for scaling and translating the Graphics2D and getting a document-coordinates clipping rectangle. It then calls paintView(), which calls methods to fill in the paper color, to draw any additional background, to draw all of the document objects, and then to draw any view objects. You can override paintView() or any of the four methods called by paintView() in order to get different effects; overriding paintPaperColor() and paintBackgroundDecoration() are the most common. The paintBackgroundDecoration method is responsible for drawing the BackgroundImage, if any.

The JGoDocument's PaperColor property determines the background for all views unless the paper color is null, which it is by default. Thus the view's Background property specifies the background color for typical documents.

Printing

JGoView also provides support for printing. The print() method brings up the print dialog and then starts a PrinterJob. You can easily override getPrintDocumentSize(), getPrintPageRect(), and getPrintScale() to customize how much is printed, on how much of the page, and at what scale. Override printDecoration() to add headers and/or footers or any other decoration on each page. Override printView(), like paintView(), to change what things get printed--by default the paper color and the view objects are not printed.

Scrolling

JGoView has support for scrolling and scroll bars built in. By default there will be both a horizontal and a vertical scroll bar, but you can remove one or both of them by setting the respective properties to null. There is also a separate corner component, where the two scroll bars meet, that is visible when both scroll bars are visible.

Of course users can scroll the view by manipulating the scroll bars. When drag-and-drop is enabled, users can also cause automatic scrolling when they are dragging near the edge of the canvas. This autoscroll region is specified by the AutoscrollInsets property.

Because a view does not show the whole document, the ViewPosition property indicates where the view's top-left corner is in the document. The ExtentSize property indicates the size of the view's canvas in the document.

Scaling and Coordinate Systems

JGoView also supports zooming, to change the scale at which the objects are drawn. The Scale property is normally 1; smaller values make objects appear smaller on the screen; larger values correspond to zooming into the diagram.

The ability to scroll and zoom the view means that the coordinate system used in a view is different from that used in the document. The convertDocToView() and convertViewToDoc() methods perform the basic transformations of Points, Dimensions, and Rectangles. The docToViewCoords() and viewToDocCoords() methods do the same, but can be less efficient to use because they allocate new objects for the return values.

Selection

Each JGoView has a JGoSelection that holds the currently selected document objects for that view. The default selection object is an instance of JGoSelection, but you can override createDefaultSelection(). The selection object is also responsible managing selection handles in the view. Many methods in JGoView deal with the current selection, either by changing it, or by operating on its collection of objects. Important examples include: cut(), copy(), deleteSelection(), moveSelection() and selectAll().

Events

JGoView is a JGoDocumentListener, which is how it can keep its display up-to-date with changes to the document and its objects. JGoView also has view-specific state that other objects may care about tracking. Thus a JGoView will notify its JGoViewListeners about any JGoViewEvents. Such events include:

High Level Mouse Events

One of the more important functions of JGoView is to handle mouse clicks. Depending on the state of the view, where the click happens, and any event modifiers, the selection may change or the click will get passed on to any object on top underneath that point. This will cause JGoViewEvents to be fired off to any interested listeners, and will call doMouseClick() or doMouseDblClick(). This method then calls the method of the same name on the object and on its parents up to the top-level object until a call returns true, indicating that it completely handled the single-click or double-click.

Similarly, when the mouse moves without any mouse button being held down, doUncapturedMouseMove() is called, which in turn calls doUncapturedMouseMove() on the object underneath that point, and on up the parent chain until a call returns true. Getting a tool tip text is also similar, in that the view passes the request down to a particular object at that point, and to its parents, until it gets a non-null string.

Resizing

Views also have default behavior for resizing objects. When the user does a mouse down on a selection handle, the view goes into resizing mode. This causes the handleResizing() method to be called while the mouse is dragging the selection handle. This method in turn calls the handleResize() method on the selected object, assuming it isResizable(). The object can then decide how to interpret the resize request. JGoView's default behavior is to draw an XOR box during the resizing, and to reshape the object when the resizing is done. If the user cancels the resizing with the Escape key, the object is restored to its original size and position.

Creating Links

Another important JGoView feature is the support for the user creating links between ports by "dragging" from a JGoPort to another one. The startNewLink() method uses validSourcePort() and validDestinationPort() to see if the port under the mouse point will permit the user's starting a new link. If so, the view creates a temporary port and a temporary link from the port to the temporary port. While the user remains in this creating-a-new-link mode, the temporary port is continuously moved to follow the mouse.

Furthermore the view checks to see which ports to which it could make a valid new link, by calling validLink() for all potential pairs of ports involving the original one. The default implementation of validLink() just asks the "from" port if it can be linked to the "to" port; this allows the behavior to be overridden either in the port class or in the view. You may want to investigate properties on JGoPort that have "valid" in their names, as well as JGoDocument's ValidCycle property.

To make drawing links easier for the user, there is also the notion of "port gravity", a distance. The temporary port automatically snaps to the location of the closest valid port within the port gravity distance.

Finally, when the user releases the mouse to create the link, the newLink() method is called. This method is responsible for creating the real JGoLink in the document connecting the two ports; the temporary port and link are discarded. If for some reason the link is not made, because the attempted link was invalid or because the user cancelled the link drawing process, the noNewLink() method is called. This allows views to clean up any other state or inform the user or do some other default failure action.

There are also methods to support modifying an existing link to allow interactive reconnection to a potentially different port. The startReLink method is similar to the startNewLink method. Upon the user's mouse-up, the reLink or noReLink methods are called instead of newLink or noNewLink.

Drag and Drop

JGoView has a default behavior for drag-and-drop. Each view can act as both a drag source and as a drop target. Within a view, a drag moves the selected objects; between views a drag and drop copies the selected objects, and from another drag source the view can decide to accept the drop and to handle it in an application specific manner. If the user cancels a drag from a JGoView, the selected objects are restored to their original locations.

To customize a view as a drop target, you'll want to override some methods: computeAcceptableDrop and onExternalDrop. If you want to make use of the default copy behavior for JGoSelection, you can call doDrop from your override of onExternalDrop. If you need somewhat more extensive customization, you can just override all the standard DropTargetListener methods.

The user can copy objects as well as move them, depending on whether the CTRL key is held down at the time of the drop. The default behavior now allows both copy and move; you can limit the behavior not to allow copying by calling setInternalMouseActions(DND.DROP_MOVE).

An internal drag, when the CTRL key is held down, makes an image copy of the current selection and drags it around to follow the mouse. The selection is left at its original position, or is moved back to that position if it had been drag-moved. When the drop-copy happens, the original selection is copied by calling the document's copyFromCollection method. The newly added objects become the new selection.

You can control whether a view handles any mouse events or any drag-and-drop behavior by setting the MouseEnabled, DragEnabled, and DropEnabled properties.

The DragEnabled property controls whether a drag gesture listener operates to start a drag-and-drop operation from the view; the DropEnabled property controls whether a drop can occur in the view from any window. Note that both need to be true for a drag-and-drop to occur internally within the view. Setting both to false may still allow internal moves and/or copies within a view, depending on whether isMouseEnabled() is still true and whether the selected objects may be dragged and the value of getInternalMouseActions().

Two other properties relating to dragging are DragsRealtime and DragsSelectionImage. The former controls whether selected objects are actually moved while the user drags them. The latter controls whether the user drags an image of the selection when drag-copying or when isDragsRealtime() is false, instead of dragging an outline.

Clipboard

JGoView supports copying the selection to and from the system clipboard; use the copy(), cut(), and paste() methods. These methods, like the default drag-and-drop implementation, use the JGoTransfer type to describe the data, which is a separate JGoDocument with copies of the selection copied by the document's copyFromCollection() method.

The paste() method selects all of the newly copied objects that have been pasted into this view's document. This makes it easier to define a JGoViewEvent.CLIPBOARD_PASTED or JGoViewEvent.EXTERNAL_OBJECTS_DROPPED event handler that modifies those newly created objects.

In-place Text Editing

Another handy feature that JGoView offers is in-place text editing. If a JGoText object is editable, then clicking on it may put it into editing mode, where the user can change the string. This is accomplished by creating a temporary JGoTextEdit object in this view and having it be responsible for actually creating and displaying an SWT Text Control and handling its editing completion or cancellation. The JGoTextEdit object is held as a property of the view. Use doEndEdit() to stop any in-place text editing in progress.

Keyboard Commands

A view can accept keyboard focus and can respond to several keyboard commands by default. Override onKeyEvent() to change or augment the default commands. You can control whether there is any default key event handling by setting the KeyEnabled property.

The getDocumentSize method includes objects that are at negative coordinate positions. The getDocumentTopLeft method has been added so that you can tell where the document now starts; by default this just returns the document's documentTopLeft property. Both of these methods values are affected by the includingNegativeCoords property. When the includingNegativeCoords property is false, the documentTopLeft property is always (0,0) and the documentSize property is shrunk accordingly from the document's documentSize property. The default value for includingNegativeCoords is false, which is compatible with earlier versions.

Similarly, for printing, getPrintDocumentSize method has different behavior when isIncludingNegativeCoords() is true, and the getPrintDocumentTopLeft method has been added.

"Mode"

The current mouse state accessible, along with various constants describing pre-defined states. These include MouseStateNone (the default state), MouseStateMove, MouseStateCreateLink, MouseStateResize, and MouseStateDragBoxSelection, among others. By defining your own state identifiers greater than MouseStateLast, you can override the doMouseDown, doMouseMove, doMouseUp, and doCancelMouse methods to control how the view responds to the user. In addition to making the State property public, a view has a CurrentObject property that makes accessible the JGoObject that some mouse handling states operate on.

Version 5.1 adds a new state, MouseStateAction, to support direct interaction with JGoActionObjects. The JGoActionObject interface allows document objects to preempt the mouse down/move/up events that would otherwise cause the JGoView to enter other states such as MouseStateMove or MouseStateResize. This might be used by a button, wholly implemented with JGoObjects, that wants to support being clicked by the user rather than being selected and dragged or resized or whatever. Furthermore this interface support continuous feedback during mouse moves. A knob, for example, could be turned by the user.

The doMouseDown method first calls the pickActionObject method. If that method returns a JGoActionObject, doMouseDown calls the startActionObject method to activate the object and to set the view's state to MouseStateAction. Then doMouseMove and doMouseUp will call handleActionObject: mouse moves cause the action object to be adjusted by calls to onActionAdjusted; a mouse up invokes the action object's action by a call to onAction.

Grids

A view has many "grid" features, governing both appearance and behavior. One of several styles of grids can be drawn: Invisible, Dot, Cross, Line. You can set the origin and horizontal and vertical spacing of the grid points, and you can specify the JGoPen that is used to draw the grid.

The objects on display in this view can be set to snap to a particular grid point, either when moving or when resizing. You can also specify the object spot that needs to be snapped to the grid point; this defaults to JGoObject.TopLeft.

When the grid style is GridInvisible and the SnapMove and SnapResize are NoSnap, which are the default values for those properties, a JGoView appears and behaves as if there were no grid.

JGoView is not thread-safe.

See Also:
JGoDocument, JGoViewEvent, JGoViewListener, JGoObject, JGoObjectCollection, JGoSelection

Field Summary
static int ChangedDimensions
          a flag indicating that the dimensions (distance between grid points) has changed
static int ChangedOrigin
          a flag indicating that the grid's origin has changed
static int ChangedPen
          a flag indicating that the pen used for drawing the grid has changed
static int ChangedSnapMove
          a flag indicating that the object moving snapping style has changed
static int ChangedSnapResize
          a flag indicating that the object resizing snapping style has changed
static int ChangedSpot
          a flag indicating that the object spot has changed
static int ChangedStyle
          a flag indicating that the grid style has changed
static int DebugEvents
          A flag used for debugging TRACE messages: drag-and-drop events
static int EventMouseDown
          A mouse state indicator used by handleResizing and drawXORBox
static int EventMouseMove
          A mouse state indicator used by handleResizing and drawXORBox
static int EventMouseUp
          A mouse state indicator used by handleResizing and drawXORBox
static int GridCross
          Display small grid line crosses at each grid point
static int GridDot
          Display dots at each grid point
static int GridInvisible
          Don't display any grid at all
static int GridLine
          Display the grid as lines
static int MouseStateAction
          The mouse state when the user is acting on a JGoActionObject
static int MouseStateCreateLink
          The mouse state when the user is drawing a new link starting at a source port
static int MouseStateCreateLinkFrom
          The mouse state when the user is drawing a new link starting at a destination port
static int MouseStateDragBoxSelection
          The mouse state when the user is drawing a rubber-band selection box
static int MouseStateLast
          If you define your own state, make sure the value is greater than this.
static int MouseStateMove
          The mouse state when the user is dragging objects, for moving or copying
static int MouseStateNone
          The mouse state when the user isn't doing much with the mouse
static int MouseStateResize
          The mouse state when the user is resizing an object
static int MouseStateSelection
          The mouse state when the user may be selecting something, and might drag it
static int NoSnap
          Move or resize objects smoothly, ignoring any grid points.
static int SnapAfter
          Move or resize objects to a grid point after release; objects move or resize smoothly while being dragged.
static int SnapJump
          Move or resize objects to a grid point while being dragged.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
JGoView(org.eclipse.swt.widgets.Composite parent, int style)
          Construct a new view of a document returned by calling createDefaultModel()
JGoView(org.eclipse.swt.widgets.Composite parent, int style, JGoDocument doc)
          Construct a new view of a JGoDocument.
 
Method Summary
 void addDocumentListener(JGoDocumentListener l)
          Add a listener for JGoDocument events, such as changes to a JGoObject's properties or to a JGoObject having been added or removed from a JGoLayer.
 JGoListPosition addObjectAtHead(JGoObject obj)
          Adds an object behind all other objects in the view.
 JGoListPosition addObjectAtTail(JGoObject obj)
          Adds an object in front of all other objects in the view.
 void addViewListener(JGoViewListener l)
          Add a listener for JGoViewEvents, such as clicking on objects or in the background, or a link having been drawn by the user, or property changes on this JGoView.
 void applyRenderingHints(Graphics2D g2)
          Set the standard RenderingHints for how shapes, images, and text are drawn.
 void bringObjectToFront(JGoObject obj)
          Moves an object in front of other objects in the view (moved to the end of the list of objects).
 boolean canPaste()
          Return true if the document's DefaultLayer is Modifiable and if there is JGo data in the clipboard.
 int computeAcceptableDrop(org.eclipse.swt.dnd.DropTargetEvent event)
          Determine the permitted drag-and-drop operation for external drag-and-drops (from a different control).
 org.eclipse.swt.graphics.Point computeAutoscrollViewPosition(org.eclipse.swt.graphics.Point viewPnt)
          This method is called to determine the next position in the document for this view, given a point at which the user is dragging the mouse.
 java.util.ArrayList computeEffectiveSelection(JGoObjectSimpleCollection coll)
          Try to avoid problems with double-moving due to duplicate entries or both a parent and its child being in the argument collection.
 java.util.ArrayList computeEffectiveSelection(JGoObjectSimpleCollection coll, boolean move, boolean includelinks)
          Try to avoid problems with double-moving due to duplicate entries or both a parent and its child being in the argument collection.
 org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint)
          The preferred size for a view normally comes from the document.
 org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
          The preferred size for a view normally comes from the document, getDocumentSize(), scaled by this view's current scale.
 void controlMoved(org.eclipse.swt.events.ControlEvent e)
           
 void controlResized(org.eclipse.swt.events.ControlEvent e)
           
 int convertActionToModifiers(int action)
          This method converts a DropTarget event's dropAction to an InputEvent's modifiers.
 void convertDocToView(Dimension d)
          Convert a Dimension in document coordinates to view coordinates.
 void convertDocToView(org.eclipse.swt.graphics.Point p)
          Convert a Point in document coordinates to view coordinates.
 void convertDocToView(org.eclipse.swt.graphics.Rectangle r)
          Convert a Rectangle in document coordinates to view coordinates.
 void convertViewToDoc(Dimension d)
          Convert a Dimension in view coordinates to document coordinates.
 void convertViewToDoc(org.eclipse.swt.graphics.Point p)
          Convert a Point in view coordinates to document coordinates.
 void convertViewToDoc(org.eclipse.swt.graphics.Rectangle r)
          Convert a Rectangle in view coordinates to document coordinates.
 void copy()
          Copy the document objects in the current selection to the system clipboard.
 void copySelection(JGoSelection sel, int modifiers, int offsetx, int offsety, int event)
          Make copies of all currently selected objects and add them to this document at positions adjusted by the given offset.
 void copyToClipboard(org.eclipse.swt.dnd.Clipboard clipboard)
          Copy document objects from the current selection to the given clipboard.
 JGoDocument createDefaultModel()
          The default model is an instance of JGoDocument.
 JGoSelection createDefaultSelection()
          Create an instance of a JGoSelection.
protected  JGoLink createTemporaryLinkForNewLink(JGoPort from, JGoPort to)
          Return a temporary link used by the user-invoked link creating routines.
protected  JGoPort createTemporaryPortForNewLink(JGoPort port, org.eclipse.swt.graphics.Point dc)
          Return a temporary port used by the user-invoked link creating or reconnecting routines.
 void cut()
          Copy the current selection to the system clipboard and then remove the selected objects from the document.
 void deleteSelection()
          Remove the objects of the current selection from the document without copying them to the clipboard.
 void disposeJGoGraphics(Graphics2D g)
          This convenience function disposes the Graphics object that is passed, or is a no-op if the object is null.
 void doAutoscroll(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          This is responsible for checking and initiating any autoscrolling action.
 void doBackgroundClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          This method is called when a click happens in the canvas and there is no object underneath and there is no selection.
 void doBackgroundToolTip(org.eclipse.swt.events.MouseEvent e)
          This is called by doUncapturedMouseMove when the mouse is not over any object.
 void doCancelMouse()
          When one needs to cancel any mouse operation, this function restores the view to the normal state.
 void doCancelMoveSelection(org.eclipse.swt.graphics.Point offset)
          Called when the user's dragging of the current selection is cancelled.
 void doCancelResize(org.eclipse.swt.graphics.Rectangle orig)
          Called when the user's resizing of an object is cancelled.
 Dimension docToViewCoords(Dimension d)
          Convert document dimensions to view coordinates.
 org.eclipse.swt.graphics.Rectangle docToViewCoords(int x, int y, int w, int h)
          Convert a rectangle in document coordinates to a rectangle in view coordinates.
 org.eclipse.swt.graphics.Point docToViewCoords(org.eclipse.swt.graphics.Point d)
          Convert a point from document coordinates to view coordinates.
 org.eclipse.swt.graphics.Rectangle docToViewCoords(org.eclipse.swt.graphics.Point p, Dimension d)
          Convert a rectangle in document coordinates to a rectangle in view coordinates.
 org.eclipse.swt.graphics.Rectangle docToViewCoords(org.eclipse.swt.graphics.Rectangle d)
          Convert a rectangle in document coordinates to a rectangle in document coordinates.
 void documentChanged(JGoDocumentEvent evt)
          This method is called whenever a document modification occurs that may require the view to repaint some portion of itself.
 boolean doDrop(org.eclipse.swt.dnd.DropTargetEvent e, JGoCopyEnvironment copyenv)
          Perform the default drop operation to copy a JGoObjectSimpleCollection into this view's document, as a result of a DropTargetListener.drop(DropTargetEvent).
 void doEndEdit()
          Tell any edit control (JGoTextEdit) that it's time to stop being in edit mode.
 void doLayout()
          Update the ScrollBar PageIncrements as well as the rest of the ScrollBar properties.
 boolean doMouseClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          Handle single click behavior for an object in the document.
 boolean doMouseDblClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          Handle double click behavior for an object in the document.
 boolean doMouseDown(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          Called when a mouse button is pressed.
 boolean doMouseMove(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          Called when the mouse is moved.
 boolean doMouseUp(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          Performs the required processing when the mouse button is released.
 void doMoveSelection(int modifiers, int offsetx, int offsety, int event)
          Moves all currently selected draggable objects by the given offset.
 void doToolTip(org.eclipse.swt.events.MouseEvent e)
          This is called on a mouse hover event, to call getToolTipText(MouseEvent) to decide whether to display a tooltip.
 void doUncapturedMouseMove(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          This method is called when the mouse is moved over the canvas and no other mouse behavior is happening.
protected  void dragAccept(org.eclipse.swt.dnd.DragSourceEvent event)
          This method is called by dragStart to cancel the drag-and-drop operation if it is not needed for the particular state this JGoView is in.
 void dragEnter(org.eclipse.swt.dnd.DropTargetEvent event)
          This DropTargetListener method handles drag-and-drop operations that originated in other windows or that are internal and may be returning to this control.
 void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event)
          This DragSourceListener method calls doCancelMouse for internal drag-and-drops.
 void dragLeave(org.eclipse.swt.dnd.DropTargetEvent event)
          This DropTargetListener method stops any autoscrolling.
 void dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent event)
          This DropTargetListener method handles changes to the modifier keys during a drag-and-drop.
 void dragOver(org.eclipse.swt.dnd.DropTargetEvent event)
          This DropTargetListener method handles drag-and-drop operations that originated in any control, including this view.
 void dragSetData(org.eclipse.swt.dnd.DragSourceEvent event)
          This DragSourceListener method serializes the Selection as the data for the transfer to the drop target.
 void dragStart(org.eclipse.swt.dnd.DragSourceEvent event)
          This DragSourceListener method starts an internal drag-and-drop.
protected  void drawGridCrosses(Graphics2D g, int crossHeight, int crossWidth, org.eclipse.swt.graphics.Rectangle clipRect)
          This method draws little crosses at the grid points.
protected  void drawGridLines(Graphics2D g, org.eclipse.swt.graphics.Rectangle clipRect)
          This method draws grid lines.
protected  void drawXORBox(Graphics2D g, int corner1x, int corner1y, int corner2x, int corner2y, int event)
          Draw an XOR'ed rectangle on the view screen given two opposite corners.
protected  void drawXORRect(Graphics2D g, int x, int y, int w, int h)
          Performs the actual drawing of the XOR'ed rectangle.
 void drop(org.eclipse.swt.dnd.DropTargetEvent event)
          This implements the default drop target listener.
 void dropAccept(org.eclipse.swt.dnd.DropTargetEvent event)
          This DropTargetListener method rejects the drop if isDropEnabled() is false.
 org.eclipse.swt.graphics.Point findNearestGridPoint(int x, int y, org.eclipse.swt.graphics.Point result)
          Find the grid point that is closest to the given point
 JGoListPosition findObject(JGoObject obj)
          Return the position of a specific object in the collection.
 void fireUpdate(int hint, int flags, java.lang.Object x)
          Call this method whenever an event occurs in the view that may require the view to repaint some portion of itself or perform other processing.
 void fireUpdate(int hint, int flags, java.lang.Object x, org.eclipse.swt.graphics.Point vc, org.eclipse.swt.graphics.Point dc, int modifiers)
          This method is called whenever an event occurs in the view that may require the view to repaint some portion of itself or perform other processing.
 Insets getAutoscrollInsets()
          Returns the inset margins in which autoscrolling will occur.
 org.eclipse.swt.graphics.RGB getBackgroundColor()
           
 org.eclipse.swt.graphics.Image getBackgroundImage()
          Return the Image displayed in the background of this view.
protected  org.eclipse.swt.events.MouseEvent getCurrentMouseEvent()
          Return the MouseEvent associated with the ongoing doMouseDown, doMouseMove, doMouseUp, doMouseClick, doMouseDblClick, or doUncapturedMouseMove methods.
 JGoObject getCurrentObject()
          Return the current JGoObject, if any, associated with any mouse event handling.
 int getCursorType()
           
 int getDebugFlags()
          Return the conditions under which this view generates TRACE messages.
 int getDefaultCursorType()
           
static int getDefaultPortGravity()
          Return the default distance at which a link will snap to a port.
static org.eclipse.swt.graphics.RGB getDefaultPrimarySelectionColor()
          Return the default primary selection color.
static org.eclipse.swt.graphics.RGB getDefaultSecondarySelectionColor()
          Return the default secondary selection color.
 JGoDocument getDocument()
          Gets the document model associated with this view.
 JGoDocumentListener[] getDocumentListeners()
          Return an array of the JGoDocumentListeners that are currently listening for JGoDocumentEvents on this view's JGoDocument.
 Dimension getDocumentSize()
          Return the size of the document as seen by this view.
 org.eclipse.swt.graphics.Point getDocumentTopLeft()
          Return the top-left corner of the document as seen by this view.
 org.eclipse.swt.dnd.DragSource getDragSource()
           
 org.eclipse.swt.dnd.DropTarget getDropTarget()
           
 JGoTextEdit getEditControl()
          This returns the single JGoTextEdit that is used for in-place editing for this whole view.
 java.lang.String getEditPresentationName(int act)
          Return a name for each of the different kinds of actions that this view provides, suitable for an UndoableEdit's presentation name.
 Dimension getExtentSize()
          Return the size in document coordinates of what is shown in the view.
 JGoLayer getFirstLayer()
          Return the bottom-most layer of objects in this document.
 JGoListPosition getFirstObjectPos()
          Return the position of the first object in the collection.
 int getGridHeight()
          Get the vertical spacing of the grid.
 org.eclipse.swt.graphics.Point getGridOrigin()
          Return the current origin for the grid.
 JGoPen getGridPen()
          Get the pen that is currently used for drawing the grid's dots, crosses or lines.
 int getGridSpot()
          Get which spot on the objects will be snapped to the nearest grid point.
 int getGridStyle()
          Return the current style of the grid.
 int getGridWidth()
          Returns the horizontal spacing of the grid.
 int getInternalMouseActions()
          Return which kinds of drag-and-drop actions are permitted for mouse drags that start and end in this view.
 Graphics2D getJGoGraphics()
          This convenience function returns a Graphics2D object for painting on the view's canvas.
 JGoLayer getLastLayer()
          Return the top-most layer of objects in this document.
 JGoListPosition getLastObjectPos()
          Return the position of the last object in the collection.
 JGoLayer getNextLayer(JGoLayer layer)
          Return the layer just above the given layer.
 JGoListPosition getNextObjectPos(JGoListPosition pos)
          Return the position for the next object in the collection.
 JGoListPosition getNextObjectPosAtTop(JGoListPosition pos)
          Return the position for the next top-level object in the collection.
 int getNumObjects()
          Returns the number of top-level objects in the view only.
 JGoObject getObjectAtPos(JGoListPosition pos)
          Return the object for the given position.
 int getPortGravity()
          Return the port gravity for this view.
 JGoLayer getPrevLayer(JGoLayer layer)
          Return the layer just below the given layer.
 JGoListPosition getPrevObjectPos(JGoListPosition pos)
          Return the position of the previous object in the collection.
 org.eclipse.swt.graphics.RGB getPrimarySelectionColor()
          Returns the primary selection color.
 Dimension getPrintDocumentSize()
          Return the size of the document to be printed, in document coordinates.
 org.eclipse.swt.graphics.Point getPrintDocumentTopLeft()
          This method returns the coordinates of the document's top-left corner, where printing should start from.
protected  org.eclipse.swt.graphics.Rectangle getPrintPageRect(Graphics2D g2, org.eclipse.swt.printing.Printer p)
          Return the bounds for the part of the print page that should hold the rendered graph.
protected  double getPrintScale(Graphics2D g2, org.eclipse.swt.printing.Printer p)
          Return the scale at which the graph should be printed.
 double getScale()
          Return the current scale at which JGoObjects are displayed.
 org.eclipse.swt.graphics.RGB getSecondarySelectionColor()
          Returns the secondary selection color.
 JGoSelection getSelection()
          Return the object representing the selection for this view.
 int getSnapMove()
          Return the current policy when objects are moved.
 int getSnapResize()
          Return the current policy when objects are resized.
 int getState()
          Return the current state of this view in its handling of the mouse.
 java.lang.String getToolTipText(org.eclipse.swt.events.MouseEvent evt)
          Implement tooltips for JGoObjects by finding the object at the given point as specified by the MouseEvent, and asking for it's tooltip.
 JGoViewListener[] getViewListeners()
          Return an array of the JGoViewListeners that are currently listening for JGoViewEvents on this view.
 org.eclipse.swt.graphics.Point getViewPosition()
          Return the position in the document of the top-left point of the view.
 org.eclipse.swt.graphics.Rectangle getViewRect()
          Return a rectangle whose origin is getViewPosition() and size is getExtentSize().
 void handleActionObject(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc, int event)
          Handle further mouse events on a JGoActionObject.
protected  void handleResizing(Graphics2D g, org.eclipse.swt.graphics.Point vc, org.eclipse.swt.graphics.Point dc, int event)
          This method is called in resize mode as the user is dragging a resize handle.
 void initializeDragDropHandling()
          This initializes drag and drop handling, both as a source and as a target.
protected  void initializeMouseHandling()
          This initializes the handling of mouse events.
 JGoListPosition insertObjectAfter(JGoListPosition pos, JGoObject obj)
          Adds an object to the view after the given position.
 JGoListPosition insertObjectBefore(JGoListPosition pos, JGoObject obj)
          Adds an object to the view before the given position.
 boolean isDragDropEnabled()
          Return whether the drag-and-drop mechanism is enabled for this view, equivalent to isDragEnabled() && isDropEnabled().
 boolean isDragEnabled()
          Return whether the drag gesture listener is enabled, to allow users to start a drag-and-drop operation from this view.
 boolean isDragsRealtime()
          Gets whether a user's drag of objects in this view actually moves the objects continuously, rather than dragging around an outline or an image of the selected objects.
 boolean isDragsSelectionImage()
          Gets whether the selection being copied or dragged is displayed as an image or with an outline.
 boolean isDrawsXorMode()
          Returns whether drawXORBox uses drawXORRect to really draw a rectangle using XOR mode, rather than simulating the rectangle using regular drawing.
 boolean isDropEnabled()
          Return whether the drop target listener is enabled, to allow users to perform a drop operation to this view.
 boolean isEditingTextControl()
          Return true if the user is in the midst of in-place text editing.
 boolean isEmpty()
          Returns true if the view contains no (view-only) objects.
 boolean isHidingDisabledScrollbars()
          This predicate is true when a scroll bars should disappear when the view is big enough to show the whole document range for that scroll bar.
 boolean isIgnoreNextMouseDown()
          Return whether the view's mouse pressed handler will ignore the next mouse pressed event.
 boolean isIncludingNegativeCoords()
          This predicate is true when the view may show parts of a document that are at negative document coordinates.
 boolean isInternalDragDrop()
          Return whether a dragging operation started within this JGoView or is coming from another window.
 boolean isKeyEnabled()
          Return true if keyboard key strokes are handled normally, or return false if those events are ignored.
 boolean isMouseEnabled()
          Return true if mouse presses, drags, releases, and clicks are handled normally or return false if those actions are ignored.
 boolean isPrinting()
          This predicate is true while printView is called.
protected  boolean keyClearSelection(int modifiers)
          Return true if the state of the modifier keys indicates that we should clear the selection when a click occurs on the background.
protected  boolean keyExtendSelection(int modifiers)
          Return true if the modifiers keys indicate that a click on an object should add the current object to the selection.
protected  boolean keyMultipleSelect(int modifiers)
          Deprecated. -- replaced by keyExtendSelection and keyToggleSelection
 void keyPressed(org.eclipse.swt.events.KeyEvent evt)
          This method implements KeyListener.
 void keyReleased(org.eclipse.swt.events.KeyEvent evt)
          This method implements KeyListener as a no-op.
protected  boolean keySingleSelection(int modifiers)
          Return true if clicking on an object should make it the only selected object.
protected  boolean keyToggleSelection(int modifiers)
          Return true if the state of the modifier keys indicates whether we should deselect a selected object or select an unselected object.
 void keyTyped(org.eclipse.swt.events.KeyEvent evt)
          This method implements KeyListener as a no-op.
 double limitScale(double s)
          This method is called by the setScale method to make sure that the view only displays objects at a reasonable scale.
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent evt)
          This is the internal event handler for mouse up events.
 void mouseDown(org.eclipse.swt.events.MouseEvent evt)
          This is the internal event handler for mouse down events.
 void mouseEnter(org.eclipse.swt.events.MouseEvent e)
          This MouseTrackListener method by default does nothing.
 void mouseExit(org.eclipse.swt.events.MouseEvent e)
          This MouseTrackListener method by default just calls stopAutoscroll.
 void mouseHover(org.eclipse.swt.events.MouseEvent e)
          This MouseTrackListener method by default just calls doToolTip.
 void mouseMove(org.eclipse.swt.events.MouseEvent evt)
          This is the internal event handler for mouse motion non-drag events.
 void mouseUp(org.eclipse.swt.events.MouseEvent evt)
          This is the internal event handler for mouse up events.
 void moveSelection(JGoSelection sel, int modifiers, int offsetx, int offsety, int event)
          Moves all currently selected draggable objects of modifiable layers by the given offset.
 void newLink(JGoPort from, JGoPort to)
          Called to create a new link from the from port to the to port.
protected  void noNewLink(JGoPort from, JGoPort to)
          Called when a link creation failed.
protected  void noReLink(JGoLink oldlink, JGoPort from, JGoPort to)
          Called when a link reconnection failed.
 void onExternalDragOver(org.eclipse.swt.dnd.DropTargetEvent event)
          This is called for drag-and-drop operations that originated in a different control.
 void onExternalDrop(org.eclipse.swt.dnd.DropTargetEvent event)
          This is called for drag-and-drop operations that originated in a different control.
 void onGridChange(int what)
          Called when some characteristic of the grid has changed.
 void onKeyEvent(org.eclipse.swt.events.KeyEvent evt)
          This is the default event handler for keystroke commands.
protected  void paintBackgroundDecoration(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
          Draw any background image or decorations before any of the document or the view objects are drawn.
 void paintControl(org.eclipse.swt.events.PaintEvent evt)
          This method is invoked by the paintListener.
protected  void paintDocumentObjects(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
          Draw all of the visible document objects that intersect the given clipping rectangle.
protected  void paintPaperColor(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
          Fill the background with the with the document's paper color.
protected  void paintView(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
          Render everything for this view that is within a given rectangle.
protected  void paintViewObjects(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
          Draw all of the visible view objects that intersect the given clipping rectangle.
 void paste()
          Copy JGoObjects from the system clipboard into this document.
 JGoCopyEnvironment pasteFromClipboard(org.eclipse.swt.dnd.Clipboard clipboard)
          Copy JGoObjects from the clipboard into this document.
 JGoActionObject pickActionObject(org.eclipse.swt.graphics.Point dc)
          Return a JGoActionObject that is in the document at a given point.
 JGoObject pickDocObject(org.eclipse.swt.graphics.Point pointToCheck, boolean selectableOnly)
          Find the topmost object in the document under the given point.
protected  JGoHandle pickHandle(org.eclipse.swt.graphics.Point point)
          Return a JGoHandle under the given document coordinate point.
 JGoPort pickNearestPort(org.eclipse.swt.graphics.Point dc)
          Return the nearest valid port to the given position in the document while the user is in the midst of drawing a new link.
 JGoObject pickObject(org.eclipse.swt.graphics.Point pointToCheck, boolean selectableOnly)
          Find the topmost view object under the given point.
protected  JGoPort pickPort(org.eclipse.swt.graphics.Point dc)
          Return a JGoPort under the given document coordinate point.
 void print()
          Call this to print the current view.
 int print(Graphics2D g, org.eclipse.swt.printing.Printer p, int pnum)
          This method is called repeatedly by the print() method, once for each page that should be printed.
protected  void printBegin(Graphics2D g2, org.eclipse.swt.printing.Printer p)
          Because there may be many calls to Printable.print for each document, we calculate a number of values once and remember their values.
protected  void printDecoration(Graphics2D g2, org.eclipse.swt.printing.Printer p, int hpnum, int vpnum)
          Print any decorations on each page.
protected  void printEnd(Graphics2D g2, org.eclipse.swt.printing.Printer p)
          Called at the end of printing and before any new printing operation; allows printBegin to reinitialize its precalculated values for the next printing operation.
protected  void printView(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
          This is called to print everything for this view that is within the given rectangle in document coordinates.
 void reLink(JGoLink oldlink, JGoPort from, JGoPort to)
          Called to reconnect an existing link from the from port to the to port.
 void removeDocumentListener(JGoDocumentListener l)
          Remove a listener for JGoDocument events.
 void removeObject(JGoObject obj)
          Removes an object from the view.
 JGoObject removeObjectAtPos(JGoListPosition pos)
          Remove an object at specified position from the collection.
 void removeViewListener(JGoViewListener l)
          Remove a listener for JGoViewEvents.
 void scrollRectToVisible(org.eclipse.swt.graphics.Rectangle contentRect)
          Scroll the view so that the given rectangle in document coordinates is at least partly visible (i.e., within getViewRect()).
 void selectAll()
          Select all the top-level, visible, selectable objects in the document.
 void selectInBox(org.eclipse.swt.graphics.Rectangle rect)
          Select all visible, selectable objects in the document that are within the given rectangle.
 JGoObject selectObject(JGoObject obj)
          Make the given object the one and only selected object in this view.
 void sendObjectToBack(JGoObject obj)
          Moves an object behind other objects in the view (moved to the head of the list of objects).
 void setAutoscrollInsets(Insets insets)
          Set the canvas's Autoscroll Insets.
 void setBackgroundColor(org.eclipse.swt.graphics.RGB c)
           
 void setBackgroundImage(org.eclipse.swt.graphics.Image img)
          Set the Image displayed in the background.
 void setCurrentObject(JGoObject obj)
          Change the current JGoObject, if any, associated with any mouse event handling.
 void setCursorType(int c)
           
 void setDebugFlags(int f)
          Control whether this view generates TRACE messages during various operations.
 void setDefaultCursorType(int cursor)
           
static void setDefaultPortGravity(int gravity)
          Set the default distance at which a link will snap to a port.
static void setDefaultPrimarySelectionColor(org.eclipse.swt.graphics.RGB c)
          Set the default primary selection color.
static void setDefaultSecondarySelectionColor(org.eclipse.swt.graphics.RGB c)
          Set the default secondary selection color.
 void setDocument(JGoDocument doc)
          Change the document model that this view is displaying.
 void setDragDropEnabled(boolean m)
          Specify whether the drag-and-drop mechanism is enabled for this view.
 void setDragEnabled(boolean m)
          Specify whether the drag mechanism is enabled for this view.
 void setDragsRealtime(boolean bFlag)
          Change whether dragging in this view actually continuously moves the objects to follow the mouse.
 void setDragsSelectionImage(boolean bFlag)
          Change whether the objects being copied, or being dragged when isDragsRealtime() is false, are drawn as an image or with an outline.
 void setDrawsXorMode(boolean d)
          When set to true, drawXORBox tries to draw using the underlying graphics's XOR mode, rather than using regular drawing.
 void setDropEnabled(boolean m)
          Specify whether the drop mechanism is enabled for this view.
 void setEditControl(JGoTextEdit edit)
          Specify the in-place text editor to use.
 void setGridHeight(int height)
          Set the vertical spacing of the grid.
 void setGridOrigin(org.eclipse.swt.graphics.Point point)
          Set the origin for the grid.
 void setGridPen(JGoPen pen)
          Set the pen that is used for drawing the grid's dots, crosses or lines.
 void setGridSpot(int spot)
          Set which spot on the objects should snap to the nearest grid point, if snapping is enabled.
 void setGridStyle(int style)
          Set the style of the grid that will be draw.
 void setGridWidth(int width)
          Sets the horizontal spacing of the grid.
 void setHidingDisabledScrollbars(boolean b)
          Change whether a scroll bar show remain visible but disabled, or if it should be hidden, when it is no longer needed due to the document being small enough to be seen in its entirety by the view (for that horizontal or vertical direction).
 void setIgnoreNextMouseDown(boolean bFlag)
          Set the view's flag to ignore the next mouse pressed event.
 void setIncludingNegativeCoords(boolean b)
          Change whether the view can display parts of a document at negative coordinates.
 void setInternalMouseActions(int m)
          Change the permitted drag-and-drop actions for internal mouse drags of selected objects.
 void setKeyEnabled(boolean m)
          This function enables or disables key event handling.
 void setMouseEnabled(boolean m)
          This function enables or disables mouse event handling, for all cases except those handled by drag-drop.
 void setPrimarySelectionColor(org.eclipse.swt.graphics.RGB newcolor)
          Set the primary selection color.
 void setScale(double scale)
          Change the scale at which JGoObjects are displayed in this view.
 void setSecondarySelectionColor(org.eclipse.swt.graphics.RGB newcolor)
          Set the secondary selection color.
 void setSnapMove(int snap)
          Set this view's policy on moving objects.
 void setSnapResize(int snap)
          Set this view's policy on resizing objects.
 void setState(int s)
          Change the current state of this view for handling mouse events.
 void setViewPosition(int x, int y)
          Scroll the view to place the given document coordinates at the top-left corner of the view.
 void setViewPosition(org.eclipse.swt.graphics.Point p)
          Scroll the view to place the given document coordinates at the top-left corner of the view.
 void shellActivated(org.eclipse.swt.events.ShellEvent e)
           
 void shellClosed(org.eclipse.swt.events.ShellEvent e)
           
 void shellDeactivated(org.eclipse.swt.events.ShellEvent e)
           
 void shellDeiconified(org.eclipse.swt.events.ShellEvent e)
           
 void shellIconified(org.eclipse.swt.events.ShellEvent e)
           
 void snapAllObjects()
          For each object, aligns the default spot for this view with the nearest grid position.
 void snapAllObjects(int spotNumber)
          For each object, aligns the spot specified by spotNumber with the nearest grid position.
 void snapObject(JGoObject object)
          Puts the spot of this object that corresponds with this GridView's default object spot at the nearest grid location.
 void snapObject(JGoObject object, int spotNumber)
          Puts the given spot of this object at the nearest grid location.
 boolean startActionObject(JGoActionObject actionobj, int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          Start acting on a JGoActionObject.
protected  boolean startDragBoxSelection(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          This method is called by doMouseMove when the mouse state is MouseStateSelection and there are no objects at the current point.
protected  boolean startMoveSelection(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          This method is called by doMouseMove when the mouse state is MouseStateSelection and there is an object at the current point.
 boolean startNewLink(JGoPort port, org.eclipse.swt.graphics.Point dc)
          This method is called in response to the user's pressing on and dragging over a valid port in order to create a new link.
 boolean startReLink(JGoLink oldlink, JGoPort oldport, org.eclipse.swt.graphics.Point dc)
          Start the process of handling a user's drawing a link between two ports.
protected  boolean startResizing(JGoHandle handle, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
          This method is called in response to the user's mouse press on a resize handle in order to start resizing an object.
 void stopAutoscroll()
          Call this method to stop any autoscrolling that may be occurring.
 void updateScrollbars()
          Make sure the horizontal and vertical scrollbars, if any, properly reflect the view position and document size.
 void updateView()
          Repaint the whole view, including scrollbars.
 void updateView(org.eclipse.swt.graphics.Rectangle viewRect)
          Request repainting a part of the view's canvas.
 boolean validDestinationPort(JGoPort to)
          Return whether or not a link can end at a port.
 boolean validLink(JGoPort from, JGoPort to)
          Return whether or not a link from "from" to "to" is valid.
 boolean validSourcePort(JGoPort from)
          Return whether or not a link can begin at the given port.
 Dimension viewToDocCoords(Dimension v)
          Convert view dimensions to document coordinates.
 org.eclipse.swt.graphics.Rectangle viewToDocCoords(int x, int y, int w, int h)
          Convert a rectangle in view coordinates to a rectangle in document coordinates.
 org.eclipse.swt.graphics.Point viewToDocCoords(org.eclipse.swt.graphics.Point v)
          Convert view coordinates to document coordinates.
 org.eclipse.swt.graphics.Rectangle viewToDocCoords(org.eclipse.swt.graphics.Point p, Dimension d)
          Convert a rectangle in view coordinates to a rectangle in document coordinates.
 org.eclipse.swt.graphics.Rectangle viewToDocCoords(org.eclipse.swt.graphics.Rectangle v)
          Convert a rectangle in view coordinates to a rectangle in document coordinates.
 void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e)
           
 void widgetDisposed(org.eclipse.swt.events.DisposeEvent e)
           
 void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
          This is the event handler for the scrollbars.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MouseStateNone

public static final int MouseStateNone
The mouse state when the user isn't doing much with the mouse

See Also:
Constant Field Values

MouseStateSelection

public static final int MouseStateSelection
The mouse state when the user may be selecting something, and might drag it

See Also:
Constant Field Values

MouseStateMove

public static final int MouseStateMove
The mouse state when the user is dragging objects, for moving or copying

See Also:
Constant Field Values

MouseStateCreateLink

public static final int MouseStateCreateLink
The mouse state when the user is drawing a new link starting at a source port

See Also:
Constant Field Values

MouseStateCreateLinkFrom

public static final int MouseStateCreateLinkFrom
The mouse state when the user is drawing a new link starting at a destination port

See Also:
Constant Field Values

MouseStateResize

public static final int MouseStateResize
The mouse state when the user is resizing an object

See Also:
Constant Field Values

MouseStateDragBoxSelection

public static final int MouseStateDragBoxSelection
The mouse state when the user is drawing a rubber-band selection box

See Also:
Constant Field Values

MouseStateAction

public static final int MouseStateAction
The mouse state when the user is acting on a JGoActionObject

See Also:
Constant Field Values

MouseStateLast

public static final int MouseStateLast
If you define your own state, make sure the value is greater than this.

See Also:
Constant Field Values

EventMouseDown

public static final int EventMouseDown
A mouse state indicator used by handleResizing and drawXORBox

See Also:
Constant Field Values

EventMouseMove

public static final int EventMouseMove
A mouse state indicator used by handleResizing and drawXORBox

See Also:
Constant Field Values

EventMouseUp

public static final int EventMouseUp
A mouse state indicator used by handleResizing and drawXORBox

See Also:
Constant Field Values

DebugEvents

public static final int DebugEvents
A flag used for debugging TRACE messages: drag-and-drop events

See Also:
Constant Field Values

GridInvisible

public static final int GridInvisible
Don't display any grid at all

See Also:
Constant Field Values

GridDot

public static final int GridDot
Display dots at each grid point

See Also:
Constant Field Values

GridCross

public static final int GridCross
Display small grid line crosses at each grid point

See Also:
Constant Field Values

GridLine

public static final int GridLine
Display the grid as lines

See Also:
Constant Field Values

NoSnap

public static final int NoSnap
Move or resize objects smoothly, ignoring any grid points.

See Also:
Constant Field Values

SnapJump

public static final int SnapJump
Move or resize objects to a grid point while being dragged.

See Also:
Constant Field Values

SnapAfter

public static final int SnapAfter
Move or resize objects to a grid point after release; objects move or resize smoothly while being dragged.

See Also:
Constant Field Values

ChangedDimensions

public static final int ChangedDimensions
a flag indicating that the dimensions (distance between grid points) has changed

See Also:
Constant Field Values

ChangedStyle

public static final int ChangedStyle
a flag indicating that the grid style has changed

See Also:
Constant Field Values

ChangedSpot

public static final int ChangedSpot
a flag indicating that the object spot has changed

See Also:
Constant Field Values

ChangedSnapMove

public static final int ChangedSnapMove
a flag indicating that the object moving snapping style has changed

See Also:
Constant Field Values

ChangedSnapResize

public static final int ChangedSnapResize
a flag indicating that the object resizing snapping style has changed

See Also:
Constant Field Values

ChangedPen

public static final int ChangedPen
a flag indicating that the pen used for drawing the grid has changed

See Also:
Constant Field Values

ChangedOrigin

public static final int ChangedOrigin
a flag indicating that the grid's origin has changed

See Also:
Constant Field Values
Constructor Detail

JGoView

public JGoView(org.eclipse.swt.widgets.Composite parent,
               int style)
Construct a new view of a document returned by calling createDefaultModel()


JGoView

public JGoView(org.eclipse.swt.widgets.Composite parent,
               int style,
               JGoDocument doc)
Construct a new view of a JGoDocument.

Parameters:
doc - the document that serves as the model for this new view.
Method Detail

widgetDisposed

public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e)
Specified by:
widgetDisposed in interface org.eclipse.swt.events.DisposeListener

getBackgroundImage

public org.eclipse.swt.graphics.Image getBackgroundImage()
Return the Image displayed in the background of this view. By default this property is null.


setBackgroundImage

public void setBackgroundImage(org.eclipse.swt.graphics.Image img)
Set the Image displayed in the background.

The paintBackgroundDecoration method normally draws the Image after painting any document paper color or any view background color.

Parameters:
img - the new background image; a value of null removes any background image.

getBackgroundColor

public org.eclipse.swt.graphics.RGB getBackgroundColor()

setBackgroundColor

public void setBackgroundColor(org.eclipse.swt.graphics.RGB c)

createDefaultModel

public JGoDocument createDefaultModel()
The default model is an instance of JGoDocument.


getDocument

public JGoDocument getDocument()
Gets the document model associated with this view.

Returns:
the document for this view.

setDocument

public void setDocument(JGoDocument doc)
Change the document model that this view is displaying.

Parameters:
doc - a JGoDocument that will be the new model.

getDocumentSize

public Dimension getDocumentSize()
Return the size of the document as seen by this view.

By default the size is increased to account for any handles on any objects. This method may need to be overridden if there are other view objects that may extend beyond the document objects.

If isIncludingNegativeCoords() is false this method only returns the size of the document that is in positive coordinate space.

The Dimension returned by this method must not be modified.

Returns:
the size of the document in document coordinates.

getDocumentTopLeft

public org.eclipse.swt.graphics.Point getDocumentTopLeft()
Return the top-left corner of the document as seen by this view.

If isIncludingNegativeCoords() is false this method returns (0, 0).

The Point returned by this method must not be modified.

Returns:
the top-left corner of the document in document coordinates.

isIncludingNegativeCoords

public boolean isIncludingNegativeCoords()
This predicate is true when the view may show parts of a document that are at negative document coordinates.

By default, this predicate is false.


setIncludingNegativeCoords

public void setIncludingNegativeCoords(boolean b)
Change whether the view can display parts of a document at negative coordinates.

This method does not set the viewPosition property to make sure the position is valid after setting this property value to false.


isHidingDisabledScrollbars

public boolean isHidingDisabledScrollbars()
This predicate is true when a scroll bars should disappear when the view is big enough to show the whole document range for that scroll bar.

By default, this predicate is false.


setHidingDisabledScrollbars

public void setHidingDisabledScrollbars(boolean b)
Change whether a scroll bar show remain visible but disabled, or if it should be hidden, when it is no longer needed due to the document being small enough to be seen in its entirety by the view (for that horizontal or vertical direction).

Note that even if the view is big enough, not all of the document might be shown by the view if the ViewPosition isn't right.


convertViewToDoc

public void convertViewToDoc(org.eclipse.swt.graphics.Point p)
Convert a Point in view coordinates to document coordinates. This modifies the given Point.

Parameters:
p - a Point in view coordinates

convertViewToDoc

public void convertViewToDoc(Dimension d)
Convert a Dimension in view coordinates to document coordinates. This modifies the given Dimension.

Parameters:
d - a Dimension in view coordinates

convertViewToDoc

public void convertViewToDoc(org.eclipse.swt.graphics.Rectangle r)
Convert a Rectangle in view coordinates to document coordinates. This modifies the given Rectangle.

Parameters:
r - a Rectangle in view coordinates

viewToDocCoords

public final org.eclipse.swt.graphics.Point viewToDocCoords(org.eclipse.swt.graphics.Point v)
Convert view coordinates to document coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
v - the view coordinates
Returns:
the document coordinates

viewToDocCoords

public final Dimension viewToDocCoords(Dimension v)
Convert view dimensions to document coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
v - a width and height in view coordinates
Returns:
a Dimension in document coordinates

viewToDocCoords

public final org.eclipse.swt.graphics.Rectangle viewToDocCoords(org.eclipse.swt.graphics.Rectangle v)
Convert a rectangle in view coordinates to a rectangle in document coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
v - a rectangle in view coordinates
Returns:
a Rectangle in document coordinates

viewToDocCoords

public final org.eclipse.swt.graphics.Rectangle viewToDocCoords(org.eclipse.swt.graphics.Point p,
                                                                Dimension d)
Convert a rectangle in view coordinates to a rectangle in document coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
p - a top-left point in view coordinates
d - a dimension in view coordinates
Returns:
a Rectangle in document coordinates

viewToDocCoords

public final org.eclipse.swt.graphics.Rectangle viewToDocCoords(int x,
                                                                int y,
                                                                int w,
                                                                int h)
Convert a rectangle in view coordinates to a rectangle in document coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
x - the X position in view coordinates
y - the Y position in view coordinates
w - the width in view coordinates
h - the height in view coordinates
Returns:
a Rectangle in document coordinates

convertDocToView

public void convertDocToView(org.eclipse.swt.graphics.Point p)
Convert a Point in document coordinates to view coordinates. This modifies the given Point.

Parameters:
p - a Point in doc coordinates

convertDocToView

public void convertDocToView(Dimension d)
Convert a Dimension in document coordinates to view coordinates. This modifies the given Dimension.

Parameters:
d - a Dimension in doc coordinates

convertDocToView

public void convertDocToView(org.eclipse.swt.graphics.Rectangle r)
Convert a Rectangle in document coordinates to view coordinates. This modifies the given Rectangle.

Parameters:
r - a Rectangle in doc coordinates

docToViewCoords

public final org.eclipse.swt.graphics.Point docToViewCoords(org.eclipse.swt.graphics.Point d)
Convert a point from document coordinates to view coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
d - a point in document coordinates
Returns:
a point in view coordinates

docToViewCoords

public final Dimension docToViewCoords(Dimension d)
Convert document dimensions to view coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
d - a width and height in document coordinates
Returns:
a Dimension in view coordinates

docToViewCoords

public final org.eclipse.swt.graphics.Rectangle docToViewCoords(org.eclipse.swt.graphics.Rectangle d)
Convert a rectangle in document coordinates to a rectangle in document coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
d - a rectangle in document coordinates
Returns:
a Rectangle in view coordinates

docToViewCoords

public final org.eclipse.swt.graphics.Rectangle docToViewCoords(org.eclipse.swt.graphics.Point p,
                                                                Dimension d)
Convert a rectangle in document coordinates to a rectangle in view coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
p - a top-left point in document coordinates
d - a dimension in document coordinates
Returns:
a Rectangle in view coordinates

docToViewCoords

public final org.eclipse.swt.graphics.Rectangle docToViewCoords(int x,
                                                                int y,
                                                                int w,
                                                                int h)
Convert a rectangle in document coordinates to a rectangle in view coordinates.

This is a convenience routine that allocates a new object for the return value.

Parameters:
x - the X position in document coordinates
y - the Y position in document coordinates
w - the width in document coordinates
h - the height in document coordinates
Returns:
a Rectangle in view coordinates

setViewPosition

public final void setViewPosition(org.eclipse.swt.graphics.Point p)
Scroll the view to place the given document coordinates at the top-left corner of the view.

Parameters:
p - the new top-left point, in document coordinates

setViewPosition

public void setViewPosition(int x,
                            int y)
Scroll the view to place the given document coordinates at the top-left corner of the view.

If isIncludingNegativeCoords() is false, we make sure the new X and Y are non-negative.

Parameters:
x - the new left position, in document coordinates
y - the new top position, in document coordinates

getViewPosition

public org.eclipse.swt.graphics.Point getViewPosition()
Return the position in the document of the top-left point of the view.

The returned Point must not be modified. Use setViewPosition() to change the visible part of the document.


getExtentSize

public Dimension getExtentSize()
Return the size in document coordinates of what is shown in the view.


getViewRect

public org.eclipse.swt.graphics.Rectangle getViewRect()
Return a rectangle whose origin is getViewPosition() and size is getExtentSize(). This is the visible part of the view, in document coordinates.


scrollRectToVisible

public void scrollRectToVisible(org.eclipse.swt.graphics.Rectangle contentRect)
Scroll the view so that the given rectangle in document coordinates is at least partly visible (i.e., within getViewRect()).

Parameters:
contentRect - the desired rectangle, in document coordinates

setScale

public void setScale(double scale)
Change the scale at which JGoObjects are displayed in this view.

The scale is a fraction comparing the displayed size with the size as specified for the objects. For example, a scale of 0.5 means that the objects the user sees appear to be half the normal size.

The permissible scale values are limited by calling limitScale(). The new value must be larger than zero.

Parameters:
scale - the new scale to be used by this view

getScale

public double getScale()
Return the current scale at which JGoObjects are displayed.

Values less than 1 mean that objects appear to the user smaller than normal. The initial value is 1.0d.


limitScale

public double limitScale(double s)
This method is called by the setScale method to make sure that the view only displays objects at a reasonable scale.

By default this limits the value to between 0.05d and 10.0d. The resulting value must be larger than zero.

Parameters:
s - the desired new scale for this view
Returns:
a valid new scale, larger than zero

pickDocObject

public JGoObject pickDocObject(org.eclipse.swt.graphics.Point pointToCheck,
                               boolean selectableOnly)
Find the topmost object in the document under the given point. If selectableOnly is true, only objects that are marked as selectable will be included in the search.

Parameters:
pointToCheck - the point under which to find the object, in document coordinates
selectableOnly - if true, consider only selectable objects

pickObject

public JGoObject pickObject(org.eclipse.swt.graphics.Point pointToCheck,
                            boolean selectableOnly)
Find the topmost view object under the given point. If selectableOnly is true, only objects that are marked as selectable will be included in the search.

Note that this method ignores document objects. Use the pickDocObject method to find a document object at the given point.

Specified by:
pickObject in interface JGoObjectCollection
Parameters:
pointToCheck - the point under which to find the object
selectableOnly - if true, consider only selectable objects
Returns:
the first object in the collection containing the indicated point.

getNumObjects

public int getNumObjects()
Returns the number of top-level objects in the view only.

Note that this method ignores document objects.

Specified by:
getNumObjects in interface JGoObjectSimpleCollection

isEmpty

public boolean isEmpty()
Returns true if the view contains no (view-only) objects.

Specified by:
isEmpty in interface JGoObjectSimpleCollection

addObjectAtHead

public JGoListPosition addObjectAtHead(JGoObject obj)
Adds an object behind all other objects in the view. Returns the position of the object in the list.

Note that this method ignores document objects. All view objects will appear in front of all document objects.

Specified by:
addObjectAtHead in interface JGoObjectCollection
Parameters:
obj - the object to add to the view.
Returns:
the position of the new child object.

addObjectAtTail

public JGoListPosition addObjectAtTail(JGoObject obj)
Adds an object in front of all other objects in the view. Returns the position of the object in the list.

Note that this method ignores document objects. All view objects will appear in front of all document objects.

Specified by:
addObjectAtTail in interface JGoObjectCollection
Parameters:
obj - the object to add to the view.
Returns:
the position of the new child object.

insertObjectBefore

public JGoListPosition insertObjectBefore(JGoListPosition pos,
                                          JGoObject obj)
Adds an object to the view before the given position. The object will appear behind the object at the given position.

Note that this method ignores document objects. All view objects will appear in front of all document objects.

If the object is already a top-level part of this view, the object is moved in the drawing order. The CHANGED view event will have a JGoObject.ChangedZOrder hint/flag, with no previous value.

Specified by:
insertObjectBefore in interface JGoObjectCollection
Parameters:
pos - the position before which to add the object.
obj - the object to add.
Returns:
the position of the new object.

insertObjectAfter

public JGoListPosition insertObjectAfter(JGoListPosition pos,
                                         JGoObject obj)
Adds an object to the view after the given position. The object will appear in front of the object at the given position.

Note that this method ignores document objects. All view objects will appear in front of all document objects.

If the object is already a top-level part of this view, the object is moved in the drawing order. The CHANGED view event will have a JGoObject.ChangedZOrder hint/flag, with no previous value.

Specified by:
insertObjectAfter in interface JGoObjectCollection
Parameters:
pos - the position after which to add the object.
obj - the object to add.
Returns:
the position of the new object.

bringObjectToFront

public void bringObjectToFront(JGoObject obj)
Moves an object in front of other objects in the view (moved to the end of the list of objects).

Note that all view objects will appear in front of all document objects.

The CHANGED view event will have a JGoObject.ChangedZOrder hint/flag, with no previous value.

The object should already be a part of this view.

Specified by:
bringObjectToFront in interface JGoObjectCollection
Parameters:
obj - the object to move to the front.

sendObjectToBack

public void sendObjectToBack(JGoObject obj)
Moves an object behind other objects in the view (moved to the head of the list of objects).

Note that all view objects will appear in front of all document objects.

The CHANGED view event will have a JGoObject.ChangedZOrder hint/flag, with no previous value.

The object should already be a part of this view.

Specified by:
sendObjectToBack in interface JGoObjectCollection
Parameters:
obj - the object to move to the back.

removeObject

public void removeObject(JGoObject obj)
Removes an object from the view.

If the object is not a part of this view, this method is a no-op. If the object is a child of a JGoArea instead of being a top-level view object, it is removed from that area.

Specified by:
removeObject in interface JGoObjectCollection
Parameters:
obj - the object to remove.

removeObjectAtPos

public JGoObject removeObjectAtPos(JGoListPosition pos)
Description copied from interface: JGoObjectCollection
Remove an object at specified position from the collection.

Specified by:
removeObjectAtPos in interface JGoObjectCollection
Parameters:
pos - the position of the object to remove.
Returns:
the object removed from the collection.

getFirstObjectPos

public JGoListPosition getFirstObjectPos()
Description copied from interface: JGoObjectSimpleCollection
Return the position of the first object in the collection. This will be null if the list is empty.

Specified by:
getFirstObjectPos in interface JGoObjectSimpleCollection

getLastObjectPos

public JGoListPosition getLastObjectPos()
Description copied from interface: JGoObjectCollection
Return the position of the last object in the collection. This will be null if the list is empty.

Specified by:
getLastObjectPos in interface JGoObjectCollection
Returns:
the position of the last object in the collection.

getNextObjectPos

public JGoListPosition getNextObjectPos(JGoListPosition pos)
Description copied from interface: JGoObjectSimpleCollection
Return the position for the next object in the collection. This may recurse through the objects contained by a JGoArea.

Specified by:
getNextObjectPos in interface JGoObjectSimpleCollection
Parameters:
pos - the position previous to that which will be returned.
Returns:
an iterator for the next object in the collection; null if there are no more objects.

getNextObjectPosAtTop

public JGoListPosition getNextObjectPosAtTop(JGoListPosition pos)
Description copied from interface: JGoObjectSimpleCollection
Return the position for the next top-level object in the collection. A top-level JGoObject is one which is not contained in any JGoArea objects.

Specified by:
getNextObjectPosAtTop in interface JGoObjectSimpleCollection
Parameters:
pos - the position from which to start searching for the next top-level object.
Returns:
an iterator for the next top-level object in the collection; null if there are no more objects.

getPrevObjectPos

public JGoListPosition getPrevObjectPos(JGoListPosition pos)
Description copied from interface: JGoObjectCollection
Return the position of the previous object in the collection.

Specified by:
getPrevObjectPos in interface JGoObjectCollection
Parameters:
pos - the position of the object that follows the object position to be returned.
Returns:
the position of the previous object in the collection; null if there are no more objects.

getObjectAtPos

public JGoObject getObjectAtPos(JGoListPosition pos)
Description copied from interface: JGoObjectSimpleCollection
Return the object for the given position.

Specified by:
getObjectAtPos in interface JGoObjectSimpleCollection
Parameters:
pos - the position of an object in the collection.
Returns:
the object for this position in the collection.

findObject

public JGoListPosition findObject(JGoObject obj)
Description copied from interface: JGoObjectCollection
Return the position of a specific object in the collection.

Specified by:
findObject in interface JGoObjectCollection
Parameters:
obj - the object whose position in the collection is to be returned. to be returned.
Returns:
the position of the indicated object; null if not found.

createDefaultSelection

public JGoSelection createDefaultSelection()
Create an instance of a JGoSelection. This is called once for each JGoView instance.


getSelection

public JGoSelection getSelection()
Return the object representing the selection for this view.

There is a separate selection for each view. There is only one selection per view, but there may be many objects in the selection.


selectObject

public JGoObject selectObject(JGoObject obj)
Make the given object the one and only selected object in this view.

This is just a convenience routine, calling selectObject on this view's JGoSelection object.

Parameters:
obj - the object to be selected

selectAll

public void selectAll()
Select all the top-level, visible, selectable objects in the document. The actual selection may include non-top-level objects if the selection was redirected for some top-level objects.


selectInBox

public void selectInBox(org.eclipse.swt.graphics.Rectangle rect)
Select all visible, selectable objects in the document that are within the given rectangle. This method will recurse into areas if the area is not Selectable or if the given rectangle does not fully enclose the area. Once it finds a selectable object whose redirected selection is within the given rectangle, it does not search further within that object if the object is a JGoArea. The actual selection may also include non-top-level objects if the selection was redirected for some top-level objects.

Parameters:
rect - the Rectangle, in document coordinates

getPrimarySelectionColor

public org.eclipse.swt.graphics.RGB getPrimarySelectionColor()
Returns the primary selection color.

By default this returns getDefaultPrimarySelectionColor().


setPrimarySelectionColor

public void setPrimarySelectionColor(org.eclipse.swt.graphics.RGB newcolor)
Set the primary selection color. If the new color value is null, this view's primary selection color will default to the value of getDefaultPrimarySelectionColor().


getSecondarySelectionColor

public org.eclipse.swt.graphics.RGB getSecondarySelectionColor()
Returns the secondary selection color.

By default this returns getDefaultSecondarySelectionColor().


setSecondarySelectionColor

public void setSecondarySelectionColor(org.eclipse.swt.graphics.RGB newcolor)
Set the secondary selection color. If the new color value is null, this view's secondary selection color will default to the value of getDefaultSecondarySelectionColor().


paintControl

public void paintControl(org.eclipse.swt.events.PaintEvent evt)
This method is invoked by the paintListener.

This is infrequently overridden.

Specified by:
paintControl in interface org.eclipse.swt.events.PaintListener

applyRenderingHints

public void applyRenderingHints(Graphics2D g2)
Set the standard RenderingHints for how shapes, images, and text are drawn.

This is called by paintView and by printView. By default this specifies quality rendering, with antialiased lines, bicubic interpolation of images, and non-aliased text using fractional metrics.

If you override this method to change its behavior, remember to apply the same changes to the Graphics2D returned by JGoGlobal.getGraphics2D(), particularly for rendering hints that apply to how text is drawn.


paintView

protected void paintView(Graphics2D g2,
                         org.eclipse.swt.graphics.Rectangle clipRect)
Render everything for this view that is within a given rectangle. The normal behavior fills in the paper color, draws any additional background, draws all of the document objects, and then draws any view objects.

This is infrequently overridden, except perhaps to change the default rendering hints.

Parameters:
g2 - the Graphics2D graphics context to draw on.
clipRect - the clipping rectangle in document coordinates

paintPaperColor

protected void paintPaperColor(Graphics2D g2,
                               org.eclipse.swt.graphics.Rectangle clipRect)
Fill the background with the with the document's paper color. If the document's paper color is null, the view's background color is used instead.

You may wish to override this method in order to change the background color for this view. For example, you may want to have a gray background if you want to indicate that the view and/or document is read-only.

Parameters:
g2 - the graphics context to draw on.
clipRect - the clipping rectangle in document coordinates

paintBackgroundDecoration

protected void paintBackgroundDecoration(Graphics2D g2,
                                         org.eclipse.swt.graphics.Rectangle clipRect)
Draw any background image or decorations before any of the document or the view objects are drawn.

When getBackgroundImage() returns a non-null Image, that image is drawn at the current view scale with the top-left corner of the image at the (0, 0) position in document coordinates.

This method also draws any grid lines.

Parameters:
g2 - the graphics context on which to draw.
clipRect - the clipping rectangle in document coordinates

paintDocumentObjects

protected void paintDocumentObjects(Graphics2D g2,
                                    org.eclipse.swt.graphics.Rectangle clipRect)
Draw all of the visible document objects that intersect the given clipping rectangle. This method is called by the canvas's paintComponent().

Parameters:
g2 - the graphics context to draw on.
clipRect - the clipping rectangle in document coordinates

paintViewObjects

protected void paintViewObjects(Graphics2D g2,
                                org.eclipse.swt.graphics.Rectangle clipRect)
Draw all of the visible view objects that intersect the given clipping rectangle. This method is called by the canvas's paintComponent().

Parameters:
g2 - the graphics context to draw on.
clipRect - the clipping rectangle in document coordinates

updateScrollbars

public void updateScrollbars()
Make sure the horizontal and vertical scrollbars, if any, properly reflect the view position and document size.

Called when the scrollbars need to be updated, such as when the document size or view position change.


updateView

public void updateView(org.eclipse.swt.graphics.Rectangle viewRect)
Request repainting a part of the view's canvas.

Called when part of the view needs to be redrawn, such as when a particular object needs to be redrawn.

Parameters:
viewRect - the area to be redrawn, in the canvas's Component coordinates

updateView

public void updateView()
Repaint the whole view, including scrollbars.

Called when the whole view and the scrollbars need to be repainted.


addViewListener

public void addViewListener(JGoViewListener l)
Add a listener for JGoViewEvents, such as clicking on objects or in the background, or a link having been drawn by the user, or property changes on this JGoView.

Parameters:
l - an object supporting the JGoViewListener interface

removeViewListener

public void removeViewListener(JGoViewListener l)
Remove a listener for JGoViewEvents.

Parameters:
l - an object supporting the JGoViewListener interface

getViewListeners

public JGoViewListener[] getViewListeners()
Return an array of the JGoViewListeners that are currently listening for JGoViewEvents on this view.


addDocumentListener

public void addDocumentListener(JGoDocumentListener l)
Add a listener for JGoDocument events, such as changes to a JGoObject's properties or to a JGoObject having been added or removed from a JGoLayer.

Parameters:
l - an object supporting the JGoDocumentListener interface

removeDocumentListener

public void removeDocumentListener(JGoDocumentListener l)
Remove a listener for JGoDocument events.

Parameters:
l - an object supporting the JGoDocumentListener interface

getDocumentListeners

public JGoDocumentListener[] getDocumentListeners()
Return an array of the JGoDocumentListeners that are currently listening for JGoDocumentEvents on this view's JGoDocument.


fireUpdate

public final void fireUpdate(int hint,
                             int flags,
                             java.lang.Object x)
Call this method whenever an event occurs in the view that may require the view to repaint some portion of itself or perform other processing.

This method is now final, because it just calls the other fireUpdate method.

Parameters:
hint - a value identifying what type of update is occurring. Hint constant values are identified in JGoViewEvent.
flags - an integer value whose meaning depends on the kind of hint.
x - an Object associated with the update, or null.

fireUpdate

public void fireUpdate(int hint,
                       int flags,
                       java.lang.Object x,
                       org.eclipse.swt.graphics.Point vc,
                       org.eclipse.swt.graphics.Point dc,
                       int modifiers)
This method is called whenever an event occurs in the view that may require the view to repaint some portion of itself or perform other processing.

By default it is also responsible for firing a JGoViewEvent to all JGoViewListeners.

Parameters:
hint - a value identifying what type of update is occurring. Hint constant values are identified in JGoViewEvent.
flags - an integer value whose meaning depends on the kind of hint.
x - an Object associated with the update, or null.
vc - the current position of the mouse in view coords
dc - the current position of the mouse in doc coords
modifiers - which keys are pressed

documentChanged

public void documentChanged(JGoDocumentEvent evt)
This method is called whenever a document modification occurs that may require the view to repaint some portion of itself.

This implements JGoDocumentListener.

Specified by:
documentChanged in interface JGoDocumentListener
Parameters:
evt - the document event, including the hint type, any flags, and any relevant object

print

public void print()
Call this to print the current view.

By default this brings up the operating system print dialog and uses a default paper margin of 0.5 inch on each side.


printBegin

protected void printBegin(Graphics2D g2,
                          org.eclipse.swt.printing.Printer p)
Because there may be many calls to Printable.print for each document, we calculate a number of values once and remember their values.

Parameters:
g2 - the Graphics2D that we are printing to; may be null
p - the Printer

getPrintDocumentSize

public Dimension getPrintDocumentSize()
Return the size of the document to be printed, in document coordinates. By default this differs from the view's getDocumentSize() because it finds the actual current bounds of all the document objects, thus avoiding printing empty pages at the right and at the bottom of the graph.

Override this method to return getDocumentSize() if you always want to print the whole document, as determined by the document's Size.

This method also considers document objects at negative coordinate positions, if isIncludingNegativeCoords() is true.


getPrintDocumentTopLeft

public org.eclipse.swt.graphics.Point getPrintDocumentTopLeft()
This method returns the coordinates of the document's top-left corner, where printing should start from.

If isIncludingNegativeCoords() is true and there are document objects at negative coordinates, this method will find the top-left point of the bounding rectangle for all document objects. Otherwise this returns (0,0) by default.


getPrintPageRect

protected org.eclipse.swt.graphics.Rectangle getPrintPageRect(Graphics2D g2,
                                                              org.eclipse.swt.printing.Printer p)
Return the bounds for the part of the print page that should hold the rendered graph. This defaults to the Imageable area of the PageFormat.

If you want to restrict the graph to a part of the Imageable area, override this method to return a smaller rectangle approriately positioned within the whole printed page.

Parameters:
g2 - the Graphics2D that we are printing to; may be null
p - the Printer

getPrintScale

protected double getPrintScale(Graphics2D g2,
                               org.eclipse.swt.printing.Printer p)
Return the scale at which the graph should be printed. This defaults to 1.0d.

For example, if you want to always print only one page, no matter how large the document is, you can scale down the printing to fit the page. In this case return the minimum of the horizontal and vertical ratios of the getPrintPageRect() and getPrintDocumentSize() widths and heights.

Parameters:
g2 - the Graphics2D that we are printing to; may be null
p - the Printer

printEnd

protected void printEnd(Graphics2D g2,
                        org.eclipse.swt.printing.Printer p)
Called at the end of printing and before any new printing operation; allows printBegin to reinitialize its precalculated values for the next printing operation.

Parameters:
g2 - the Graphics2D that we are printing to; may be null
p - the Printer

print

public int print(Graphics2D g,
                 org.eclipse.swt.printing.Printer p,
                 int pnum)
This method is called repeatedly by the print() method, once for each page that should be printed.

This returns zero when there are no more pages to be printed.


isPrinting

public boolean isPrinting()
This predicate is true while printView is called.

Currently this is only used for influencing Greeking behavior for text and ports.


printDecoration

protected void printDecoration(Graphics2D g2,
                               org.eclipse.swt.printing.Printer p,
                               int hpnum,
                               int vpnum)
Print any decorations on each page.

The default decoration consists of small corners that bound the graph printing region, getPrintPageRect(), so that it is easy to physically cut and paste the pieces of paper into a large sheet.

If you wish to add headers and/or footers on each page, override this method to render that information, and override getPrintPageRect to make sure the area for the printed graph is smaller than the Imageable area, to leave room for headers and/or footers.

Parameters:
g2 - the Graphics2D that we are printing to
p - the Printer
hpnum - the horizontal page number (zero based)
vpnum - the vertical page number (zero based)

printView

protected void printView(Graphics2D g2,
                         org.eclipse.swt.graphics.Rectangle clipRect)
This is called to print everything for this view that is within the given rectangle in document coordinates. The normal behavior only draws any additional background and draws all of the document objects; not the paper color or any view objects.

If you do want to draw selection handles and other view objects, override this method to call paintViewObjects(g2, clipRect) after calling super.printView(g2, clipRect).

Parameters:
g2 - the Graphics2D graphics context to draw on.
clipRect - the clipping rectangle in document coordinates

doLayout

public void doLayout()
Update the ScrollBar PageIncrements as well as the rest of the ScrollBar properties.


computeSize

public org.eclipse.swt.graphics.Point computeSize(int wHint,
                                                  int hHint)
The preferred size for a view normally comes from the document.

This just returns the result of computeSize(wHint, hHint, false).


computeSize

public org.eclipse.swt.graphics.Point computeSize(int wHint,
                                                  int hHint,
                                                  boolean changed)
The preferred size for a view normally comes from the document, getDocumentSize(), scaled by this view's current scale.


controlMoved

public void controlMoved(org.eclipse.swt.events.ControlEvent e)
Specified by:
controlMoved in interface org.eclipse.swt.events.ControlListener

controlResized

public void controlResized(org.eclipse.swt.events.ControlEvent e)
Specified by:
controlResized in interface org.eclipse.swt.events.ControlListener

shellActivated

public void shellActivated(org.eclipse.swt.events.ShellEvent e)
Specified by:
shellActivated in interface org.eclipse.swt.events.ShellListener

shellClosed

public void shellClosed(org.eclipse.swt.events.ShellEvent e)
Specified by:
shellClosed in interface org.eclipse.swt.events.ShellListener

shellDeactivated

public void shellDeactivated(org.eclipse.swt.events.ShellEvent e)
Specified by:
shellDeactivated in interface org.eclipse.swt.events.ShellListener

shellDeiconified

public void shellDeiconified(org.eclipse.swt.events.ShellEvent e)
Specified by:
shellDeiconified in interface org.eclipse.swt.events.ShellListener

shellIconified

public void shellIconified(org.eclipse.swt.events.ShellEvent e)
Specified by:
shellIconified in interface org.eclipse.swt.events.ShellListener

widgetSelected

public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
This is the event handler for the scrollbars. It calls setViewPosition() with the new document position for the view according to the scrollbar values.

Specified by:
widgetSelected in interface org.eclipse.swt.events.SelectionListener

widgetDefaultSelected

public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e)
Specified by:
widgetDefaultSelected in interface org.eclipse.swt.events.SelectionListener

setKeyEnabled

public void setKeyEnabled(boolean m)
This function enables or disables key event handling.

Parameters:
m - true to allow handling keyboard key events; false to ignore them

isKeyEnabled

public boolean isKeyEnabled()
Return true if keyboard key strokes are handled normally, or return false if those events are ignored.


keyPressed

public void keyPressed(org.eclipse.swt.events.KeyEvent evt)
This method implements KeyListener. If this view has enabled keystroke command handling, it calls onKeyEvent(), which implements both the default keyboard commands as well as any JGoView subclass overridden behavior.

Specified by:
keyPressed in interface org.eclipse.swt.events.KeyListener

keyTyped

public void keyTyped(org.eclipse.swt.events.KeyEvent evt)
This method implements KeyListener as a no-op.


keyReleased

public void keyReleased(org.eclipse.swt.events.KeyEvent evt)
This method implements KeyListener as a no-op.

Specified by:
keyReleased in interface org.eclipse.swt.events.KeyListener

onKeyEvent

public void onKeyEvent(org.eclipse.swt.events.KeyEvent evt)
This is the default event handler for keystroke commands.

By default, PageUp and PageDown scroll vertically; Ctrl-PageUp and Ctrl-PageDown scroll horizontally.

Override this method to add behavior for other keys, or to change or disable the default keystroke behavior. Call setKeyEnabled() to turn on and off all keystroke handling.

Parameters:
evt - the keystroke event

isIgnoreNextMouseDown

public boolean isIgnoreNextMouseDown()
Return whether the view's mouse pressed handler will ignore the next mouse pressed event.


setIgnoreNextMouseDown

public void setIgnoreNextMouseDown(boolean bFlag)
Set the view's flag to ignore the next mouse pressed event. The mouse pressed handler will automatically clear this flag when it sees the first event, so that subsequent mouse press events are handled normally.

Parameters:
bFlag - true to ignore next mouse press

keyToggleSelection

protected boolean keyToggleSelection(int modifiers)
Return true if the state of the modifier keys indicates whether we should deselect a selected object or select an unselected object.

The default implementation returns true if shift or control is held down.

Parameters:
modifiers - the key state -- see InputEvent

keyExtendSelection

protected boolean keyExtendSelection(int modifiers)
Return true if the modifiers keys indicate that a click on an object should add the current object to the selection.

The default implementation returns true if shift is held down.

Parameters:
modifiers - the key state -- see InputEvent

keySingleSelection

protected boolean keySingleSelection(int modifiers)
Return true if clicking on an object should make it the only selected object.

The default implementation always returns true.

Parameters:
modifiers - the key state -- see InputEvent

keyMultipleSelect

protected final boolean keyMultipleSelect(int modifiers)
Deprecated. -- replaced by keyExtendSelection and keyToggleSelection


keyClearSelection

protected boolean keyClearSelection(int modifiers)
Return true if the state of the modifier keys indicates that we should clear the selection when a click occurs on the background.

The default implementation is to return true unless shift or control is held down.

Parameters:
modifiers - the key state -- see InputEvent

initializeMouseHandling

protected void initializeMouseHandling()
This initializes the handling of mouse events.


setMouseEnabled

public void setMouseEnabled(boolean m)
This function enables or disables mouse event handling, for all cases except those handled by drag-drop.

Parameters:
m - true to allow user mouse actions; false to ignore mouse presses, drags, releases and drops

isMouseEnabled

public boolean isMouseEnabled()
Return true if mouse presses, drags, releases, and clicks are handled normally or return false if those actions are ignored.


getCurrentMouseEvent

protected final org.eclipse.swt.events.MouseEvent getCurrentMouseEvent()
Return the MouseEvent associated with the ongoing doMouseDown, doMouseMove, doMouseUp, doMouseClick, doMouseDblClick, or doUncapturedMouseMove methods.

The return value is invalid when not called from within those methods. Even so, the value may be null if those methods were not invoked from a mouse event handler.


mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent evt)
This is the internal event handler for mouse down events.

Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent evt)
This is the internal event handler for mouse up events.

Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent evt)
This is the internal event handler for mouse up events.

Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseMove

public void mouseMove(org.eclipse.swt.events.MouseEvent evt)
This is the internal event handler for mouse motion non-drag events.

Specified by:
mouseMove in interface org.eclipse.swt.events.MouseMoveListener

doMouseDown

public boolean doMouseDown(int modifiers,
                           org.eclipse.swt.graphics.Point dc,
                           org.eclipse.swt.graphics.Point vc)
Called when a mouse button is pressed. The default behavior depends on any JGoObjects at the specified point.

If the object is a JGoActionObject (or part of one), we activate that object for handling further mouse events.

If the object is a JGoHandle, we may start resizing the object.

If the object is a JGoPort, we may start creating a link to another port.

Otherwise if there is a selectable object at the point, we start doing something with the selection.

If there is no selectable object at the point, we start a rubber-band selection box.

Parameters:
modifiers - which keys are pressed
dc - the current position of the mouse in doc coords
vc - the current position of the mouse in view coords

doMouseMove

public boolean doMouseMove(int modifiers,
                           org.eclipse.swt.graphics.Point dc,
                           org.eclipse.swt.graphics.Point vc)
Called when the mouse is moved. The default behavior depends on any JGoObjects at the specified point.

If we are acting on a JGoActionObject, we adjust it by calling handleActionObject.

If we had started resizing an object, creating a link, doing a rubber-band selection, we continue that operation.

If there is a selection, then the selection may be modified depending on whether the object is already part of the selection.

The default behavior is to move the selection to the point, thus causing the selection to follow the mouse around the canvas.

Parameters:
modifiers - which keys are pressed
dc - the current position of the mouse in doc coords
vc - the current position of the mouse in view coords

doMouseUp

public boolean doMouseUp(int modifiers,
                         org.eclipse.swt.graphics.Point dc,
                         org.eclipse.swt.graphics.Point vc)
Performs the required processing when the mouse button is released. What is done depends on what state we're currently in.

Parameters:
modifiers - which keys are pressed, etc.
vc - the view coordinates.
dc - the document coordinates.

doMouseClick

public boolean doMouseClick(int modifiers,
                            org.eclipse.swt.graphics.Point dc,
                            org.eclipse.swt.graphics.Point vc)
Handle single click behavior for an object in the document.

By default, this picks the top object (perhaps not a Selectable one) in the document at the given position and fires JGoViewEvent.CLICKED on the that object. It then invokes doMouseClick on that object. If that call returns true, this method returns true. Otherwise it will go up the chain of that object's parents, invoking doMouseClick on each one until one returns true.

If there is no object at the point, this method calls doBackgroundClick.

No document transactions are involved with this method by default; your mouse click handlers may want to start and end transactions if they cause changes to the document, for example by bringing up a properties dialog.

Parameters:
modifiers - which keys are pressed
dc - the destination point in document coordinates
vc - the destination point in view coordinates

doMouseDblClick

public boolean doMouseDblClick(int modifiers,
                               org.eclipse.swt.graphics.Point dc,
                               org.eclipse.swt.graphics.Point vc)
Handle double click behavior for an object in the document.

By default, this picks the object in the document at the given position and fires JGoViewEvent.DOUBLE_CLICKED with that object. It then invokes doMouseDblClick on that object. If that call returns true, this method returns true. Otherwise it will go up the chain of that object's parents, invoking doMouseDblClick on each one until one returns true.

If there is no object at the point, this method fires the JGoViewEvent.BACKGROUND_DOUBLE_CLICKED event and returns false.

The object need not be selectable, so the object may very well be a part of an area.

No document transactions are involved with this method by default; your double-click handlers may want to start and end transactions if they cause changes to the document, for example by bringing up a properties dialog.

Parameters:
modifiers - which keys are pressed
dc - the destination point in document coordinates
vc - the destination point in view coordinates

doCancelMouse

public void doCancelMouse()
When one needs to cancel any mouse operation, this function restores the view to the normal state.

If the user was acting on a JGoActionObject, this calls JGoActionObject.setActionActivated(false). If the user was moving or copying with the mouse, this calls doCancelMoveSelection. If the user was resizing an object, this calls doCancelResize. If the user was linking or relinking ports, this calls noNewLink or noReLink appropriately and restores the original link's state. The selection handles are restored.


getState

public final int getState()
Return the current state of this view in its handling of the mouse. The value is normally one of the "MouseState" constants, but may be a user-defined state.


setState

public void setState(int s)
Change the current state of this view for handling mouse events. You should be careful to call this in a manner that is consistent with what is expected by all mouse handling code.

Parameters:
s - the new mouse state, normally a user-defined state or MouseStateNone

getCurrentObject

public final JGoObject getCurrentObject()
Return the current JGoObject, if any, associated with any mouse event handling.


setCurrentObject

public void setCurrentObject(JGoObject obj)
Change the current JGoObject, if any, associated with any mouse event handling.


doUncapturedMouseMove

public void doUncapturedMouseMove(int modifiers,
                                  org.eclipse.swt.graphics.Point dc,
                                  org.eclipse.swt.graphics.Point vc)
This method is called when the mouse is moved over the canvas and no other mouse behavior is happening.

The default behavior is to find the object at the given point and to call its doUncapturedMouseMove() method. If it returns null, we try calling the object's parents. If there is no object to handle the method, we just set the cursor to the default cursor.

No document transactions are normally involved with this method.

Parameters:
modifiers - which keys are pressed
dc - the destination point in document coordinates
vc - the destination point in view coordinates

getDefaultCursorType

public int getDefaultCursorType()

setDefaultCursorType

public void setDefaultCursorType(int cursor)

getCursorType

public int getCursorType()

setCursorType

public void setCursorType(int c)

doBackgroundClick

public void doBackgroundClick(int modifiers,
                              org.eclipse.swt.graphics.Point dc,
                              org.eclipse.swt.graphics.Point vc)
This method is called when a click happens in the canvas and there is no object underneath and there is no selection. By default this just fires the JGoViewEvent.BACKGROUND_CLICKED event.


doMoveSelection

public void doMoveSelection(int modifiers,
                            int offsetx,
                            int offsety,
                            int event)
Moves all currently selected draggable objects by the given offset. This method is called by the mouse event handlers.

This method calls moveSelection if the document is modifiable. Furthermore, if the CTRL key is held down at the time of the mouse up (a drop), we make a copy of the selection rather than moving it, by calling copySelection method, and the copied objects become the new selection. The moveSelection method has been added to separate out that functionality from the default event handling responsibilities of this method.

The default implementation of this method starts a transaction on this view's document on an EventMouseDown, and ends it on an EventMouseUp. The transaction may also be aborted by a call to doCancelMoveSelection. If a move occurs, this method fires the JGoViewEvent.SELECTION_MOVED event. If a copy occurs, this method fires the JGoViewEvent.SELECTION_COPIED event.

Parameters:
modifiers - which keys are pressed
offsetx - the distance to move horizontally, in document coordinates
offsety - the distance to move vertically, in document coordinates
event - one of: EventMouseDown, EventMouseMove, EventMouseUp

isDragsRealtime

public boolean isDragsRealtime()
Gets whether a user's drag of objects in this view actually moves the objects continuously, rather than dragging around an outline or an image of the selected objects.

By default this is true.


setDragsRealtime

public void setDragsRealtime(boolean bFlag)
Change whether dragging in this view actually continuously moves the objects to follow the mouse.

A value of false may be more responsive for large selections or for objects that require a lot of computation when moved.

Parameters:
bFlag - true to

getInternalMouseActions

public int getInternalMouseActions()
Return which kinds of drag-and-drop actions are permitted for mouse drags that start and end in this view.

The default value is Copy-or-Move.

For drag-and-drops that occur between windows (Components), see computeAcceptableDrop and the DropTargetListener methods.


setInternalMouseActions

public void setInternalMouseActions(int m)
Change the permitted drag-and-drop actions for internal mouse drags of selected objects. The values are: (DND.DROP_MOVE | DND.DROP_COPY) (the default), DND.DROP_MOVE, DND.DROP_COPY, or DND.DROP_NONE.

This has no effect on drag-and-drops between other windows and this view, nor does it effect drag-box selection, resizing, and linking ports.


isDragsSelectionImage

public boolean isDragsSelectionImage()
Gets whether the selection being copied or dragged is displayed as an image or with an outline.

By default this is true.


setDragsSelectionImage

public void setDragsSelectionImage(boolean bFlag)
Change whether the objects being copied, or being dragged when isDragsRealtime() is false, are drawn as an image or with an outline.


moveSelection

public void moveSelection(JGoSelection sel,
                          int modifiers,
                          int offsetx,
                          int offsety,
                          int event)
Moves all currently selected draggable objects of modifiable layers by the given offset.

For each object in the selection whose isDraggable() predicate is true (in layers that are modifiable), this method calls JGoObject.getDraggingObject to determine the real object to be moved. This method also tries to avoid moving the same object twice, in case both a parent area and its child are in the selection.

By default this ignores the modifiers and event arguments, but overrides could change the behavior depending on those values.

If a snap grid is active, move the selection to position each object's spot to a grid point, depending on the SnapMove property.

Note that no change is made to the object's height or width to accommodate the snap behavior. In other words, after moving, the object's resize handles might no longer be on a grid point.

The actual object-moving functionality is in this method, so that this could be called independently of a mouse move event handler, and so that the default mouse handling could be sensitive to whether the document is Modifiable. However, the decision on what objects to actually move, given the argument selection, is determined by the computeEffectiveSelection method.

Parameters:
sel - the selection of objects to be moved by the given offsets
modifiers - which keys are pressed (not used by the default implementation)
offsetx - the distance to move horizontally, in document coordinates
offsety - the distance to move vertically, in document coordinates
event - one of: EventMouseDown, EventMouseMove, EventMouseUp

computeEffectiveSelection

public java.util.ArrayList computeEffectiveSelection(JGoObjectSimpleCollection coll)
Try to avoid problems with double-moving due to duplicate entries or both a parent and its child being in the argument collection. Also add all links that have both ports/nodes in the selection.

Parameters:
coll - a collection of JGoObjects to be dragged (moved or copied)
Returns:
an ArrayList of the actual objects to be dragged

computeEffectiveSelection

public java.util.ArrayList computeEffectiveSelection(JGoObjectSimpleCollection coll,
                                                     boolean move,
                                                     boolean includelinks)
Try to avoid problems with double-moving due to duplicate entries or both a parent and its child being in the argument collection.

Parameters:
coll - a collection of JGoObjects to be dragged (moved or copied)
move - whether the drag is intended to be a move instead of a copy
includelinks - whether to add all links whose ports are part of the collection
Returns:
an ArrayList of the actual objects to be dragged

doCancelMoveSelection

public void doCancelMoveSelection(org.eclipse.swt.graphics.Point offset)
Called when the user's dragging of the current selection is cancelled. Besides moving the selection back to its original location, it also aborts the current transaction on this view's document.


copySelection

public void copySelection(JGoSelection sel,
                          int modifiers,
                          int offsetx,
                          int offsety,
                          int event)
Make copies of all currently selected objects and add them to this document at positions adjusted by the given offset.

This calls JGoDocument.copyFromCollection to actually copy the objects. This method then selects all the newly copied objects. If getSnapMove() specifies a snap, this method also moves all those newly copied objects to the nearest grid points, according to the getGridSpot().

Parameters:
sel - the selection of objects to be copied by the given offsets
modifiers - which keys are pressed (not used by the default implementation)
offsetx - the distance to move horizontally, in document coordinates
offsety - the distance to move vertically, in document coordinates
event - one of: EventMouseDown, EventMouseMove, EventMouseUp

startMoveSelection

protected boolean startMoveSelection(int modifiers,
                                     org.eclipse.swt.graphics.Point dc,
                                     org.eclipse.swt.graphics.Point vc)
This method is called by doMouseMove when the mouse state is MouseStateSelection and there is an object at the current point.

This changes the state to MouseStateMove and calls doMoveSelection with an event value of MouseStateDown to indicate that the move is just starting.

This method does nothing if there is no current object, or if the current object is not draggable or if it is in a JGoLayer that is not modifiable, or if getInternalMouseActions() allows neither move nor copy.

Parameters:
modifiers - key modifers
dc - the current mouse point in document coordinates
vc - the current mouse point in view coordinates

startDragBoxSelection

protected boolean startDragBoxSelection(int modifiers,
                                        org.eclipse.swt.graphics.Point dc,
                                        org.eclipse.swt.graphics.Point vc)
This method is called by doMouseMove when the mouse state is MouseStateSelection and there are no objects at the current point.

This changes the state to MouseStateDragBoxSelection and starts drawing a rubber-band box in XOR mode from the given view-coordinates point.

Parameters:
modifiers - key modifers
dc - the current mouse point in document coordinates
vc - the current mouse point in view coordinates

startResizing

protected boolean startResizing(JGoHandle handle,
                                org.eclipse.swt.graphics.Point dc,
                                org.eclipse.swt.graphics.Point vc)
This method is called in response to the user's mouse press on a resize handle in order to start resizing an object.

By default this will also clear all the selection handles for the object being resized, to be restored after the resize is finished.

Return true if the view should start calling handleResizing as the mouse is being dragged. By default this will return false if the object is in a not-modifiable layer or document.

The default implementation of this method starts a transaction on this view's document. The handleResizing and doCancelResize methods are responsible for ending the transaction on EventMouseUp.

Parameters:
handle - the handle with which the user is doing the resize
dc - the current mouse point in document coordinates
vc - the current mouse point in view coordinates
Returns:
whether to go into resize mode

handleResizing

protected void handleResizing(Graphics2D g,
                              org.eclipse.swt.graphics.Point vc,
                              org.eclipse.swt.graphics.Point dc,
                              int event)
This method is called in resize mode as the user is dragging a resize handle.

This method commits a transaction on this view's document when the event is EventMouseUp. Presumably the transaction had been started by the startResizing method. On a mouse up when resizing, this fires a JGoViewEvent.OBJECT_RESIZED event.

If SnapResizing is enabled, modify the standard resizing of the selected o bject to position the dragged resize handle to a grid point, depending on the SnapResize property.

Not that no change is made to the object's location to accommodate the snap behavior. In other words, after resizing, the object's location might no longer be on a grid point.

Parameters:
g - the graphics to be used for drawing any resizing feedback
vc - the current mouse point in view coordinates
dc - the current mouse point in document coordinates
event - one of: EventMouseUp, EventMouseMove, EventMouseDown

doCancelResize

public void doCancelResize(org.eclipse.swt.graphics.Rectangle orig)
Called when the user's resizing of an object is cancelled. Besides restoring the original geometry of the object, this method also aborts the transaction on this view's document.


pickActionObject

public JGoActionObject pickActionObject(org.eclipse.swt.graphics.Point dc)
Return a JGoActionObject that is in the document at a given point.

This picks a document object; if it is not a JGoActionObject, this method proceeds up the parent chain. If it finds an action object, and if JGoActionObject.isActionEnabled() is true, this method returns that object. Otherwise this returns null.

Parameters:
dc - the current mouse point in document coordinates
Returns:
an enabled JGoActionObject at the mouse point, or null

startActionObject

public boolean startActionObject(JGoActionObject actionobj,
                                 int modifiers,
                                 org.eclipse.swt.graphics.Point dc,
                                 org.eclipse.swt.graphics.Point vc)
Start acting on a JGoActionObject.

Basically this method just calls JGoActionObject.setActionActivated(true) and sets the current JGoView mouse state to be MouseStateAction. The view's current object will be the action object. For a prototypical button, the activation will give it a chance to display differently, probably to look as it were being "pressed".

Parameters:
actionobj - a JGoObject implementing JGoActionObject
modifiers - the key state
vc - the current mouse point in view coordinates
dc - the current mouse point in document coordinates
Returns:
true if the action object was activated

handleActionObject

public void handleActionObject(int modifiers,
                               org.eclipse.swt.graphics.Point dc,
                               org.eclipse.swt.graphics.Point vc,
                               int event)
Handle further mouse events on a JGoActionObject.

This is called by doMouseDown, doMouseMove and doMouseUp when getState() == MouseStateAction. This assumes getCurrentObject() is a JGoActionObject. For mouse moves, this method calls JGoActionObject.onActionAdjusted. For a mouse up this method calls JGoActionObject.onAction. Thus for a typical button, there is no final "action" if the mouse up happens outside of the button.

Parameters:
modifiers - the key state
vc - the current mouse point in view coordinates
dc - the current mouse point in document coordinates
event - one of JGoView.EventMouseDown, EventMouseMove, or EventMouseUp.

getToolTipText

public java.lang.String getToolTipText(org.eclipse.swt.events.MouseEvent evt)
Implement tooltips for JGoObjects by finding the object at the given point as specified by the MouseEvent, and asking for it's tooltip.

If no string is returned, ask the object's parent, until either a non-null string is returned, or until there is no JGoObject parent.

Parameters:
evt - the mouse event generated when passing over the canvas.
Returns:
a string for a tooltip, or null if this object should have no tooltip and the view should ask this object's parent

doBackgroundToolTip

public void doBackgroundToolTip(org.eclipse.swt.events.MouseEvent e)
This is called by doUncapturedMouseMove when the mouse is not over any object.

This calls getToolTipText(MouseEvent) in order to determine if there is any tooltip string to be shown. If the value is null, we remove any tooltip. Otherwise if there is a tooltip visible and the new non-null value is different, set it immediately.


doToolTip

public void doToolTip(org.eclipse.swt.events.MouseEvent e)
This is called on a mouse hover event, to call getToolTipText(MouseEvent) to decide whether to display a tooltip.


setEditControl

public void setEditControl(JGoTextEdit edit)
Specify the in-place text editor to use. Note that this editor is itself a JGoObject that is responsible for bringing up an SWT Text Control as the real editor.

Parameters:
edit - the JGoTextEdit object

getEditControl

public JGoTextEdit getEditControl()
This returns the single JGoTextEdit that is used for in-place editing for this whole view.


isEditingTextControl

public boolean isEditingTextControl()
Return true if the user is in the midst of in-place text editing.


doEndEdit

public void doEndEdit()
Tell any edit control (JGoTextEdit) that it's time to stop being in edit mode.


drawXORRect

protected void drawXORRect(Graphics2D g,
                           int x,
                           int y,
                           int w,
                           int h)
Performs the actual drawing of the XOR'ed rectangle. If the Graphics2D object is null, this is a no-op.

Parameters:
g - the graphics context on which to draw
x - the rectangle X position to draw (in view coordinates)
y - the rectangle Y position to draw (in view coordinates)
w - the rectangle width to draw (in view coordinates)
h - the rectangle height to draw (in view coordinates)

isDrawsXorMode

public boolean isDrawsXorMode()
Returns whether drawXORBox uses drawXORRect to really draw a rectangle using XOR mode, rather than simulating the rectangle using regular drawing.

The default value is false.


setDrawsXorMode

public void setDrawsXorMode(boolean d)
When set to true, drawXORBox tries to draw using the underlying graphics's XOR mode, rather than using regular drawing.

Some platforms cannot handle drawing in XOR mode, so you should not set this to true without careful testing on all of the platforms you may want to run on.


drawXORBox

protected void drawXORBox(Graphics2D g,
                          int corner1x,
                          int corner1y,
                          int corner2x,
                          int corner2y,
                          int event)
Draw an XOR'ed rectangle on the view screen given two opposite corners. This erases any previous rectangle and stops drawing on EventMouseUp.

Parameters:
g - the graphics context on which to draw.
corner1x - one corner of the rectangle in view coordinates
corner1y - one corner of the rectangle in view coordinates
corner2x - the opposite corner in view coordinates
corner2y - the opposite corner in view coordinates
event - one of: EventMouseUp, EventMouseMove, EventMouseDown

getJGoGraphics

public Graphics2D getJGoGraphics()
This convenience function returns a Graphics2D object for painting on the view's canvas. Remember to call disposeJGoGraphics on the result as soon as you are done with it.

Returns:
a Graphics2D for painting on the canvas.

disposeJGoGraphics

public void disposeJGoGraphics(Graphics2D g)
This convenience function disposes the Graphics object that is passed, or is a no-op if the object is null.

Parameters:
g - a Graphics2D produced by a call to getJGoGraphics

pickHandle

protected JGoHandle pickHandle(org.eclipse.swt.graphics.Point point)
Return a JGoHandle under the given document coordinate point.

Return null if there is no such handle, or if you do not want the handle to particpate in user-controlled resizing gestures.

Parameters:
point - a point in document coordinates

newLink

public void newLink(JGoPort from,
                    JGoPort to)
Called to create a new link from the from port to the to port. Both ports must belong to the view's document. By default the link will be a JGoLink that is added to the links layer of the view's document, JGoDocument.getLinksLayer(), or to the subgraph that includes both ports, if such a common parent subgraph exists.

Override this method to create links that are derived from JGoLink. You can call JGoSubGraphBase.reparentToCommonSubGraph to add the new link to the appropriate subgraph or layer, or you can call JGoLayer.addObjectAtTail to add the new link to a particular layer.

This method is responsible for firing the JGoViewEvent.LINK_CREATED event and for committing a transaction on the view's document.

Parameters:
from - the source port
to - the destination port

noNewLink

protected void noNewLink(JGoPort from,
                         JGoPort to)
Called when a link creation failed. Subclasses may override to get interesting behavior -- the default is to do nothing.

This method is responsible for committing a transaction on the view's document.

Parameters:
from - the source port (may be null)
to - the destination port (may be null)

reLink

public void reLink(JGoLink oldlink,
                   JGoPort from,
                   JGoPort to)
Called to reconnect an existing link from the from port to the to port. Both ports must belong to the view's document. By default this just makes sure the oldlink's ports are the same as those specified, and reparents the link to the common parent subgraph, if any, or else as a top-level object in the oldlink's layer.

This method is responsible for firing the JGoViewEvent.LINK_RELINKED event and for committing a transaction on the view's document.

Parameters:
oldlink - the existing link being reconnected
from - the source port
to - the destination port

noReLink

protected void noReLink(JGoLink oldlink,
                        JGoPort from,
                        JGoPort to)
Called when a link reconnection failed. Subclasses may override to get interesting behavior -- the default is to just delete the link from the document.

If the old link is removed from the document, this fires the JGoViewEvent.SELECTION_DELETED event. This method is responsible for committing a transaction on the view's document.

Parameters:
oldlink - the existing link being reconnected
from - the source port (may be null)
to - the destination port (may be null)

validLink

public boolean validLink(JGoPort from,
                         JGoPort to)
Return whether or not a link from "from" to "to" is valid. By default, every link is valid as long as both ports are in modifiable layers (and document). Subclasses should override to get more interesting behavior.

Parameters:
from - the source port
to - the destination port
Returns:
true if the link would be valid

validSourcePort

public boolean validSourcePort(JGoPort from)
Return whether or not a link can begin at the given port. Subclasses should override to get more interesting behavior, either here in JGoView or JGoPort.isValidSource().

By default this checks to make sure the port is in a modifiable layer/document and that the port is a valid source.

Parameters:
from - the source port
Returns:
true if the link should be considered

validDestinationPort

public boolean validDestinationPort(JGoPort to)
Return whether or not a link can end at a port. Subclasses should override to get more interesting behavior, either here in JGoView or JGoPort.isValidDestination().

By default this checks to make sure the port is in a modifiable layer/document and that the port is a valid destination.

Parameters:
to - the source port
Returns:
true if the link should be considered

getPortGravity

public int getPortGravity()
Return the port gravity for this view.

When the user is drawing a link, the link will automatically snap to the nearest valid port, if it is less than the port gravity distance away.

The value defaults to getDefaultPortGravity().


pickNearestPort

public JGoPort pickNearestPort(org.eclipse.swt.graphics.Point dc)
Return the nearest valid port to the given position in the document while the user is in the midst of drawing a new link.

This method makes use of the getPortGravity() method to "snap" a potential link to the nearest valid port within that distance. This method makes use of JGoPort.isValidLink() to determine which ports were checked to be valid connections for the potential link.


pickPort

protected JGoPort pickPort(org.eclipse.swt.graphics.Point dc)
Return a JGoPort under the given document coordinate point.

Return null if there is no such port, or if you do not want the port to particpate in user-controlled linking gestures.

Parameters:
dc - a point in document coordinates

startNewLink

public boolean startNewLink(JGoPort port,
                            org.eclipse.swt.graphics.Point dc)
This method is called in response to the user's pressing on and dragging over a valid port in order to create a new link.

The technique behind the interactive behavior is that the view creates a temporary hidden port and a temporary link between the given port and the temporary one. The hidden port is continuously dragged around following the still-depressed mouse. The temporary link is therefore continuously redrawn as it must connect both ports.

You can override the default behavior by overriding createTemporaryPortForNewLink() and createTemporaryLinkForNewLink().

If the given port is a valid source port, the new link's source will be that port. If not, then if the given port is a valid destination port, the user is drawing a link "backwards", and the port will be the "to" port of the new link. If the given port is neither a valid source or destination port, no link is created, and this method returns false.

If the port is in a layer or document that is not modifiable, this method will return false, thereby disabling the user's link-drawing behavior.

The default implementation of this method starts a transaction on this view's document on an EventMouseDown. The newLink, noNewLink, and doCancelMouse methods are responsible for ending the transaction.

Parameters:
port - represents the port at which the user pressed and starting dragging the mouse.
dc - the point where the mouse is, in document coordinates
Returns:
whether to enter link-drawing mode

startReLink

public boolean startReLink(JGoLink oldlink,
                           JGoPort oldport,
                           org.eclipse.swt.graphics.Point dc)
Start the process of handling a user's drawing a link between two ports. This differs from startNewLink(JGoPort, Point) in that we want the user to modify an existing link (oldlink) by connecting it to a new port. The drawing will just re-link that existing link, rather than creating a completely new link. On mouse up either the reLink method or the noReLink method will be called. On cancelling the link will be relinked to its original port, oldport.

The default implementation of this method starts a transaction on this view's document on an EventMouseDown. The reLink, noReLink, and doCancelMouse methods are responsible for ending the transaction.

Parameters:
oldlink - an existing document link with one null JGoPort that needs to be re-hooked up at that end
oldport - represents the port near which the user pressed and starting dragging the mouse to start relinking. This port will represents the original port that the existing link used to be connected to.
dc - the point where the mouse is, in document coordinates
Returns:
whether to enter link-drawing mode

createTemporaryPortForNewLink

protected JGoPort createTemporaryPortForNewLink(JGoPort port,
                                                org.eclipse.swt.graphics.Point dc)
Return a temporary port used by the user-invoked link creating or reconnecting routines. See startNewLink() and startReLink() for more details. The view does not add the temporary port to either the view or the document.

Parameters:
port - the port at which the user started dragging to create a new link
dc - the Point at which the user is starting the new link, in document coordinates

createTemporaryLinkForNewLink

protected JGoLink createTemporaryLinkForNewLink(JGoPort from,
                                                JGoPort to)
Return a temporary link used by the user-invoked link creating routines. See startNewLink() for more details. The view will add the temporary link as a view object.

One of the two ports will be the temporary port created by createTemporaryPortForNewLink(). Which one depends on whether the user started dragging from a valid source port--if so, the from port will be the source port and the to port will be the temporary port.

Parameters:
from - the source port
to - the destination port

copy

public void copy()
Copy the document objects in the current selection to the system clipboard.

The default implementation of this method starts a transaction on this view's document before calling copyToClipboard, firing the JGoViewEvent.CLIPBOARD_COPIED event, and then ending the transaction.


copyToClipboard

public void copyToClipboard(org.eclipse.swt.dnd.Clipboard clipboard)
Copy document objects from the current selection to the given clipboard. A new instance of this document is created, the selection's objects are copied to the new document, and then the document is serialized to the clipboard.

The copy() and cut() methods are the normal callers of this method. This method does not start or finish any transaction.

Parameters:
clipboard - the clipboard to receive a new document containing a copy of the current selection

cut

public void cut()
Copy the current selection to the system clipboard and then remove the selected objects from the document.

The default implementation of this method starts a transaction on this view's document before calling copyToClipboard and deleteSelection, firing the JGoViewEvent.CLIPBOARD_COPIED event, and then ending the transaction.


deleteSelection

public void deleteSelection()
Remove the objects of the current selection from the document without copying them to the clipboard.

Top-level selected objects are removed from the document. Before version 4.1, non-top-level objects, i.e. parts of areas, cause the top-level areas to be removed from the document rather than from the parent area. For version 4.1, the result of JGoObject.getDraggingObject() determines what object really is removed from the document.

This fires the JGoViewEvent.SELECTION_DELETED event. The default implementation of this method starts a transaction on this view's document before deleting all selected objects in modifiable layers and then ending the transaction.


paste

public void paste()
Copy JGoObjects from the system clipboard into this document.

The default implementation of this method starts a transaction on this view's document before calling pasteFromClipboard, firing the JGoViewEvent.CLIPBOARD_PASTED event, and then ending the transaction.

For version 4.1, this method now resets the selection to be the set of top-level objects that were copied. If you do not want the selection to be changed, you can just call pasteFromClipboard (presumably within a document transaction).


canPaste

public boolean canPaste()
Return true if the document's DefaultLayer is Modifiable and if there is JGo data in the clipboard.


pasteFromClipboard

public JGoCopyEnvironment pasteFromClipboard(org.eclipse.swt.dnd.Clipboard clipboard)
Copy JGoObjects from the clipboard into this document.

The paste() method is the normal caller of this method. This method does not start or finish any transaction.

Parameters:
clipboard - the clipboard supporting the standard JGoTransfer type, containing objects to be copied to this document using the default copying method.

initializeDragDropHandling

public void initializeDragDropHandling()
This initializes drag and drop handling, both as a source and as a target.


setDragDropEnabled

public void setDragDropEnabled(boolean m)
Specify whether the drag-and-drop mechanism is enabled for this view. This is equivalent to calling setDragEnabled and setDropEnabled.

Parameters:
m - true to turn on performing standard Java drag-and-drop behavior

setDragEnabled

public void setDragEnabled(boolean m)
Specify whether the drag mechanism is enabled for this view.

If the argument is false, the user will not be able to start a drag operation from this window that might go to another window.

Parameters:
m - true to turn on initiating standard Java drag-and-drop behavior

setDropEnabled

public void setDropEnabled(boolean m)
Specify whether the drop mechanism is enabled for this view.

If the argument is false, the user will not be able to drop things from other windows into this one.

Parameters:
m - true to turn on handling standard Java drag-and-drop behavior

isDragDropEnabled

public boolean isDragDropEnabled()
Return whether the drag-and-drop mechanism is enabled for this view, equivalent to isDragEnabled() && isDropEnabled().


isDragEnabled

public boolean isDragEnabled()
Return whether the drag gesture listener is enabled, to allow users to start a drag-and-drop operation from this view.

Even when this value is false, the user may be able to move and/or copy objects within this view, if isMouseEnabled() is true and the objects permit it. However, the standard Java Drag-and-Drop mechanism is not used, so the behavior may be slightly different.


isDropEnabled

public boolean isDropEnabled()
Return whether the drop target listener is enabled, to allow users to perform a drop operation to this view.


isInternalDragDrop

public boolean isInternalDragDrop()
Return whether a dragging operation started within this JGoView or is coming from another window.


getDragSource

public org.eclipse.swt.dnd.DragSource getDragSource()

getDropTarget

public org.eclipse.swt.dnd.DropTarget getDropTarget()

dragStart

public void dragStart(org.eclipse.swt.dnd.DragSourceEvent event)
This DragSourceListener method starts an internal drag-and-drop.

If isDragEnabled() is false, the drag-and-drop is cancelled. If isDropEnabled() is false, so that a drag started from this view cannot be completed in this view, we at least call doMouseMove to simulate a mouse move.

Specified by:
dragStart in interface org.eclipse.swt.dnd.DragSourceListener

dragAccept

protected void dragAccept(org.eclipse.swt.dnd.DragSourceEvent event)
This method is called by dragStart to cancel the drag-and-drop operation if it is not needed for the particular state this JGoView is in.

By default this cancels all drag-and-drops except when we are about to perform a dragging (i.e. getState() == MouseStateSelection) and getCurrentObject() is not null, or we are actually doing a drag (i.e. getState() == MouseStateMove).

This is not a DragSourceListener method.

Parameters:
event - the DragSourceEvent that was passed to the dragStart method

dragSetData

public void dragSetData(org.eclipse.swt.dnd.DragSourceEvent event)
This DragSourceListener method serializes the Selection as the data for the transfer to the drop target.

If isDragEnabled() is false, this method does nothing. No objects are serialized as transfer data for rubber-band selection, resize, linking, or mouse action operations.

Specified by:
dragSetData in interface org.eclipse.swt.dnd.DragSourceListener

dragFinished

public void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event)
This DragSourceListener method calls doCancelMouse for internal drag-and-drops.

This behavior is needed, for example, to make sure objects that are dragged in real time in this window and then into a different window are restored to their original position after the drag-and-drop finishes in the other window, whether completed successfully or cancelled.

Specified by:
dragFinished in interface org.eclipse.swt.dnd.DragSourceListener

dragEnter

public void dragEnter(org.eclipse.swt.dnd.DropTargetEvent event)
This DropTargetListener method handles drag-and-drop operations that originated in other windows or that are internal and may be returning to this control.

If isDropEnabled() is false, this method rejects the drop. For external drag-and-drops (i.e. started in a different window), this method will call computeAcceptableDrop to determine what kind of operation is permitted. For internal drag-and-drops, this just calls doMouseMove, to maintain compatible behavior within a view even when the drag-and-drop mechanism is not used.

Specified by:
dragEnter in interface org.eclipse.swt.dnd.DropTargetListener

dragLeave

public void dragLeave(org.eclipse.swt.dnd.DropTargetEvent event)
This DropTargetListener method stops any autoscrolling.

Specified by:
dragLeave in interface org.eclipse.swt.dnd.DropTargetListener

dragOperationChanged

public void dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent event)
This DropTargetListener method handles changes to the modifier keys during a drag-and-drop.

If isDropEnabled() is false, this method rejects the drop. For external drag-and-drops (i.e. started in a different window), this method will call computeAcceptableDrop to determine what kind of operation is permitted.

Specified by:
dragOperationChanged in interface org.eclipse.swt.dnd.DropTargetListener

dragOver

public void dragOver(org.eclipse.swt.dnd.DropTargetEvent event)
This DropTargetListener method handles drag-and-drop operations that originated in any control, including this view.

If isDropEnabled() is false, this method rejects the drop. For external drag-and-drops (i.e. started in a different window), this method will call computeAcceptableDrop to determine what kind of operation is permitted. This will also call doAutoscroll to allow users to try to scroll the view when trying to drop something into this view. For internal drag-and-drops, this just calls doMouseMove, to maintain compatible behavior within a view even when the drag-and-drop mechanism is not used.

Specified by:
dragOver in interface org.eclipse.swt.dnd.DropTargetListener

onExternalDragOver

public void onExternalDragOver(org.eclipse.swt.dnd.DropTargetEvent event)
This is called for drag-and-drop operations that originated in a different control.

This method is called by dragOver to handle external drag-and-drop operations. This calls computeAcceptableDrop to determine what kind of operation is permitted. It also calls doAutoscroll to allow users to try to scroll the view when trying to drop something into this view.


dropAccept

public void dropAccept(org.eclipse.swt.dnd.DropTargetEvent event)
This DropTargetListener method rejects the drop if isDropEnabled() is false.

Specified by:
dropAccept in interface org.eclipse.swt.dnd.DropTargetListener

computeAcceptableDrop

public int computeAcceptableDrop(org.eclipse.swt.dnd.DropTargetEvent event)
Determine the permitted drag-and-drop operation for external drag-and-drops (from a different control).

Many DropTargetListener methods set the DropTargetEvent's detail field to the return value of this method. This returns DND.DROP_NONE if the transfer data type is not supported, if the document's DefaultLayer is not modifiable, or if the actions DND.DROP_COPY or DND.DROP_MOVE are not requested.


drop

public void drop(org.eclipse.swt.dnd.DropTargetEvent event)
This implements the default drop target listener.

If isDropEnabled() is false, this method rejects the drop.

For internal drag-and-drops, this calls doMouseUp, to maintain compatible behavior within a view even when the drag-and-drop mechanism is not used. For external drag-and-drops, this calls onExternalDrop. For both cases, this method calls stopAutoscroll.

Specified by:
drop in interface org.eclipse.swt.dnd.DropTargetListener

onExternalDrop

public void onExternalDrop(org.eclipse.swt.dnd.DropTargetEvent event)
This is called for drag-and-drop operations that originated in a different control.

This method is called by drop to handle external drops. If the document's DefaultLayer is modifiable, this method starts a transaction on this view's document, and calls the doDrop method to handle standard drops from other JGoViews. If doDrop returns true, it fires the JGoViewEvent.EXTERNAL_OBJECTS_DROPPED event and commits the transaction. If doDrop returns false, it aborts the transaction.


doDrop

public boolean doDrop(org.eclipse.swt.dnd.DropTargetEvent e,
                      JGoCopyEnvironment copyenv)
Perform the default drop operation to copy a JGoObjectSimpleCollection into this view's document, as a result of a DropTargetListener.drop(DropTargetEvent).

This method is normally called by onExternalDrop. The default behavior is to copy the event's deserialized JGoDocument (a collection of JGoObjects) into this document at the drop point.

If you do not want to perform the drop, just return false.

Parameters:
e - the event passed in from drop()
copyenv - the copy environment to be used for controlling the copy to the document; specify null to use the document's default copy environment. If the copy environment is supplied, the caller will be able to examine the results of the drop, as well as control how any newly copied objects are merged into this document.
Returns:
true if the drop was accepted and completed, false otherwise

convertActionToModifiers

public int convertActionToModifiers(int action)
This method converts a DropTarget event's dropAction to an InputEvent's modifiers.


getAutoscrollInsets

public Insets getAutoscrollInsets()
Returns the inset margins in which autoscrolling will occur.

Returns:
the autoscrolling Insets

setAutoscrollInsets

public void setAutoscrollInsets(Insets insets)
Set the canvas's Autoscroll Insets.

Parameters:
insets - the margins in which autoscrolling will occur

doAutoscroll

public void doAutoscroll(int modifiers,
                         org.eclipse.swt.graphics.Point dc,
                         org.eclipse.swt.graphics.Point vc)
This is responsible for checking and initiating any autoscrolling action.

This is called by doMouseMove during certain states and by dragOver during drag-and-drops from other controls. This calls computeAutoscrollViewPosition to determine a possible new ViewPosition for this view, given the current mouse point. If the computed view position is different from the current value of getViewPosition(), this initiates a timer to repeatedly scroll until computeAutoscrollViewPosition returns the same value as getViewPosition().


stopAutoscroll

public void stopAutoscroll()
Call this method to stop any autoscrolling that may be occurring.


computeAutoscrollViewPosition

public org.eclipse.swt.graphics.Point computeAutoscrollViewPosition(org.eclipse.swt.graphics.Point viewPnt)
This method is called to determine the next position in the document for this view, given a point at which the user is dragging the mouse.

This uses the getAutoscrollInsets() property to calculate a new ViewPosition. The closer the point is to the edge of the view, the larger a multiple is used as a scroll step in that direction.

Parameters:
viewPnt - the current mouse point, in view coordinates

mouseEnter

public void mouseEnter(org.eclipse.swt.events.MouseEvent e)
This MouseTrackListener method by default does nothing.

Specified by:
mouseEnter in interface org.eclipse.swt.events.MouseTrackListener

mouseExit

public void mouseExit(org.eclipse.swt.events.MouseEvent e)
This MouseTrackListener method by default just calls stopAutoscroll.

Specified by:
mouseExit in interface org.eclipse.swt.events.MouseTrackListener

mouseHover

public void mouseHover(org.eclipse.swt.events.MouseEvent e)
This MouseTrackListener method by default just calls doToolTip.

Specified by:
mouseHover in interface org.eclipse.swt.events.MouseTrackListener

getFirstLayer

public JGoLayer getFirstLayer()
Return the bottom-most layer of objects in this document.


getLastLayer

public JGoLayer getLastLayer()
Return the top-most layer of objects in this document.


getNextLayer

public JGoLayer getNextLayer(JGoLayer layer)
Return the layer just above the given layer. Return null if the given layer is the top-most one.


getPrevLayer

public JGoLayer getPrevLayer(JGoLayer layer)
Return the layer just below the given layer. Return null if the given layer is the bottom-most one.


getEditPresentationName

public java.lang.String getEditPresentationName(int act)
Return a name for each of the different kinds of actions that this view provides, suitable for an UndoableEdit's presentation name. Override this method if you want to provide your own custom names for undo/redo edits. Return null to use a default name.


getDebugFlags

public int getDebugFlags()
Return the conditions under which this view generates TRACE messages. By default this returns 0.


setDebugFlags

public void setDebugFlags(int f)
Control whether this view generates TRACE messages during various operations.

Currently the following flags are defined:

Parameters:
f -

getDefaultPrimarySelectionColor

public static org.eclipse.swt.graphics.RGB getDefaultPrimarySelectionColor()
Return the default primary selection color.


setDefaultPrimarySelectionColor

public static void setDefaultPrimarySelectionColor(org.eclipse.swt.graphics.RGB c)
Set the default primary selection color.


getDefaultSecondarySelectionColor

public static org.eclipse.swt.graphics.RGB getDefaultSecondarySelectionColor()
Return the default secondary selection color.


setDefaultSecondarySelectionColor

public static void setDefaultSecondarySelectionColor(org.eclipse.swt.graphics.RGB c)
Set the default secondary selection color.


getDefaultPortGravity

public static int getDefaultPortGravity()
Return the default distance at which a link will snap to a port.


setDefaultPortGravity

public static void setDefaultPortGravity(int gravity)
Set the default distance at which a link will snap to a port. This can be set globally, or can be overridden for each JGoView.


setGridWidth

public void setGridWidth(int width)
Sets the horizontal spacing of the grid. Also changes the horizontal scroll bar's unit increment.

If the grid size given is different than the current grid size, then we call onGridChange().

Parameters:
width - the new horizontal spacing, in document coordinates

getGridWidth

public int getGridWidth()
Returns the horizontal spacing of the grid.

The default grid width is 50.

Returns:
the horizontal spacing, in document coordinates

setGridHeight

public void setGridHeight(int height)
Set the vertical spacing of the grid. Also changes the vertical scroll bar's unit increment.

Parameters:
height - the new vertical spacing, in document coordinates

getGridHeight

public int getGridHeight()
Get the vertical spacing of the grid.

The default grid height is 50.

Returns:
the vertical spacing, in document coordinates

setGridStyle

public void setGridStyle(int style)
Set the style of the grid that will be draw.

The style should be one of: GridInvisible, GridDot, GridCross, GridLine. Or you may wish to define your own styles.

If the grid style given is different than the current grid style, then we call onGridChange().

Parameters:
style - the new grid style

getGridStyle

public int getGridStyle()
Return the current style of the grid.

The default style is GridInvisible--no grid is drawn.

Returns:
the current style of the grid.

setGridOrigin

public void setGridOrigin(org.eclipse.swt.graphics.Point point)
Set the origin for the grid.

If the new grid origin is different than the current grid origin, then we call onGridChange().

Parameters:
point - the new location of the start of the grid, in document coordinates

getGridOrigin

public org.eclipse.swt.graphics.Point getGridOrigin()
Return the current origin for the grid.

The default position of the grid origin is (0,0).

Returns:
the current grid origin, in document coordinates. This Point must not be modified.

setGridSpot

public void setGridSpot(int spot)
Set which spot on the objects should snap to the nearest grid point, if snapping is enabled.

The spot value should be one of the spots defined on JGoObject.

If the new grid object spot is different than the current value, then we call onGridChange().

Parameters:
spot - the object spot to snap
See Also:
JGoObject

getGridSpot

public int getGridSpot()
Get which spot on the objects will be snapped to the nearest grid point.

The default spot is JGoObject.TopLeft.

Returns:
the object spot that will be snapped

setGridPen

public void setGridPen(JGoPen pen)
Set the pen that is used for drawing the grid's dots, crosses or lines.

Parameters:
pen - the pen to be used in drawing the grid

getGridPen

public JGoPen getGridPen()
Get the pen that is currently used for drawing the grid's dots, crosses or lines.

The view's initial grid pen is JGoPen.lightGray.

Returns:
the pen used to draw the grid

getSnapMove

public int getSnapMove()
Return the current policy when objects are moved.

This defaults to NoSnap.


setSnapMove

public void setSnapMove(int snap)
Set this view's policy on moving objects.

Parameters:
snap - one of: NoSnap, SnapJump, SnapAfter

getSnapResize

public int getSnapResize()
Return the current policy when objects are resized.

This defaults to NoSnap.


setSnapResize

public void setSnapResize(int snap)
Set this view's policy on resizing objects.

Parameters:
snap - one of: NoSnap, SnapJump, SnapAfter

onGridChange

public void onGridChange(int what)
Called when some characteristic of the grid has changed.

By default this method just fires a GRID_CHANGED view event. The flags property of the view event will be one of the Changed indicator constants defined on this class.

Parameters:
what - the aspect of the grid that has changed

drawGridLines

protected void drawGridLines(Graphics2D g,
                             org.eclipse.swt.graphics.Rectangle clipRect)
This method draws grid lines.

Parameters:
g - the graphics context onto which to draw.
clipRect - the bounds for where we need to draw, in document coordinates

drawGridCrosses

protected void drawGridCrosses(Graphics2D g,
                               int crossHeight,
                               int crossWidth,
                               org.eclipse.swt.graphics.Rectangle clipRect)
This method draws little crosses at the grid points. The crosses are of height crossHeight and width crossWidth.

Parameters:
g - where to draw the crosses
crossHeight - the height of the crosses, in document coordinates
crossWidth - the width of the crosses, in document coordinates
clipRect - the bounds for where we need to draw, in document coordinates

snapObject

public void snapObject(JGoObject object)
Puts the spot of this object that corresponds with this GridView's default object spot at the nearest grid location.

Parameters:
object - the object to snap.

snapObject

public void snapObject(JGoObject object,
                       int spotNumber)
Puts the given spot of this object at the nearest grid location.

Parameters:
object - the object to snap.
spotNumber - which spot to snap.

snapAllObjects

public void snapAllObjects()
For each object, aligns the default spot for this view with the nearest grid position.


snapAllObjects

public void snapAllObjects(int spotNumber)
For each object, aligns the spot specified by spotNumber with the nearest grid position.

This does not call snapObject on any JGoLinks.

Parameters:
spotNumber - which spot to snap

findNearestGridPoint

public org.eclipse.swt.graphics.Point findNearestGridPoint(int x,
                                                           int y,
                                                           org.eclipse.swt.graphics.Point result)
Find the grid point that is closest to the given point

Parameters:
x - the X position in document coordinates
y - the Y position in document coordinates
result - a Point that is modified to be the closest grid point, in document coordinates
Returns:
the modified Point, or a newly allocated one if result was null