|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
com.nwoods.jgo.JGoView
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:
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:
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.
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 |
public static final int MouseStateNone
public static final int MouseStateSelection
public static final int MouseStateMove
public static final int MouseStateCreateLink
public static final int MouseStateCreateLinkFrom
public static final int MouseStateResize
public static final int MouseStateDragBoxSelection
public static final int MouseStateAction
public static final int MouseStateLast
public static final int EventMouseDown
public static final int EventMouseMove
public static final int EventMouseUp
public static final int DebugEvents
public static final int GridInvisible
public static final int GridDot
public static final int GridCross
public static final int GridLine
public static final int NoSnap
public static final int SnapJump
public static final int SnapAfter
public static final int ChangedDimensions
public static final int ChangedStyle
public static final int ChangedSpot
public static final int ChangedSnapMove
public static final int ChangedSnapResize
public static final int ChangedPen
public static final int ChangedOrigin
Constructor Detail |
public JGoView(org.eclipse.swt.widgets.Composite parent, int style)
public JGoView(org.eclipse.swt.widgets.Composite parent, int style, JGoDocument doc)
doc
- the document that serves as the model for this new view.Method Detail |
public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e)
widgetDisposed
in interface org.eclipse.swt.events.DisposeListener
public org.eclipse.swt.graphics.Image getBackgroundImage()
public void setBackgroundImage(org.eclipse.swt.graphics.Image img)
The paintBackgroundDecoration method normally draws the Image after painting any document paper color or any view background color.
img
- the new background image; a value of null removes any background image.public org.eclipse.swt.graphics.RGB getBackgroundColor()
public void setBackgroundColor(org.eclipse.swt.graphics.RGB c)
public JGoDocument createDefaultModel()
public JGoDocument getDocument()
public void setDocument(JGoDocument doc)
doc
- a JGoDocument that will be the new model.public Dimension getDocumentSize()
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.
public org.eclipse.swt.graphics.Point getDocumentTopLeft()
If isIncludingNegativeCoords() is false this method returns (0, 0).
The Point returned by this method must not be modified.
public boolean isIncludingNegativeCoords()
By default, this predicate is false.
public void setIncludingNegativeCoords(boolean b)
This method does not set the viewPosition property to make sure the position is valid after setting this property value to false.
public boolean isHidingDisabledScrollbars()
By default, this predicate is false.
public void setHidingDisabledScrollbars(boolean b)
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.
public void convertViewToDoc(org.eclipse.swt.graphics.Point p)
p
- a Point in view coordinatespublic void convertViewToDoc(Dimension d)
d
- a Dimension in view coordinatespublic void convertViewToDoc(org.eclipse.swt.graphics.Rectangle r)
r
- a Rectangle in view coordinatespublic final org.eclipse.swt.graphics.Point viewToDocCoords(org.eclipse.swt.graphics.Point v)
This is a convenience routine that allocates a new object for the return value.
v
- the view coordinates
public final Dimension viewToDocCoords(Dimension v)
This is a convenience routine that allocates a new object for the return value.
v
- a width and height in view coordinates
public final org.eclipse.swt.graphics.Rectangle viewToDocCoords(org.eclipse.swt.graphics.Rectangle v)
This is a convenience routine that allocates a new object for the return value.
v
- a rectangle in view coordinates
public final org.eclipse.swt.graphics.Rectangle viewToDocCoords(org.eclipse.swt.graphics.Point p, Dimension d)
This is a convenience routine that allocates a new object for the return value.
p
- a top-left point in view coordinatesd
- a dimension in view coordinates
public final org.eclipse.swt.graphics.Rectangle viewToDocCoords(int x, int y, int w, int h)
This is a convenience routine that allocates a new object for the return value.
x
- the X position in view coordinatesy
- the Y position in view coordinatesw
- the width in view coordinatesh
- the height in view coordinates
public void convertDocToView(org.eclipse.swt.graphics.Point p)
p
- a Point in doc coordinatespublic void convertDocToView(Dimension d)
d
- a Dimension in doc coordinatespublic void convertDocToView(org.eclipse.swt.graphics.Rectangle r)
r
- a Rectangle in doc coordinatespublic final org.eclipse.swt.graphics.Point docToViewCoords(org.eclipse.swt.graphics.Point d)
This is a convenience routine that allocates a new object for the return value.
d
- a point in document coordinates
public final Dimension docToViewCoords(Dimension d)
This is a convenience routine that allocates a new object for the return value.
d
- a width and height in document coordinates
public final org.eclipse.swt.graphics.Rectangle docToViewCoords(org.eclipse.swt.graphics.Rectangle d)
This is a convenience routine that allocates a new object for the return value.
d
- a rectangle in document coordinates
public final org.eclipse.swt.graphics.Rectangle docToViewCoords(org.eclipse.swt.graphics.Point p, Dimension d)
This is a convenience routine that allocates a new object for the return value.
p
- a top-left point in document coordinatesd
- a dimension in document coordinates
public final org.eclipse.swt.graphics.Rectangle docToViewCoords(int x, int y, int w, int h)
This is a convenience routine that allocates a new object for the return value.
x
- the X position in document coordinatesy
- the Y position in document coordinatesw
- the width in document coordinatesh
- the height in document coordinates
public final void setViewPosition(org.eclipse.swt.graphics.Point p)
p
- the new top-left point, in document coordinatespublic void setViewPosition(int x, int y)
If isIncludingNegativeCoords() is false, we make sure the new X and Y are non-negative.
x
- the new left position, in document coordinatesy
- the new top position, in document coordinatespublic org.eclipse.swt.graphics.Point getViewPosition()
The returned Point must not be modified. Use setViewPosition() to change the visible part of the document.
public Dimension getExtentSize()
public org.eclipse.swt.graphics.Rectangle getViewRect()
public void scrollRectToVisible(org.eclipse.swt.graphics.Rectangle contentRect)
contentRect
- the desired rectangle, in document coordinatespublic void setScale(double scale)
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.
scale
- the new scale to be used by this viewpublic double getScale()
Values less than 1 mean that objects appear to the user smaller than normal. The initial value is 1.0d.
public double limitScale(double s)
By default this limits the value to between 0.05d and 10.0d. The resulting value must be larger than zero.
s
- the desired new scale for this view
public JGoObject pickDocObject(org.eclipse.swt.graphics.Point pointToCheck, boolean selectableOnly)
pointToCheck
- the point under which to find the object, in
document coordinatesselectableOnly
- if true, consider only selectable objectspublic JGoObject pickObject(org.eclipse.swt.graphics.Point pointToCheck, boolean selectableOnly)
Note that this method ignores document objects. Use the pickDocObject method to find a document object at the given point.
pickObject
in interface JGoObjectCollection
pointToCheck
- the point under which to find the objectselectableOnly
- if true, consider only selectable objects
public int getNumObjects()
Note that this method ignores document objects.
getNumObjects
in interface JGoObjectSimpleCollection
public boolean isEmpty()
isEmpty
in interface JGoObjectSimpleCollection
public JGoListPosition addObjectAtHead(JGoObject obj)
Note that this method ignores document objects. All view objects will appear in front of all document objects.
addObjectAtHead
in interface JGoObjectCollection
obj
- the object to add to the view.
public JGoListPosition addObjectAtTail(JGoObject obj)
Note that this method ignores document objects. All view objects will appear in front of all document objects.
addObjectAtTail
in interface JGoObjectCollection
obj
- the object to add to the view.
public JGoListPosition insertObjectBefore(JGoListPosition pos, JGoObject obj)
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.
insertObjectBefore
in interface JGoObjectCollection
pos
- the position before which to add the object.obj
- the object to add.
public JGoListPosition insertObjectAfter(JGoListPosition pos, JGoObject obj)
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.
insertObjectAfter
in interface JGoObjectCollection
pos
- the position after which to add the object.obj
- the object to add.
public void bringObjectToFront(JGoObject obj)
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.
bringObjectToFront
in interface JGoObjectCollection
obj
- the object to move to the front.public void sendObjectToBack(JGoObject obj)
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.
sendObjectToBack
in interface JGoObjectCollection
obj
- the object to move to the back.public void removeObject(JGoObject obj)
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.
removeObject
in interface JGoObjectCollection
obj
- the object to remove.public JGoObject removeObjectAtPos(JGoListPosition pos)
JGoObjectCollection
removeObjectAtPos
in interface JGoObjectCollection
pos
- the position of the object to remove.
public JGoListPosition getFirstObjectPos()
JGoObjectSimpleCollection
getFirstObjectPos
in interface JGoObjectSimpleCollection
public JGoListPosition getLastObjectPos()
JGoObjectCollection
getLastObjectPos
in interface JGoObjectCollection
public JGoListPosition getNextObjectPos(JGoListPosition pos)
JGoObjectSimpleCollection
getNextObjectPos
in interface JGoObjectSimpleCollection
pos
- the position previous to that which will be returned.
public JGoListPosition getNextObjectPosAtTop(JGoListPosition pos)
JGoObjectSimpleCollection
getNextObjectPosAtTop
in interface JGoObjectSimpleCollection
pos
- the position from which to start searching for the next
top-level object.
public JGoListPosition getPrevObjectPos(JGoListPosition pos)
JGoObjectCollection
getPrevObjectPos
in interface JGoObjectCollection
pos
- the position of the object that follows the object position
to be returned.
public JGoObject getObjectAtPos(JGoListPosition pos)
JGoObjectSimpleCollection
getObjectAtPos
in interface JGoObjectSimpleCollection
pos
- the position of an object in the collection.
public JGoListPosition findObject(JGoObject obj)
JGoObjectCollection
findObject
in interface JGoObjectCollection
obj
- the object whose position in the collection is to be returned.
to be returned.
public JGoSelection createDefaultSelection()
public JGoSelection getSelection()
There is a separate selection for each view. There is only one selection per view, but there may be many objects in the selection.
public JGoObject selectObject(JGoObject obj)
This is just a convenience routine, calling selectObject on this view's JGoSelection object.
obj
- the object to be selectedpublic void selectAll()
public void selectInBox(org.eclipse.swt.graphics.Rectangle rect)
rect
- the Rectangle, in document coordinatespublic org.eclipse.swt.graphics.RGB getPrimarySelectionColor()
By default this returns getDefaultPrimarySelectionColor().
public void setPrimarySelectionColor(org.eclipse.swt.graphics.RGB newcolor)
public org.eclipse.swt.graphics.RGB getSecondarySelectionColor()
By default this returns getDefaultSecondarySelectionColor().
public void setSecondarySelectionColor(org.eclipse.swt.graphics.RGB newcolor)
public void paintControl(org.eclipse.swt.events.PaintEvent evt)
This is infrequently overridden.
paintControl
in interface org.eclipse.swt.events.PaintListener
public void applyRenderingHints(Graphics2D g2)
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.
protected void paintView(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
This is infrequently overridden, except perhaps to change the default rendering hints.
g2
- the Graphics2D graphics context to draw on.clipRect
- the clipping rectangle in document coordinatesprotected void paintPaperColor(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
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.
g2
- the graphics context to draw on.clipRect
- the clipping rectangle in document coordinatesprotected void paintBackgroundDecoration(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
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.
g2
- the graphics context on which to draw.clipRect
- the clipping rectangle in document coordinatesprotected void paintDocumentObjects(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
g2
- the graphics context to draw on.clipRect
- the clipping rectangle in document coordinatesprotected void paintViewObjects(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
g2
- the graphics context to draw on.clipRect
- the clipping rectangle in document coordinatespublic void updateScrollbars()
Called when the scrollbars need to be updated, such as when the document size or view position change.
public void updateView(org.eclipse.swt.graphics.Rectangle viewRect)
Called when part of the view needs to be redrawn, such as when a particular object needs to be redrawn.
viewRect
- the area to be redrawn, in the canvas's Component coordinatespublic void updateView()
Called when the whole view and the scrollbars need to be repainted.
public void addViewListener(JGoViewListener l)
l
- an object supporting the JGoViewListener interfacepublic void removeViewListener(JGoViewListener l)
l
- an object supporting the JGoViewListener interfacepublic JGoViewListener[] getViewListeners()
public void addDocumentListener(JGoDocumentListener l)
l
- an object supporting the JGoDocumentListener interfacepublic void removeDocumentListener(JGoDocumentListener l)
l
- an object supporting the JGoDocumentListener interfacepublic JGoDocumentListener[] getDocumentListeners()
public final void fireUpdate(int hint, int flags, java.lang.Object x)
This method is now final, because it just calls the other fireUpdate method.
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.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)
By default it is also responsible for firing a JGoViewEvent to all JGoViewListeners.
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 coordsdc
- the current position of the mouse in doc coordsmodifiers
- which keys are pressedpublic void documentChanged(JGoDocumentEvent evt)
This implements JGoDocumentListener.
documentChanged
in interface JGoDocumentListener
evt
- the document event, including the hint type, any flags, and any relevant objectpublic void print()
By default this brings up the operating system print dialog and uses a default paper margin of 0.5 inch on each side.
protected void printBegin(Graphics2D g2, org.eclipse.swt.printing.Printer p)
g2
- the Graphics2D that we are printing to; may be nullp
- the Printerpublic Dimension getPrintDocumentSize()
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.
public org.eclipse.swt.graphics.Point getPrintDocumentTopLeft()
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.
protected org.eclipse.swt.graphics.Rectangle getPrintPageRect(Graphics2D g2, org.eclipse.swt.printing.Printer p)
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.
g2
- the Graphics2D that we are printing to; may be nullp
- the Printerprotected double getPrintScale(Graphics2D g2, org.eclipse.swt.printing.Printer p)
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.
g2
- the Graphics2D that we are printing to; may be nullp
- the Printerprotected void printEnd(Graphics2D g2, org.eclipse.swt.printing.Printer p)
g2
- the Graphics2D that we are printing to; may be nullp
- the Printerpublic int print(Graphics2D g, org.eclipse.swt.printing.Printer p, int pnum)
This returns zero when there are no more pages to be printed.
public boolean isPrinting()
Currently this is only used for influencing Greeking behavior for text and ports.
protected void printDecoration(Graphics2D g2, org.eclipse.swt.printing.Printer p, int hpnum, int vpnum)
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.
g2
- the Graphics2D that we are printing top
- the Printerhpnum
- the horizontal page number (zero based)vpnum
- the vertical page number (zero based)protected void printView(Graphics2D g2, org.eclipse.swt.graphics.Rectangle clipRect)
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).
g2
- the Graphics2D graphics context to draw on.clipRect
- the clipping rectangle in document coordinatespublic void doLayout()
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint)
This just returns the result of computeSize(wHint, hHint, false).
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
public void controlMoved(org.eclipse.swt.events.ControlEvent e)
controlMoved
in interface org.eclipse.swt.events.ControlListener
public void controlResized(org.eclipse.swt.events.ControlEvent e)
controlResized
in interface org.eclipse.swt.events.ControlListener
public void shellActivated(org.eclipse.swt.events.ShellEvent e)
shellActivated
in interface org.eclipse.swt.events.ShellListener
public void shellClosed(org.eclipse.swt.events.ShellEvent e)
shellClosed
in interface org.eclipse.swt.events.ShellListener
public void shellDeactivated(org.eclipse.swt.events.ShellEvent e)
shellDeactivated
in interface org.eclipse.swt.events.ShellListener
public void shellDeiconified(org.eclipse.swt.events.ShellEvent e)
shellDeiconified
in interface org.eclipse.swt.events.ShellListener
public void shellIconified(org.eclipse.swt.events.ShellEvent e)
shellIconified
in interface org.eclipse.swt.events.ShellListener
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
widgetSelected
in interface org.eclipse.swt.events.SelectionListener
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e)
widgetDefaultSelected
in interface org.eclipse.swt.events.SelectionListener
public void setKeyEnabled(boolean m)
m
- true to allow handling keyboard key events;
false to ignore thempublic boolean isKeyEnabled()
public void keyPressed(org.eclipse.swt.events.KeyEvent evt)
keyPressed
in interface org.eclipse.swt.events.KeyListener
public void keyTyped(org.eclipse.swt.events.KeyEvent evt)
public void keyReleased(org.eclipse.swt.events.KeyEvent evt)
keyReleased
in interface org.eclipse.swt.events.KeyListener
public void onKeyEvent(org.eclipse.swt.events.KeyEvent evt)
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.
evt
- the keystroke eventpublic boolean isIgnoreNextMouseDown()
public void setIgnoreNextMouseDown(boolean bFlag)
bFlag
- true to ignore next mouse pressprotected boolean keyToggleSelection(int modifiers)
The default implementation returns true if shift or control is held down.
modifiers
- the key state -- see InputEventprotected boolean keyExtendSelection(int modifiers)
The default implementation returns true if shift is held down.
modifiers
- the key state -- see InputEventprotected boolean keySingleSelection(int modifiers)
The default implementation always returns true.
modifiers
- the key state -- see InputEventprotected final boolean keyMultipleSelect(int modifiers)
protected boolean keyClearSelection(int modifiers)
The default implementation is to return true unless shift or control is held down.
modifiers
- the key state -- see InputEventprotected void initializeMouseHandling()
public void setMouseEnabled(boolean m)
m
- true to allow user mouse actions; false to ignore
mouse presses, drags, releases and dropspublic boolean isMouseEnabled()
protected final org.eclipse.swt.events.MouseEvent getCurrentMouseEvent()
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.
public void mouseDown(org.eclipse.swt.events.MouseEvent evt)
mouseDown
in interface org.eclipse.swt.events.MouseListener
public void mouseUp(org.eclipse.swt.events.MouseEvent evt)
mouseUp
in interface org.eclipse.swt.events.MouseListener
public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent evt)
mouseDoubleClick
in interface org.eclipse.swt.events.MouseListener
public void mouseMove(org.eclipse.swt.events.MouseEvent evt)
mouseMove
in interface org.eclipse.swt.events.MouseMoveListener
public boolean doMouseDown(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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.
modifiers
- which keys are presseddc
- the current position of the mouse in doc coordsvc
- the current position of the mouse in view coordspublic boolean doMouseMove(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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.
modifiers
- which keys are presseddc
- the current position of the mouse in doc coordsvc
- the current position of the mouse in view coordspublic boolean doMouseUp(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
modifiers
- which keys are pressed, etc.vc
- the view coordinates.dc
- the document coordinates.public boolean doMouseClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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.
modifiers
- which keys are presseddc
- the destination point in document coordinatesvc
- the destination point in view coordinatespublic boolean doMouseDblClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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.
modifiers
- which keys are presseddc
- the destination point in document coordinatesvc
- the destination point in view coordinatespublic void doCancelMouse()
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.
public final int getState()
public void setState(int s)
s
- the new mouse state, normally a user-defined state or MouseStateNonepublic final JGoObject getCurrentObject()
public void setCurrentObject(JGoObject obj)
public void doUncapturedMouseMove(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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.
modifiers
- which keys are presseddc
- the destination point in document coordinatesvc
- the destination point in view coordinatespublic int getDefaultCursorType()
public void setDefaultCursorType(int cursor)
public int getCursorType()
public void setCursorType(int c)
public void doBackgroundClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
public void doMoveSelection(int modifiers, int offsetx, int offsety, int event)
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.
modifiers
- which keys are pressedoffsetx
- the distance to move horizontally, in document coordinatesoffsety
- the distance to move vertically, in document coordinatesevent
- one of: EventMouseDown, EventMouseMove, EventMouseUppublic boolean isDragsRealtime()
By default this is true.
public void setDragsRealtime(boolean bFlag)
A value of false may be more responsive for large selections or for objects that require a lot of computation when moved.
bFlag
- true topublic int getInternalMouseActions()
The default value is Copy-or-Move.
For drag-and-drops that occur between windows (Components), see computeAcceptableDrop and the DropTargetListener methods.
public void setInternalMouseActions(int m)
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.
public boolean isDragsSelectionImage()
By default this is true.
public void setDragsSelectionImage(boolean bFlag)
public void moveSelection(JGoSelection sel, int modifiers, int offsetx, int offsety, int event)
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.
sel
- the selection of objects to be moved by the given offsetsmodifiers
- which keys are pressed (not used by the default implementation)offsetx
- the distance to move horizontally, in document coordinatesoffsety
- the distance to move vertically, in document coordinatesevent
- one of: EventMouseDown, EventMouseMove, EventMouseUppublic java.util.ArrayList computeEffectiveSelection(JGoObjectSimpleCollection coll)
coll
- a collection of JGoObjects to be dragged (moved or copied)
public java.util.ArrayList computeEffectiveSelection(JGoObjectSimpleCollection coll, boolean move, boolean includelinks)
coll
- a collection of JGoObjects to be dragged (moved or copied)move
- whether the drag is intended to be a move instead of a copyincludelinks
- whether to add all links whose ports are part of the collection
public void doCancelMoveSelection(org.eclipse.swt.graphics.Point offset)
public void copySelection(JGoSelection sel, int modifiers, int offsetx, int offsety, int event)
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().
sel
- the selection of objects to be copied by the given offsetsmodifiers
- which keys are pressed (not used by the default implementation)offsetx
- the distance to move horizontally, in document coordinatesoffsety
- the distance to move vertically, in document coordinatesevent
- one of: EventMouseDown, EventMouseMove, EventMouseUpprotected boolean startMoveSelection(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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.
modifiers
- key modifersdc
- the current mouse point in document coordinatesvc
- the current mouse point in view coordinatesprotected boolean startDragBoxSelection(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
This changes the state to MouseStateDragBoxSelection and starts drawing a rubber-band box in XOR mode from the given view-coordinates point.
modifiers
- key modifersdc
- the current mouse point in document coordinatesvc
- the current mouse point in view coordinatesprotected boolean startResizing(JGoHandle handle, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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.
handle
- the handle with which the user is doing the resizedc
- the current mouse point in document coordinatesvc
- the current mouse point in view coordinates
protected void handleResizing(Graphics2D g, org.eclipse.swt.graphics.Point vc, org.eclipse.swt.graphics.Point dc, int event)
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.
g
- the graphics to be used for drawing any resizing feedbackvc
- the current mouse point in view coordinatesdc
- the current mouse point in document coordinatesevent
- one of: EventMouseUp, EventMouseMove, EventMouseDownpublic void doCancelResize(org.eclipse.swt.graphics.Rectangle orig)
public JGoActionObject pickActionObject(org.eclipse.swt.graphics.Point dc)
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.
dc
- the current mouse point in document coordinates
public boolean startActionObject(JGoActionObject actionobj, int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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".
actionobj
- a JGoObject implementing JGoActionObjectmodifiers
- the key statevc
- the current mouse point in view coordinatesdc
- the current mouse point in document coordinates
public void handleActionObject(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc, int event)
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.
modifiers
- the key statevc
- the current mouse point in view coordinatesdc
- the current mouse point in document coordinatesevent
- one of JGoView.EventMouseDown, EventMouseMove, or EventMouseUp.public java.lang.String getToolTipText(org.eclipse.swt.events.MouseEvent evt)
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.
evt
- the mouse event generated when passing over the canvas.
public void doBackgroundToolTip(org.eclipse.swt.events.MouseEvent e)
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.
public void doToolTip(org.eclipse.swt.events.MouseEvent e)
public void setEditControl(JGoTextEdit edit)
edit
- the JGoTextEdit objectpublic JGoTextEdit getEditControl()
public boolean isEditingTextControl()
public void doEndEdit()
protected void drawXORRect(Graphics2D g, int x, int y, int w, int h)
g
- the graphics context on which to drawx
- 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)public boolean isDrawsXorMode()
The default value is false.
public void setDrawsXorMode(boolean d)
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.
protected void drawXORBox(Graphics2D g, int corner1x, int corner1y, int corner2x, int corner2y, int event)
g
- the graphics context on which to draw.corner1x
- one corner of the rectangle in view coordinatescorner1y
- one corner of the rectangle in view coordinatescorner2x
- the opposite corner in view coordinatescorner2y
- the opposite corner in view coordinatesevent
- one of: EventMouseUp, EventMouseMove, EventMouseDownpublic Graphics2D getJGoGraphics()
public void disposeJGoGraphics(Graphics2D g)
g
- a Graphics2D produced by a call to getJGoGraphicsprotected JGoHandle pickHandle(org.eclipse.swt.graphics.Point point)
Return null if there is no such handle, or if you do not want the handle to particpate in user-controlled resizing gestures.
point
- a point in document coordinatespublic void newLink(JGoPort from, JGoPort to)
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.
from
- the source portto
- the destination portprotected void noNewLink(JGoPort from, JGoPort to)
This method is responsible for committing a transaction on the view's document.
from
- the source port (may be null)to
- the destination port (may be null)public void reLink(JGoLink oldlink, JGoPort from, JGoPort to)
This method is responsible for firing the JGoViewEvent.LINK_RELINKED event and for committing a transaction on the view's document.
oldlink
- the existing link being reconnectedfrom
- the source portto
- the destination portprotected void noReLink(JGoLink oldlink, JGoPort from, JGoPort to)
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.
oldlink
- the existing link being reconnectedfrom
- the source port (may be null)to
- the destination port (may be null)public boolean validLink(JGoPort from, JGoPort to)
from
- the source portto
- the destination port
public boolean validSourcePort(JGoPort from)
By default this checks to make sure the port is in a modifiable layer/document and that the port is a valid source.
from
- the source port
public boolean validDestinationPort(JGoPort to)
By default this checks to make sure the port is in a modifiable layer/document and that the port is a valid destination.
to
- the source port
public int getPortGravity()
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().
public JGoPort pickNearestPort(org.eclipse.swt.graphics.Point dc)
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.
protected JGoPort pickPort(org.eclipse.swt.graphics.Point dc)
Return null if there is no such port, or if you do not want the port to particpate in user-controlled linking gestures.
dc
- a point in document coordinatespublic boolean startNewLink(JGoPort port, org.eclipse.swt.graphics.Point dc)
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.
port
- represents the port at which the user pressed
and starting dragging the mouse.dc
- the point where the mouse is, in document coordinates
public boolean startReLink(JGoLink oldlink, JGoPort oldport, org.eclipse.swt.graphics.Point dc)
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.
oldlink
- an existing document link with one null JGoPort
that needs to be re-hooked up at that endoldport
- 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
protected JGoPort createTemporaryPortForNewLink(JGoPort port, org.eclipse.swt.graphics.Point dc)
port
- the port at which the user started dragging to create a new linkdc
- the Point at which the user is starting the new link,
in document coordinatesprotected JGoLink createTemporaryLinkForNewLink(JGoPort from, JGoPort to)
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.
from
- the source portto
- the destination portpublic void copy()
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.
public void copyToClipboard(org.eclipse.swt.dnd.Clipboard clipboard)
The copy() and cut() methods are the normal callers of this method. This method does not start or finish any transaction.
clipboard
- the clipboard to receive a new document containing
a copy of the current selectionpublic void cut()
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.
public void deleteSelection()
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.
public void paste()
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).
public boolean canPaste()
public JGoCopyEnvironment pasteFromClipboard(org.eclipse.swt.dnd.Clipboard clipboard)
The paste() method is the normal caller of this method. This method does not start or finish any transaction.
clipboard
- the clipboard supporting the standard JGoTransfer type,
containing objects to be copied to this document
using the default copying method.public void initializeDragDropHandling()
public void setDragDropEnabled(boolean m)
m
- true to turn on performing standard Java drag-and-drop behaviorpublic void setDragEnabled(boolean m)
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.
m
- true to turn on initiating standard Java drag-and-drop behaviorpublic void setDropEnabled(boolean m)
If the argument is false, the user will not be able to drop things from other windows into this one.
m
- true to turn on handling standard Java drag-and-drop behaviorpublic boolean isDragDropEnabled()
public boolean isDragEnabled()
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.
public boolean isDropEnabled()
public boolean isInternalDragDrop()
public org.eclipse.swt.dnd.DragSource getDragSource()
public org.eclipse.swt.dnd.DropTarget getDropTarget()
public void dragStart(org.eclipse.swt.dnd.DragSourceEvent event)
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.
dragStart
in interface org.eclipse.swt.dnd.DragSourceListener
protected void dragAccept(org.eclipse.swt.dnd.DragSourceEvent event)
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.
event
- the DragSourceEvent that was passed to the dragStart methodpublic void dragSetData(org.eclipse.swt.dnd.DragSourceEvent event)
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.
dragSetData
in interface org.eclipse.swt.dnd.DragSourceListener
public void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event)
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.
dragFinished
in interface org.eclipse.swt.dnd.DragSourceListener
public void dragEnter(org.eclipse.swt.dnd.DropTargetEvent event)
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.
dragEnter
in interface org.eclipse.swt.dnd.DropTargetListener
public void dragLeave(org.eclipse.swt.dnd.DropTargetEvent event)
dragLeave
in interface org.eclipse.swt.dnd.DropTargetListener
public void dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent event)
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.
dragOperationChanged
in interface org.eclipse.swt.dnd.DropTargetListener
public void dragOver(org.eclipse.swt.dnd.DropTargetEvent event)
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.
dragOver
in interface org.eclipse.swt.dnd.DropTargetListener
public void onExternalDragOver(org.eclipse.swt.dnd.DropTargetEvent event)
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.
public void dropAccept(org.eclipse.swt.dnd.DropTargetEvent event)
dropAccept
in interface org.eclipse.swt.dnd.DropTargetListener
public int computeAcceptableDrop(org.eclipse.swt.dnd.DropTargetEvent event)
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.
public void drop(org.eclipse.swt.dnd.DropTargetEvent event)
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.
drop
in interface org.eclipse.swt.dnd.DropTargetListener
public void onExternalDrop(org.eclipse.swt.dnd.DropTargetEvent event)
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.
public boolean doDrop(org.eclipse.swt.dnd.DropTargetEvent e, JGoCopyEnvironment copyenv)
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.
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.
public int convertActionToModifiers(int action)
public Insets getAutoscrollInsets()
public void setAutoscrollInsets(Insets insets)
insets
- the margins in which autoscrolling will occurpublic void doAutoscroll(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc)
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().
public void stopAutoscroll()
public org.eclipse.swt.graphics.Point computeAutoscrollViewPosition(org.eclipse.swt.graphics.Point viewPnt)
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.
viewPnt
- the current mouse point, in view coordinatespublic void mouseEnter(org.eclipse.swt.events.MouseEvent e)
mouseEnter
in interface org.eclipse.swt.events.MouseTrackListener
public void mouseExit(org.eclipse.swt.events.MouseEvent e)
mouseExit
in interface org.eclipse.swt.events.MouseTrackListener
public void mouseHover(org.eclipse.swt.events.MouseEvent e)
mouseHover
in interface org.eclipse.swt.events.MouseTrackListener
public JGoLayer getFirstLayer()
public JGoLayer getLastLayer()
public JGoLayer getNextLayer(JGoLayer layer)
public JGoLayer getPrevLayer(JGoLayer layer)
public java.lang.String getEditPresentationName(int act)
public int getDebugFlags()
public void setDebugFlags(int f)
Currently the following flags are defined:
f
- public static org.eclipse.swt.graphics.RGB getDefaultPrimarySelectionColor()
public static void setDefaultPrimarySelectionColor(org.eclipse.swt.graphics.RGB c)
public static org.eclipse.swt.graphics.RGB getDefaultSecondarySelectionColor()
public static void setDefaultSecondarySelectionColor(org.eclipse.swt.graphics.RGB c)
public static int getDefaultPortGravity()
public static void setDefaultPortGravity(int gravity)
public void setGridWidth(int width)
If the grid size given is different than the current grid size, then we call onGridChange().
width
- the new horizontal spacing, in document coordinatespublic int getGridWidth()
The default grid width is 50.
public void setGridHeight(int height)
height
- the new vertical spacing, in document coordinatespublic int getGridHeight()
The default grid height is 50.
public void setGridStyle(int style)
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().
style
- the new grid stylepublic int getGridStyle()
The default style is GridInvisible--no grid is drawn.
public void setGridOrigin(org.eclipse.swt.graphics.Point point)
If the new grid origin is different than the current grid origin, then we call onGridChange().
point
- the new location of the start of the grid,
in document coordinatespublic org.eclipse.swt.graphics.Point getGridOrigin()
The default position of the grid origin is (0,0).
public void setGridSpot(int spot)
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().
spot
- the object spot to snapJGoObject
public int getGridSpot()
The default spot is JGoObject.TopLeft.
public void setGridPen(JGoPen pen)
pen
- the pen to be used in drawing the gridpublic JGoPen getGridPen()
The view's initial grid pen is JGoPen.lightGray.
public int getSnapMove()
This defaults to NoSnap.
public void setSnapMove(int snap)
snap
- one of: NoSnap, SnapJump, SnapAfterpublic int getSnapResize()
This defaults to NoSnap.
public void setSnapResize(int snap)
snap
- one of: NoSnap, SnapJump, SnapAfterpublic void onGridChange(int what)
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.
what
- the aspect of the grid that has changedprotected void drawGridLines(Graphics2D g, org.eclipse.swt.graphics.Rectangle clipRect)
g
- the graphics context onto which to draw.clipRect
- the bounds for where we need to draw, in document coordinatesprotected void drawGridCrosses(Graphics2D g, int crossHeight, int crossWidth, org.eclipse.swt.graphics.Rectangle clipRect)
g
- where to draw the crossescrossHeight
- the height of the crosses, in document coordinatescrossWidth
- the width of the crosses, in document coordinatesclipRect
- the bounds for where we need to draw, in document coordinatespublic void snapObject(JGoObject object)
object
- the object to snap.public void snapObject(JGoObject object, int spotNumber)
object
- the object to snap.spotNumber
- which spot to snap.public void snapAllObjects()
public void snapAllObjects(int spotNumber)
This does not call snapObject on any JGoLinks.
spotNumber
- which spot to snappublic org.eclipse.swt.graphics.Point findNearestGridPoint(int x, int y, org.eclipse.swt.graphics.Point result)
x
- the X position in document coordinatesy
- the Y position in document coordinatesresult
- a Point that is modified to be the closest grid point,
in document coordinates
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |