|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.nwoods.jgo.JGoView
JGoView is a lightweight Swing JComponent 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 Swing JComponent. 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 a Swing JComponent, JGoView's canvas overrides paintComponent() in order to render the view. This just calls JGoView.onPaintComponent(), which 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.
Version 5.1 also introduces a printPreview method.
Scrolling
JGoView has support for scrolling and scroll bars built in. The use of JScrollPane and JViewport is not necessary. 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 has a drag gesture recognizer and acts 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 several methods: isDropFlavorAcceptable(), computeAcceptableDrop(), and drop(). If you want to make use of the default copy behavior for JGoSelection, you can call doDrop() from your override of drop(). If you need somewhat more extensive customization, you can just override all the standard DropTargetListener methods.
The implementation of drag-and-drop does not actually make the JGoView the listener for drag gestures, drag source events, or drop target events. It is actually the view's canvas, which delegates to internal methods of the view, which in turn call the respective standard listener methods. The reason for this additional step is to allow default support for dragging selection handles, drawing a rubber-band selection box, or starting a link between ports. If you really need complete control of mouse-related operations for a view, you'll need to override the internal handler methods, whose names are prefixed with "on".
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(DnDConstants.ACTION_MOVE).
An internal drag, when the CTRL key is held down, makes an outline 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. For views that are part of Applets, you'll need to call initializeDragDropHandling first from a different thread, but only after the applet has been started.
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, depend on the document's DataFlavor, the document's and selection's implementation of Transferable, and 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 a Swing JTextComponent 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,
Serialized Form| Nested Class Summary | |
class |
JGoView.JGoViewCanvas
|
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| 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 javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
JGoView()
Construct a new view of a document returned by calling createDefaultModel() |
|
JGoView(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. |
void |
addNotify()
Only initialize drag-and-drop handling if there's a topmost Frame, and we're not inside an Applet. |
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(java.awt.Graphics2D g2)
Set the standard RenderingHints for how shapes, images, and text are drawn. |
void |
autoscroll(java.awt.Point location)
Implement the Autoscroll interface. |
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. |
void |
completeDrop(java.awt.dnd.DropTargetDropEvent e,
boolean success)
This method implements a work-around for a Java bug on Windows. |
int |
computeAcceptableDrop(java.awt.dnd.DropTargetDragEvent e)
This method is called by the default implementations of DropTargetListener.dragEnter, dragOver, and dropActionChanged to dynamically determine the permissible drop actions. |
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. |
int |
convertActionToModifiers(int action)
This method converts a DropTarget event's dropAction to an InputEvent's modifiers. |
void |
convertDocToView(java.awt.Dimension d)
Convert a Dimension in document coordinates to view coordinates. |
void |
convertDocToView(java.awt.Point p)
Convert a Point in document coordinates to view coordinates. |
void |
convertDocToView(java.awt.Rectangle r)
Convert a Rectangle in document coordinates to view coordinates. |
void |
convertViewToDoc(java.awt.Dimension d)
Convert a Dimension in view coordinates to document coordinates. |
void |
convertViewToDoc(java.awt.Point p)
Convert a Point in view coordinates to document coordinates. |
void |
convertViewToDoc(java.awt.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(java.awt.datatransfer.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,
java.awt.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(java.awt.Graphics2D g)
This convenience function disposes the Graphics object that is passed, or is a no-op if the object is null. |
void |
doBackgroundClick(int modifiers,
java.awt.Point dc,
java.awt.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 |
doCancelMouse()
When one needs to cancel any mouse operation, this function restores the view to the normal state. |
void |
doCancelMoveSelection(java.awt.Point offset)
Called when the user's dragging of the current selection is cancelled. |
void |
doCancelResize(java.awt.Rectangle orig)
Called when the user's resizing of an object is cancelled. |
java.awt.Dimension |
docToViewCoords(java.awt.Dimension d)
Convert document dimensions to view coordinates. |
java.awt.Rectangle |
docToViewCoords(int x,
int y,
int w,
int h)
Convert a rectangle in document coordinates to a rectangle in view coordinates. |
java.awt.Point |
docToViewCoords(java.awt.Point d)
Convert a point from document coordinates to view coordinates. |
java.awt.Rectangle |
docToViewCoords(java.awt.Point p,
java.awt.Dimension d)
Convert a rectangle in document coordinates to a rectangle in view coordinates. |
java.awt.Rectangle |
docToViewCoords(java.awt.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(java.awt.dnd.DropTargetDropEvent e,
JGoCopyEnvironment copyenv)
Perform the default drop operation, as a result of a DropTargetListener.drop(DropTargetDropEvent). |
void |
doEndEdit()
Tell any edit control (JGoTextEdit) that it's time to stop being in edit mode. |
void |
doLayout()
This method actually performs the layout of the canvas, the scrollbars, and the corner component. |
boolean |
doMouseClick(int modifiers,
java.awt.Point dc,
java.awt.Point vc)
Handle single click behavior for an object in the document. |
boolean |
doMouseDblClick(int modifiers,
java.awt.Point dc,
java.awt.Point vc)
Handle double click behavior for an object in the document. |
boolean |
doMouseDown(int modifiers,
java.awt.Point dc,
java.awt.Point vc)
Called when a mouse button is pressed. |
boolean |
doMouseMove(int modifiers,
java.awt.Point dc,
java.awt.Point vc)
Called when the mouse is moved. |
boolean |
doMouseUp(int modifiers,
java.awt.Point dc,
java.awt.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 |
doUncapturedMouseMove(int modifiers,
java.awt.Point dc,
java.awt.Point vc)
This method is called when the mouse is moved over the canvas and no other mouse behavior is happening. |
void |
dragDropEnd(java.awt.dnd.DragSourceDropEvent e)
This implements the default drag source listener, a no-op. |
void |
dragEnter(java.awt.dnd.DragSourceDragEvent e)
This implements the default drag source listener, a no-op. |
void |
dragEnter(java.awt.dnd.DropTargetDragEvent e)
This implements the default drop target listener, calling isDropFlavorAcceptable() to see if any drop is possible, and then calling computeAcceptableDrop() to decide whether to reject or accept the drag. |
void |
dragExit(java.awt.dnd.DragSourceEvent e)
This implements the default drag source listener, a no-op. |
void |
dragExit(java.awt.dnd.DropTargetEvent e)
This implements the default drop target listener, a no-op. |
void |
dragGestureRecognized(java.awt.dnd.DragGestureEvent e)
This implements the default drag gesture listener, starting a drag. |
void |
dragOver(java.awt.dnd.DragSourceDragEvent e)
This implements the default drag source listener, a no-op. |
void |
dragOver(java.awt.dnd.DropTargetDragEvent e)
This implements the default drop target listener, calling isDropFlavorAcceptable() and computeAcceptableDrop() to decide whether to reject or accept the drag. |
protected void |
drawGridCrosses(java.awt.Graphics2D g,
int crossHeight,
int crossWidth,
java.awt.Rectangle clipRect)
This method draws little crosses at the grid points. |
protected void |
drawGridLines(java.awt.Graphics2D g,
java.awt.Rectangle clipRect)
This method draws grid lines. |
protected void |
drawXORBox(java.awt.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(java.awt.Graphics2D g,
int x,
int y,
int w,
int h)
Performs the actual drawing of the XOR'ed rectangle. |
void |
drop(java.awt.dnd.DropTargetDropEvent e)
This implements the default drop target listener, calling doDrop() and rejecting the drop if it returned false. |
void |
dropActionChanged(java.awt.dnd.DragSourceDragEvent e)
This implements the default drag source listener, a no-op. |
void |
dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
This implements the default drop target listener, calling isDropFlavorAcceptable() and computeAcceptableDrop() to decide whether to reject or accept the drag. |
java.awt.Point |
findNearestGridPoint(int x,
int y,
java.awt.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,
java.awt.Point vc,
java.awt.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. |
java.awt.Insets |
getAutoscrollInsets()
Returns the inset margins in which autoscrolling will occur. |
java.awt.Image |
getBackgroundImage()
Return the Image displayed in the background of this view. |
JGoView.JGoViewCanvas |
getCanvas()
Return the component representing the canvas--where JGoObjects will be drawn. |
javax.swing.JComponent |
getCorner()
Return the component used at the corner between the horizontal and vertical scrollbars. |
protected java.awt.event.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 |
getDebugFlags()
Return the conditions under which this view generates TRACE messages. |
java.awt.Cursor |
getDefaultCursor()
Return the default cursor for the view. |
static int |
getDefaultPortGravity()
Return the default distance at which a link will snap to a port. |
static java.awt.Color |
getDefaultPrimarySelectionColor()
Return the default primary selection color. |
static java.awt.Color |
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. |
java.awt.Dimension |
getDocumentSize()
Return the size of the document as seen by this view. |
java.awt.Point |
getDocumentTopLeft()
Return the top-left corner of the document as seen by this view. |
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. |
java.awt.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. |
java.awt.Frame |
getFrame()
Return the Frame that this view is in. |
int |
getGridHeight()
Get the vertical spacing of the grid. |
java.awt.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. |
javax.swing.JScrollBar |
getHorizontalScrollBar()
Return the horizontal scrollbar, or null if there is none. |
int |
getInternalMouseActions()
Return which kinds of drag-and-drop actions are permitted for mouse drags that start and end in this view. |
java.awt.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. |
java.awt.Dimension |
getMinimumSize()
The minimum size for this JComponent defaults to (50, 50). |
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. |
java.awt.Dimension |
getPreferredSize()
The preferred size for a view normally comes from the document. |
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. |
java.awt.Color |
getPrimarySelectionColor()
Returns the primary selection color. |
java.awt.Dimension |
getPrintDocumentSize()
Return the size of the document to be printed, in document coordinates. |
java.awt.Point |
getPrintDocumentTopLeft()
This method returns the coordinates of the document's top-left corner, where printing should start from. |
protected java.awt.geom.Rectangle2D.Double |
getPrintPageRect(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
Return the bounds for the part of the print page that should hold the rendered graph. |
protected double |
getPrintScale(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
Return the scale at which the graph should be printed. |
double |
getScale()
Return the current scale at which JGoObjects are displayed. |
java.awt.Color |
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(java.awt.event.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. |
javax.swing.JScrollBar |
getVerticalScrollBar()
Return the vertical scrollbar, or null if there is none. |
JGoViewListener[] |
getViewListeners()
Return an array of the JGoViewListeners that are currently listening for JGoViewEvents on this view. |
java.awt.Point |
getViewPosition()
Return the position in the document of the top-left point of the view. |
java.awt.Rectangle |
getViewRect()
Return a rectangle whose origin is getViewPosition() and size is getExtentSize(). |
void |
handleActionObject(int modifiers,
java.awt.Point dc,
java.awt.Point vc,
int event)
Handle further mouse events on a JGoActionObject. |
protected void |
handleResizing(java.awt.Graphics2D g,
java.awt.Point vc,
java.awt.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. |
protected void |
internalPrint(java.awt.print.PrinterJob pj)
|
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 |
isDropFlavorAcceptable(java.awt.dnd.DropTargetDragEvent e)
This predicate is called by the default implementation of DropTargetListener.dragEnter, dragOver, and dropActionChanged to see if there is an acceptable DataFlavor available. |
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 |
isFocusTraversable()
This returns true to allow tabbing to this component. |
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(java.awt.event.KeyEvent evt)
This method implements KeyListener. |
void |
keyReleased(java.awt.event.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(java.awt.event.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 |
lostOwnership(java.awt.datatransfer.Clipboard c,
java.awt.datatransfer.Transferable t)
This method implements ClipboardOwner. |
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 |
onDragDropEnd(java.awt.dnd.DragSourceDropEvent e)
This implements the internal drag source listener |
void |
onDragEnter(java.awt.dnd.DragSourceDragEvent e)
This implements the internal drag source listener |
void |
onDragEnter(java.awt.dnd.DropTargetDragEvent e)
This implements the internal drop target listener |
void |
onDragExit(java.awt.dnd.DragSourceEvent e)
This implements the internal drag source listener |
void |
onDragExit(java.awt.dnd.DropTargetEvent e)
This implements the internal drop target listener |
void |
onDragGestureRecognized(java.awt.dnd.DragGestureEvent e)
This implements the internal drag gesture listener |
void |
onDragOver(java.awt.dnd.DragSourceDragEvent e)
This implements the internal drag source listener |
void |
onDragOver(java.awt.dnd.DropTargetDragEvent e)
This implements the internal drop target listener |
void |
onDrop(java.awt.dnd.DropTargetDropEvent e)
This implements the internal drop target listener |
void |
onDropActionChanged(java.awt.dnd.DragSourceDragEvent e)
This implements the internal drag source listener |
void |
onDropActionChanged(java.awt.dnd.DropTargetDragEvent e)
This implements the internal drop target listener |
void |
onGridChange(int what)
Called when some characteristic of the grid has changed. |
void |
onKeyEvent(java.awt.event.KeyEvent evt)
This is the default event handler for keystroke commands. |
protected void |
onMouseDragged(java.awt.event.MouseEvent evt)
This is the internal event handler for mouse motion drag events. |
protected void |
onMouseMoved(java.awt.event.MouseEvent evt)
This is the internal event handler for mouse motion non-drag events. |
protected void |
onMousePressed(java.awt.event.MouseEvent evt)
This is the internal event handler for mouse down events. |
protected void |
onMouseReleased(java.awt.event.MouseEvent evt)
This is the internal event handler for mouse up events. |
protected void |
onPaintComponent(java.awt.Graphics g)
This method is invoked by the canvas's paintComponent(). |
protected void |
onScrollEvent(java.awt.event.AdjustmentEvent evt)
This is the event handler for the scrollbars. |
protected void |
paintBackgroundDecoration(java.awt.Graphics2D g2,
java.awt.Rectangle clipRect)
Draw any background image or decorations before any of the document or the view objects are drawn. |
protected void |
paintDocumentObjects(java.awt.Graphics2D g2,
java.awt.Rectangle clipRect)
Draw all of the visible document objects that intersect the given clipping rectangle. |
protected void |
paintPaperColor(java.awt.Graphics2D g2,
java.awt.Rectangle clipRect)
Fill the background with the with the document's paper color. |
protected void |
paintView(java.awt.Graphics2D g2,
java.awt.Rectangle clipRect)
Render everything for this view that is within a given rectangle. |
protected void |
paintViewObjects(java.awt.Graphics2D g2,
java.awt.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(java.awt.datatransfer.Clipboard clipboard)
Copy JGoObjects from the clipboard into this document. |
JGoActionObject |
pickActionObject(java.awt.Point dc)
Return a JGoActionObject that is in the document at a given point. |
JGoObject |
pickDocObject(java.awt.Point pointToCheck,
boolean selectableOnly)
Find the topmost object in the document under the given point. |
protected JGoHandle |
pickHandle(java.awt.Point point)
Return a JGoHandle under the given document coordinate point. |
JGoPort |
pickNearestPort(java.awt.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(java.awt.Point pointToCheck,
boolean selectableOnly)
Find the topmost view object under the given point. |
protected JGoPort |
pickPort(java.awt.Point dc)
Return a JGoPort under the given document coordinate point. |
void |
print()
Call this to print the current view. |
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pf,
int pnum)
Implement the Printable interface; called by the PrinterJob. |
protected void |
printBegin(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
This method is called once at the beginning of the printing process. |
protected void |
printDecoration(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf,
int hpnum,
int vpnum)
Print any decorations on each page. |
protected void |
printEnd(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
This method is called once at the end of the printing process. |
void |
printPreview()
Bring up a JGoPrintPreview to preview the pages to be printed, if this is running in a Frame. |
void |
printPreview(java.lang.String title,
java.awt.print.PageFormat pf)
Bring up a JGoPrintPreview to preview the pages to be printed, if this is running in a Frame. |
protected java.awt.print.PageFormat |
printShowPageDialog(java.awt.print.PrinterJob pj)
This method is called in order to call PrinterJob.pageDialog. |
protected void |
printView(java.awt.Graphics2D g2,
java.awt.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(java.awt.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(java.awt.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(java.awt.Insets insets)
Set the canvas's Autoscroll Insets. |
void |
setBackgroundImage(java.awt.Image img)
Set the Image displayed in the background. |
void |
setBounds(int x,
int y,
int w,
int h)
This overrides Component.setBounds to make sure we re-layout the scroll bars. |
void |
setBounds(java.awt.Rectangle r)
This overrides Component.setBounds to make sure we re-layout the scroll bars. |
void |
setCorner(javax.swing.JComponent box)
Set the corner component, where the horizontal and vertical scrollbars would intersect. |
void |
setCurrentObject(JGoObject obj)
Change the current JGoObject, if any, associated with any mouse event handling. |
void |
setCursor(java.awt.Cursor cur)
This method implements a work-around for a Java bug on Windows, by delaying the actual setCursor call. |
void |
setCursorImmediately(java.awt.Cursor cur)
This method helps implement a work-around for a Java bug on Windows. |
void |
setDebugFlags(int f)
Control whether this view generates TRACE messages during various operations. |
void |
setDefaultCursor(java.awt.Cursor cursor)
Set the default cursor for the view. |
static void |
setDefaultPortGravity(int gravity)
Set the default distance at which a link will snap to a port. |
static void |
setDefaultPrimarySelectionColor(java.awt.Color c)
Set the default primary selection color. |
static void |
setDefaultSecondarySelectionColor(java.awt.Color 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(java.awt.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 |
setHorizontalScrollBar(javax.swing.JScrollBar bar)
Set the horizontal scrollbar. |
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(java.awt.Color newcolor)
Set the primary selection color. |
void |
setScale(double scale)
Change the scale at which JGoObjects are displayed in this view. |
void |
setSecondarySelectionColor(java.awt.Color newcolor)
Set the secondary selection color. |
void |
setSize(java.awt.Dimension d)
This overrides Component.setSize to make sure we re-layout the scroll bars. |
void |
setSize(int width,
int height)
This overrides Component.setSize to make sure we re-layout the scroll bars. |
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 |
setVerticalScrollBar(javax.swing.JScrollBar bar)
Set the vertical scrollbar. |
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(java.awt.Point p)
Scroll the view to place the given document coordinates at the top-left corner of the view. |
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,
java.awt.Point dc,
java.awt.Point vc)
Start acting on a JGoActionObject. |
protected boolean |
startDragBoxSelection(int modifiers,
java.awt.Point dc,
java.awt.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,
java.awt.Point dc,
java.awt.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,
java.awt.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,
java.awt.Point dc)
Start the process of handling a user's drawing a link between two ports. |
protected boolean |
startResizing(JGoHandle handle,
java.awt.Point dc,
java.awt.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 |
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(java.awt.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. |
java.awt.Dimension |
viewToDocCoords(java.awt.Dimension v)
Convert view dimensions to document coordinates. |
java.awt.Rectangle |
viewToDocCoords(int x,
int y,
int w,
int h)
Convert a rectangle in view coordinates to a rectangle in document coordinates. |
java.awt.Point |
viewToDocCoords(java.awt.Point v)
Convert view coordinates to document coordinates. |
java.awt.Rectangle |
viewToDocCoords(java.awt.Point p,
java.awt.Dimension d)
Convert a rectangle in view coordinates to a rectangle in document coordinates. |
java.awt.Rectangle |
viewToDocCoords(java.awt.Rectangle v)
Convert a rectangle in view coordinates to a rectangle in document coordinates. |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, show, show, size, toString, transferFocus, transferFocusUpCycle |
| 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()
public JGoView(JGoDocument doc)
doc - the document that serves as the model for this new view.| Method Detail |
public java.awt.Frame getFrame()
public void addNotify()
public JGoView.JGoViewCanvas getCanvas()
public javax.swing.JScrollBar getVerticalScrollBar()
You may wish to set the scrollbar's unit increment or block increment.
public void setVerticalScrollBar(javax.swing.JScrollBar bar)
If the value is set to null, the scrollbar is removed from the view.
bar - the new scrollbar to be used by the view.public javax.swing.JScrollBar getHorizontalScrollBar()
You may wish to set the scrollbar's unit increment or block increment.
public void setHorizontalScrollBar(javax.swing.JScrollBar bar)
If the value is null, the scrollbar is removed from the view.
bar - the new scrollbar to be used by the view.public javax.swing.JComponent getCorner()
public void setCorner(javax.swing.JComponent box)
This corner component will be visible only if both horizontal and vertical scrollbars are used in the view.
If the value is null, the corner is removed from the view.
box - the new corner component to be used by the view.public java.awt.Image getBackgroundImage()
public void setBackgroundImage(java.awt.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 JGoDocument createDefaultModel()
public JGoDocument getDocument()
public void setDocument(JGoDocument doc)
doc - a JGoDocument that will be the new model.public java.awt.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 java.awt.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(java.awt.Point p)
p - a Point in view coordinatespublic void convertViewToDoc(java.awt.Dimension d)
d - a Dimension in view coordinatespublic void convertViewToDoc(java.awt.Rectangle r)
r - a Rectangle in view coordinatespublic final java.awt.Point viewToDocCoords(java.awt.Point v)
This is a convenience routine that allocates a new object for the return value.
v - the view coordinates
public final java.awt.Dimension viewToDocCoords(java.awt.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 java.awt.Rectangle viewToDocCoords(java.awt.Rectangle v)
This is a convenience routine that allocates a new object for the return value.
v - a rectangle in view coordinates
public final java.awt.Rectangle viewToDocCoords(java.awt.Point p,
java.awt.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 java.awt.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(java.awt.Point p)
p - a Point in doc coordinatespublic void convertDocToView(java.awt.Dimension d)
d - a Dimension in doc coordinatespublic void convertDocToView(java.awt.Rectangle r)
r - a Rectangle in doc coordinatespublic final java.awt.Point docToViewCoords(java.awt.Point d)
This is a convenience routine that allocates a new object for the return value.
d - a point in document coordinates
public final java.awt.Dimension docToViewCoords(java.awt.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 java.awt.Rectangle docToViewCoords(java.awt.Rectangle d)
This is a convenience routine that allocates a new object for the return value.
d - a rectangle in document coordinates
public final java.awt.Rectangle docToViewCoords(java.awt.Point p,
java.awt.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 java.awt.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(java.awt.Point p)
p - the new top-left point, in document coordinates
public 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 java.awt.Point getViewPosition()
The returned Point must not be modified. Use setViewPosition() to change the visible part of the document.
public java.awt.Dimension getExtentSize()
public java.awt.Rectangle getViewRect()
public void scrollRectToVisible(java.awt.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(java.awt.Point pointToCheck,
boolean selectableOnly)
pointToCheck - the point under which to find the object, in
document coordinatesselectableOnly - if true, consider only selectable objects
public JGoObject pickObject(java.awt.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 JGoObjectCollectionpointToCheck - 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 JGoObjectSimpleCollectionpublic boolean isEmpty()
isEmpty in interface JGoObjectSimpleCollectionpublic 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 JGoObjectCollectionobj - 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 JGoObjectCollectionobj - 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 JGoObjectCollectionpos - 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 JGoObjectCollectionpos - 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 JGoObjectCollectionobj - 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 JGoObjectCollectionobj - 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 JGoObjectCollectionobj - the object to remove.public JGoObject removeObjectAtPos(JGoListPosition pos)
JGoObjectCollection
removeObjectAtPos in interface JGoObjectCollectionpos - the position of the object to remove.
public JGoListPosition getFirstObjectPos()
JGoObjectSimpleCollection
getFirstObjectPos in interface JGoObjectSimpleCollectionpublic JGoListPosition getLastObjectPos()
JGoObjectCollection
getLastObjectPos in interface JGoObjectCollectionpublic JGoListPosition getNextObjectPos(JGoListPosition pos)
JGoObjectSimpleCollection
getNextObjectPos in interface JGoObjectSimpleCollectionpos - the position previous to that which will be returned.
public JGoListPosition getNextObjectPosAtTop(JGoListPosition pos)
JGoObjectSimpleCollection
getNextObjectPosAtTop in interface JGoObjectSimpleCollectionpos - the position from which to start searching for the next
top-level object.
public JGoListPosition getPrevObjectPos(JGoListPosition pos)
JGoObjectCollection
getPrevObjectPos in interface JGoObjectCollectionpos - the position of the object that follows the object position
to be returned.
public JGoObject getObjectAtPos(JGoListPosition pos)
JGoObjectSimpleCollection
getObjectAtPos in interface JGoObjectSimpleCollectionpos - the position of an object in the collection.
public JGoListPosition findObject(JGoObject obj)
JGoObjectCollection
findObject in interface JGoObjectCollectionobj - 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(java.awt.Rectangle rect)
rect - the Rectangle, in document coordinatespublic java.awt.Color getPrimarySelectionColor()
By default this returns getDefaultPrimarySelectionColor().
public void setPrimarySelectionColor(java.awt.Color newcolor)
public java.awt.Color getSecondarySelectionColor()
By default this returns getDefaultSecondarySelectionColor().
public void setSecondarySelectionColor(java.awt.Color newcolor)
protected void onPaintComponent(java.awt.Graphics g)
This is infrequently overridden.
public void applyRenderingHints(java.awt.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(java.awt.Graphics2D g2,
java.awt.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 coordinates
protected void paintPaperColor(java.awt.Graphics2D g2,
java.awt.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 coordinates
protected void paintBackgroundDecoration(java.awt.Graphics2D g2,
java.awt.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 coordinates
protected void paintDocumentObjects(java.awt.Graphics2D g2,
java.awt.Rectangle clipRect)
g2 - the graphics context to draw on.clipRect - the clipping rectangle in document coordinates
protected void paintViewObjects(java.awt.Graphics2D g2,
java.awt.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(java.awt.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,
java.awt.Point vc,
java.awt.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 JGoDocumentListenerevt - 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 java.awt.print.PageFormat printShowPageDialog(java.awt.print.PrinterJob pj)
You may want to override this method in order to modify the PageFormat that is passed to PrinterJob.pageDialog, or not to call that method at all. For example, to change the default orientation to LANDSCAPE:
protected PageFormat printShowPageDialog(PrinterJob pj) {
PageFormat defaultpf = pj.validatePage(pj.defaultPage());
// Change the default Orientation to be landscape.
defaultpf.setOrientation(PageFormat.LANDSCAPE);
// Ask the user what page size they're using, what the margins are,
// and whether they are printing in landscape or portrait mode.
PageFormat pf = pj.pageDialog(defaultpf);
// PF will be the same as DEFAULTPF if the user cancels this dialog;
// it will be a new PageFormat if the user OK'd it, perhaps having changed some values
if (pf != defaultpf)
return pf;
else
return null;
}
To avoid showing any page dialog at all, override as follows:
protected PageFormat printShowPageDialog(PrinterJob pj) {
PageFormat defaultpf = pj.validatePage(pj.defaultPage());
defaultpf.setOrientation(PageFormat.LANDSCAPE);
return defaultpf;
}
protected void internalPrint(java.awt.print.PrinterJob pj)
protected void printBegin(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
Because there may be many calls to Printable.print for each document, we calculate a number of values once and remember their values.
g2 - the Graphics2D that we are printing to; may be nullpf - the PageFormat constraining our printingpublic java.awt.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 java.awt.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 java.awt.geom.Rectangle2D.Double getPrintPageRect(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
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 nullpf - the PageFormat constraining our printing
protected double getPrintScale(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
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 nullpf - the PageFormat constraining our printing
protected void printEnd(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf)
Call this method to allow printBegin to be called again for the next printing operation on this JGoView.
g2 - the Graphics2D that we are printing to; may be nullpf - the PageFormat constraining our printing
public int print(java.awt.Graphics g,
java.awt.print.PageFormat pf,
int pnum)
print in interface java.awt.print.Printablepublic boolean isPrinting()
Currently this is only used for influencing Greeking behavior for text and ports.
protected void printDecoration(java.awt.Graphics2D g2,
java.awt.print.PageFormat pf,
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 topf - the PageFormat constraining our printinghpnum - the horizontal page number (zero based)vpnum - the vertical page number (zero based)
protected void printView(java.awt.Graphics2D g2,
java.awt.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 printPreview()
public void printPreview(java.lang.String title,
java.awt.print.PageFormat pf)
title - the title to show in the preview windowpf - a java.awt.print.PageFormat constant (e.g. PORTRAIT or LANDSCAPE)public void doLayout()
public void setSize(int width,
int height)
public final void setSize(java.awt.Dimension d)
public void setBounds(int x,
int y,
int w,
int h)
public final void setBounds(java.awt.Rectangle r)
public java.awt.Dimension getPreferredSize()
public java.awt.Dimension getMinimumSize()
protected void onScrollEvent(java.awt.event.AdjustmentEvent evt)
public void setKeyEnabled(boolean m)
m - true to allow handling keyboard key events;
false to ignore thempublic boolean isKeyEnabled()
public void keyPressed(java.awt.event.KeyEvent evt)
keyPressed in interface java.awt.event.KeyListenerpublic void keyTyped(java.awt.event.KeyEvent evt)
keyTyped in interface java.awt.event.KeyListenerpublic void keyReleased(java.awt.event.KeyEvent evt)
keyReleased in interface java.awt.event.KeyListenerpublic void onKeyEvent(java.awt.event.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 isFocusTraversable()
public 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 java.awt.event.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.
protected void onMousePressed(java.awt.event.MouseEvent evt)
protected void onMouseReleased(java.awt.event.MouseEvent evt)
protected void onMouseMoved(java.awt.event.MouseEvent evt)
protected void onMouseDragged(java.awt.event.MouseEvent evt)
public boolean doMouseDown(int modifiers,
java.awt.Point dc,
java.awt.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 coords
public boolean doMouseMove(int modifiers,
java.awt.Point dc,
java.awt.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 coords
public boolean doMouseUp(int modifiers,
java.awt.Point dc,
java.awt.Point vc)
modifiers - which keys are pressed, etc.vc - the view coordinates.dc - the document coordinates.
public boolean doMouseClick(int modifiers,
java.awt.Point dc,
java.awt.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 coordinates
public boolean doMouseDblClick(int modifiers,
java.awt.Point dc,
java.awt.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,
java.awt.Point dc,
java.awt.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 void setCursor(java.awt.Cursor cur)
public void setCursorImmediately(java.awt.Cursor cur)
public java.awt.Cursor getDefaultCursor()
public void setDefaultCursor(java.awt.Cursor cursor)
If the new cursor value is null, the view will use the standard default Cursor.
cursor - the cursor to use when no object specifies a cursor
public void doBackgroundClick(int modifiers,
java.awt.Point dc,
java.awt.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(java.awt.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, EventMouseUp
protected boolean startMoveSelection(int modifiers,
java.awt.Point dc,
java.awt.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 coordinates
protected boolean startDragBoxSelection(int modifiers,
java.awt.Point dc,
java.awt.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 coordinates
protected boolean startResizing(JGoHandle handle,
java.awt.Point dc,
java.awt.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(java.awt.Graphics2D g,
java.awt.Point vc,
java.awt.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(java.awt.Rectangle orig)
public JGoActionObject pickActionObject(java.awt.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,
java.awt.Point dc,
java.awt.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,
java.awt.Point dc,
java.awt.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(java.awt.event.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 setEditControl(JGoTextEdit edit)
edit - the JGoTextEdit objectpublic JGoTextEdit getEditControl()
public boolean isEditingTextControl()
public void doEndEdit()
protected void drawXORRect(java.awt.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(java.awt.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 java.awt.Graphics2D getJGoGraphics()
public void disposeJGoGraphics(java.awt.Graphics2D g)
g - a Graphics2D produced by a call to getJGoGraphicsprotected JGoHandle pickHandle(java.awt.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 coordinates
public 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 port
protected 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 port
protected 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(java.awt.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(java.awt.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 coordinates
public boolean startNewLink(JGoPort port,
java.awt.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,
java.awt.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,
java.awt.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 coordinates
protected 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 port
public void lostOwnership(java.awt.datatransfer.Clipboard c,
java.awt.datatransfer.Transferable t)
lostOwnership in interface java.awt.datatransfer.ClipboardOwnerpublic 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(java.awt.datatransfer.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(java.awt.datatransfer.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 JGoDocument DataFlavor,
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 void onDragGestureRecognized(java.awt.dnd.DragGestureEvent e)
public void dragGestureRecognized(java.awt.dnd.DragGestureEvent e)
dragGestureRecognized in interface java.awt.dnd.DragGestureListenerpublic void onDragEnter(java.awt.dnd.DragSourceDragEvent e)
public void onDragOver(java.awt.dnd.DragSourceDragEvent e)
public void onDropActionChanged(java.awt.dnd.DragSourceDragEvent e)
public void onDragExit(java.awt.dnd.DragSourceEvent e)
public void onDragDropEnd(java.awt.dnd.DragSourceDropEvent e)
public void dragEnter(java.awt.dnd.DragSourceDragEvent e)
dragEnter in interface java.awt.dnd.DragSourceListenerpublic void dragOver(java.awt.dnd.DragSourceDragEvent e)
dragOver in interface java.awt.dnd.DragSourceListenerpublic void dropActionChanged(java.awt.dnd.DragSourceDragEvent e)
dropActionChanged in interface java.awt.dnd.DragSourceListenerpublic void dragExit(java.awt.dnd.DragSourceEvent e)
dragExit in interface java.awt.dnd.DragSourceListenerpublic void dragDropEnd(java.awt.dnd.DragSourceDropEvent e)
dragDropEnd in interface java.awt.dnd.DragSourceListenerpublic int convertActionToModifiers(int action)
public void onDragEnter(java.awt.dnd.DropTargetDragEvent e)
public void onDragOver(java.awt.dnd.DropTargetDragEvent e)
public void onDropActionChanged(java.awt.dnd.DropTargetDragEvent e)
public void onDragExit(java.awt.dnd.DropTargetEvent e)
public void onDrop(java.awt.dnd.DropTargetDropEvent e)
public void dragEnter(java.awt.dnd.DropTargetDragEvent e)
dragEnter in interface java.awt.dnd.DropTargetListenerpublic void dragOver(java.awt.dnd.DropTargetDragEvent e)
dragOver in interface java.awt.dnd.DropTargetListenerpublic void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
dropActionChanged in interface java.awt.dnd.DropTargetListenerpublic void dragExit(java.awt.dnd.DropTargetEvent e)
dragExit in interface java.awt.dnd.DropTargetListenerpublic void drop(java.awt.dnd.DropTargetDropEvent e)
This method starts a transaction on this view's document. If the doDrop method returns true, it fires the JGoViewEvent.EXTERNAL_OBJECTS_DROPPED event and commits the transaction; if it returns false, it aborts the transaction.
drop in interface java.awt.dnd.DropTargetListenerpublic boolean isDropFlavorAcceptable(java.awt.dnd.DropTargetDragEvent e)
Override this method to control what kinds of sources could possibly be acceptable for a drop.
The default behavior is to see if the standard JGoDocument DataFlavor is supported.
public int computeAcceptableDrop(java.awt.dnd.DropTargetDragEvent e)
Override this method to look at the source, and possibly at the destination, to decide whether to allow COPY, MOVE, LINK, or some combination thereof or no drop at all.
The default behavior is allow only COPY or MOVE, and only if the document's default layer is modifiable.
public boolean doDrop(java.awt.dnd.DropTargetDropEvent e,
JGoCopyEnvironment copyenv)
The default behavior is to copy the Transferable's collection of JGoObjects into this document at the drop point.
This method should call acceptDrop on the DropTargetDropEvent, then JGoView.completeDrop on this view when the drop has finished, and finally return true.
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 void completeDrop(java.awt.dnd.DropTargetDropEvent e,
boolean success)
public java.awt.Insets getAutoscrollInsets()
getAutoscrollInsets in interface java.awt.dnd.Autoscrollpublic void setAutoscrollInsets(java.awt.Insets insets)
insets - the margins in which autoscrolling will occurpublic void autoscroll(java.awt.Point location)
autoscroll in interface java.awt.dnd.Autoscrolllocation - a point in the canvas, not in this view component,
(nor in the document).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 java.awt.Color getDefaultPrimarySelectionColor()
public static void setDefaultPrimarySelectionColor(java.awt.Color c)
public static java.awt.Color getDefaultSecondarySelectionColor()
public static void setDefaultSecondarySelectionColor(java.awt.Color 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(java.awt.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 java.awt.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 snapJGoObjectpublic 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 changed
protected void drawGridLines(java.awt.Graphics2D g,
java.awt.Rectangle clipRect)
g - the graphics context onto which to draw.clipRect - the bounds for where we need to draw, in document coordinates
protected void drawGridCrosses(java.awt.Graphics2D g,
int crossHeight,
int crossWidth,
java.awt.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 snap
public java.awt.Point findNearestGridPoint(int x,
int y,
java.awt.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 | |||||||||