| 
 | Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.DropSupport
public class DropSupport
A support class for Graph2DView that facilitates the drop part of drag and drop operations. This class has
 support for dropping NodeRealizer and EdgeRealizer instances onto a Graph2DView to
 create nodes or start edge creation. Also it allows to temporarily add a DropTargetListener to
 the view as a one-shot operation.
| Nested Class Summary | |
|---|---|
| static class | DropSupport.EdgeSplitSupportHandles edge splitting on node drops if edge splitting is enabled. | 
| static interface | DropSupport.EventHandlerHandles data flavor dependent access to drag and drop events for DropSupport's default node and edge transfers. | 
| Constructor Summary | |
|---|---|
| DropSupport()Creates a new instance of the class for no specific view. | |
| DropSupport(Graph2DView view)Creates a new instance of the class and creates supportfor
 droppingnode realizerandedge realizerinstances onto the view. | |
| Method Summary | |
|---|---|
| protected  DropSupport.EdgeSplitSupport | createEdgeSplitSupport()Creates an instance of EdgeSplitSupportto handle
 edge splitting on node drops ifedge splitting is enabled. | 
| protected  Node | createNode(Graph2DView view,
           NodeRealizer r,
           double worldCoordX,
           double worldCoordY)Callback that creates the node in response to dropNodeRealizer(Graph2DView, NodeRealizer, double,
 double). | 
|  void | createRealizerDropSupport(Graph2DView view)Registers support for dropping node realizerandedge realizerinstances onto the provided
 view. | 
|  void | createSupport(Graph2DView view)Creates a support class for the provided Graph2DViewthat will enable the provided view to react tostarted drag operations. | 
|  java.awt.datatransfer.Transferable | createTransferable(EdgeRealizer er)Creates a Transferablefor the givenEdgeRealizerthat is understood
 by this instance'ssupportfordropEdgeRealizer(Graph2DView, EdgeRealizer, double, double)dropping edges}. | 
|  java.awt.datatransfer.Transferable | createTransferable(NodeRealizer nr)Creates a Transferablefor the givenNodeRealizerthat is understood
 by this instance'ssupportfordropping nodes. | 
| protected  void | drawSourceNodeIndicator(java.awt.Graphics2D g,
                        NodeRealizer nodeRealizer)Paints the isIndicatingSourceNode()source node indicator}
 during edge drag operations. | 
| protected  boolean | dropEdgeRealizer(Graph2DView view,
                 EdgeRealizer realizer,
                 double worldCoordX,
                 double worldCoordY)Tries to start the edge creationusing theedit modein
 the provided view. | 
| protected  boolean | dropNodeRealizer(Graph2DView view,
                 NodeRealizer r,
                 double worldCoordX,
                 double worldCoordY)Callback method that creates the nodeafter a drop
 operation. | 
| protected  EditMode | findEditMode(Graph2DView view)Tries to find the EditModeinstance in the given view to start theedge creation. | 
|  DropSupport.EventHandler | getEdgeEventHandler()Returns the event handler for edge transfers. | 
|  DropSupport.EdgeSplitSupport | getEdgeSplitSupport()Specifies the support class that handles edge splitting on node drops if edge splitting is enabled. | 
|  DropSupport.EventHandler | getNodeEventHandler()Returns the event handler for node transfers. | 
|  MoveSnapContext | getSnapContext()Gets the MoveSnapContextthat is used by this instance ifsnapping is enabled. | 
| protected  java.awt.Rectangle | getSourceNodeIndicatorBounds(NodeRealizer nodeRealizer)Calculates the bounds of the isIndicatingSourceNode()source node indicator} during edge drag
 operations. | 
| protected  boolean | isEdgeCreationAllowed(EditMode editMode)Determines whether edge creation is allowed for the provided EditModeThis implementation uses theEditMode.doAllowEdgeCreation()property to determine the result. | 
|  boolean | isEdgeSplittingEnabled()Determines whether or not this drop support should split an edge when a dragged node is dropped onto it. | 
|  boolean | isIndicatingSourceNode()Determines whether or not possible source nodes are highlighted during edge drag operations. | 
|  boolean | isPreviewEnabled()Returns whether or not this support class should show a preview of the dragged node realizerduring the drag operation. | 
|  boolean | isSnappingEnabled()Returns whether or not this support class should use the snap contextto provide snap lines during the
 drag operation. | 
|  void | removeListener(Graph2DView view,
               java.awt.datatransfer.DataFlavor flavor)Removes a previously setlistener from the provided view. | 
|  void | removeRealizerDropSupport(Graph2DView view)Removes previously added support for dropping realizers from the given view. | 
|  void | removeSupport(Graph2DView view)Removes the previously createdsupport from the provided view. | 
| protected  void | requestFocus(Graph2DView view)Requests the input focus for the given view after a successful edge or node drop. | 
|  void | setEdgeEventHandler(DropSupport.EventHandler handler)Sets the event handler for edge transfers. | 
|  void | setEdgeSplitSupport(DropSupport.EdgeSplitSupport splitter)Specifies the support class that handles edge splitting on node drops if edge splitting is enabled. | 
|  void | setEdgeSplittingEnabled(boolean enabled)Specifies whether or not this drop support should split an edge when a dragged node is dropped onto it. | 
|  void | setIndicatingSourceNode(boolean enabled)Specifies whether or not possible source nodes are highlighted during edge drag operations. | 
|  void | setListener(Graph2DView view,
            java.awt.datatransfer.DataFlavor flavor,
            java.awt.dnd.DropTargetListener listener)Sets a specific DropTargetListenerthat will be used in theGraph2DViewif the givenDataFlavoris being dragged into the view. | 
|  void | setNodeEventHandler(DropSupport.EventHandler handler)Sets the event handler for node transfers. | 
| protected  void | setParent(Node child,
          Node parent)Assigns the specified child node to the specified parent node. | 
|  void | setPreviewEnabled(boolean enabled)Specifies whether or not this support class should show a preview of the dragged node realizerduring the drag operation. | 
|  void | setSnapContext(MoveSnapContext snapContext)Sets the new MoveSnapContextthat is used by this instance ifsnapping is enabled. | 
|  void | setSnappingEnabled(boolean enabled)Specifies whether or not this support class should use the snap contextto provide snap lines during the
 drag operation. | 
|  void | startDrag(java.awt.dnd.DragSource source,
          java.awt.dnd.DropTargetListener listener,
          java.awt.dnd.DragGestureEvent trigger,
          java.awt.Cursor dragCursor)One shot drag and drop operation that will be available on the registered Graph2DViews. | 
|  void | startDrag(java.awt.dnd.DragSource source,
          EdgeRealizer er,
          java.awt.dnd.DragGestureEvent trigger,
          java.awt.Cursor dragCursor)Initiates dragging an EdgeRealizeron a givenDragSourcethat can be handled byregisteredGraph2DViews. | 
|  void | startDrag(java.awt.dnd.DragSource source,
          NodeRealizer nr,
          java.awt.dnd.DragGestureEvent trigger,
          java.awt.Cursor dragCursor)Initiates dragging a NodeRealizeron a givenDragSourcethat can be handled byregisteredGraph2DViews. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public DropSupport()
public DropSupport(Graph2DView view)
creates support for
 dropping node realizer and edge realizer instances onto the view.
view - The view to enable realizer drop support onto.| Method Detail | 
|---|
protected DropSupport.EdgeSplitSupport createEdgeSplitSupport()
EdgeSplitSupport to handle
 edge splitting on node drops if
 edge splitting is enabled.
 Client code may overwrite this method to create a customized version
 of EdgeSplitSupport.
EdgeSplitSupport instance.public DropSupport.EdgeSplitSupport getEdgeSplitSupport()
edge splitting is enabled.
setEdgeSplitSupport(y.view.DropSupport.EdgeSplitSupport), 
createEdgeSplitSupport()public void setEdgeSplitSupport(DropSupport.EdgeSplitSupport splitter)
edge splitting is enabled.
splitter - the the support class to handles edge splitting on node
 drops.getEdgeSplitSupport(), 
createEdgeSplitSupport()
public void startDrag(java.awt.dnd.DragSource source,
                      java.awt.dnd.DropTargetListener listener,
                      java.awt.dnd.DragGestureEvent trigger,
                      java.awt.Cursor dragCursor)
Graph2DViews. This method will actually
 start a drag
 on the source and will use the specified listener
 to handle drop operations on registered
 Graph2DViews.
source - The source that actually started the drag.listener - The listener that will be used as a callback. Note that the
 carried data is for internal use, only. The listener needs to know the data
 of the drag and drop operation.trigger - The trigger to pass on to
 DragSource.startDrag().dragCursor - The cursor to pass on to
 DragSource.startDrag().
public void startDrag(java.awt.dnd.DragSource source,
                      NodeRealizer nr,
                      java.awt.dnd.DragGestureEvent trigger,
                      java.awt.Cursor dragCursor)
NodeRealizer on a given DragSource
 that can be handled by registered
 Graph2DViews.
source - The source that actually started the drag.nr - The NodeRealizer to display during the drag and to drop into the view in
 dropNodeRealizer().trigger - The trigger to pass on to
 DragSource.startDrag().dragCursor - The cursor to pass on to
 DragSource.startDrag()
public void startDrag(java.awt.dnd.DragSource source,
                      EdgeRealizer er,
                      java.awt.dnd.DragGestureEvent trigger,
                      java.awt.Cursor dragCursor)
EdgeRealizer on a given DragSource
 that can be handled by registered
 Graph2DViews.
source - The source that actually started the drag.er - The realizer to drop into the view in
 dropEdgeRealizer().trigger - The trigger to pass on to
 DragSource.startDrag().dragCursor - The cursor to pass on to
 DragSource.startDrag().public boolean isSnappingEnabled()
snap context to provide snap lines during the
 drag operation.
 
 The default is false.
 
true if snap lines are provided during the drag
 operation; false otherwise.setSnappingEnabled(boolean)public void setSnappingEnabled(boolean enabled)
snap context to provide snap lines during the
 drag operation.
 
 The default is false.
 
enabled - if true snap line are provided during the drag
 operation.isSnappingEnabled()public boolean isPreviewEnabled()
dragged node realizer
 during the drag operation.
 
 The default is true.
 
true if a node preview is shown during the drag
 operation; false otherwise.setPreviewEnabled(boolean)public void setPreviewEnabled(boolean enabled)
dragged node realizer
 during the drag operation.
 
 The default is true.
 
enabled - if true a node preview is shown during the drag
 operation.isPreviewEnabled()public boolean isIndicatingSourceNode()
 Defaults to false.
 
true if source nodes are highlighted;
 false otherwise.setIndicatingSourceNode(boolean), 
drawSourceNodeIndicator(java.awt.Graphics2D, NodeRealizer), 
getSourceNodeIndicatorBounds(NodeRealizer)public void setIndicatingSourceNode(boolean enabled)
 Defaults to false.
 
enabled - if true possible source nodes are highlighted
 during edge drag operations.isIndicatingSourceNode(), 
drawSourceNodeIndicator(java.awt.Graphics2D, NodeRealizer), 
getSourceNodeIndicatorBounds(NodeRealizer)public MoveSnapContext getSnapContext()
MoveSnapContext that is used by this instance if
 snapping is enabled.
MoveSnapContext instance used to provide snap lines.setSnapContext(MoveSnapContext)public void setSnapContext(MoveSnapContext snapContext)
MoveSnapContext that is used by this instance if
 snapping is enabled.
snapContext - the MoveSnapContext instance to
 provide snap lines.getSnapContext()public void createSupport(Graph2DView view)
Graph2DView that will enable the provided view to react to
 started drag operations.
view - The view to register the specialized DropTarget with.removeSupport(Graph2DView), 
createRealizerDropSupport(Graph2DView)public void removeSupport(Graph2DView view)
previously created support from the provided view.
view - The view to remove the drop support from.createSupport(Graph2DView)public void createRealizerDropSupport(Graph2DView view)
node realizer
 and edge realizer instances onto the provided
 view. This will automatically create support for drop operations on the view if
 this has not been done, already.
view - The to add support to.removeRealizerDropSupport(Graph2DView)public void removeRealizerDropSupport(Graph2DView view)
view - The view to remove the support from.createRealizerDropSupport(Graph2DView)
public void setListener(Graph2DView view,
                        java.awt.datatransfer.DataFlavor flavor,
                        java.awt.dnd.DropTargetListener listener)
DropTargetListener that will be used in the Graph2DView if the given
 DataFlavor is being dragged into the view. This allows for registering different DropTargetListener instances to which the event will be multiplexed, depending on the DataFlavor.
view - The view to add a listener to.flavor - The flavor for which the listener will be registered.listener - The listener to delegate to or null in order to remove a previously registered
                 listener.removeListener(Graph2DView, java.awt.datatransfer.DataFlavor)
public void removeListener(Graph2DView view,
                           java.awt.datatransfer.DataFlavor flavor)
set listener from the provided view.
view - The view to remove the listener from.flavor - The flavor for which the listener had been registered.public DropSupport.EventHandler getNodeEventHandler()
setNodeEventHandler(y.view.DropSupport.EventHandler)public void setNodeEventHandler(DropSupport.EventHandler handler)
A custom event handler may be used if the built-in support for node transfers has to be used with custom data flavors. E.g. for inter-process drag and drop support, the internal data flavor for node transfers cannot be used and a custom data flavor is necessary to access transfer data.
 The specified handler's getTransferData methods have to return
 NodeRealizer instances. Otherwise, a
 ClassCastException will be thrown during drag and drop
 operations.
 
handler - the event handler for node transfers.
java.lang.IllegalArgumentException - if the specified handler is
 null.public DropSupport.EventHandler getEdgeEventHandler()
setEdgeEventHandler(y.view.DropSupport.EventHandler)public void setEdgeEventHandler(DropSupport.EventHandler handler)
A custom event handler may be used if the built-in support for edge transfers has to be used with custom data flavors. E.g. for inter-process drag and drop support, the internal data flavor for edge transfers cannot be used and a custom data flavor is necessary to access transfer data.
 The specified handler's getTransferData methods have to return
 EdgeRealizer instances. Otherwise, a
 ClassCastException will be thrown during drag and drop
 operations.
 
handler - the event handler for edge transfers.
java.lang.IllegalArgumentException - if the specified handler is
 null.protected void requestFocus(Graph2DView view)
view - the view that should receive the input focus.dropEdgeRealizer(Graph2DView, EdgeRealizer, double, double), 
dropNodeRealizer(Graph2DView, NodeRealizer, double, double)protected java.awt.Rectangle getSourceNodeIndicatorBounds(NodeRealizer nodeRealizer)
isIndicatingSourceNode() source node indicator} during edge drag
 operations.
 Client code that overrides
 drawSourceNodeIndicator(java.awt.Graphics2D, NodeRealizer) should
 also override this method accordingly.
nodeRealizer - The realizer to highlight.
protected void drawSourceNodeIndicator(java.awt.Graphics2D g,
                                       NodeRealizer nodeRealizer)
isIndicatingSourceNode() source node indicator}
 during edge drag operations.
 Client code that overrides this method to draw a custom indicator should
 also override getSourceNodeIndicatorBounds(NodeRealizer)
 accordingly.
g - the graphics context to paint upon.nodeRealizer - the realizer to highlight.protected EditMode findEditMode(Graph2DView view)
EditMode instance in the given view to start the edge creation.
view - The view to search.
EditMode instance or null.
protected boolean dropNodeRealizer(Graph2DView view,
                                   NodeRealizer r,
                                   double worldCoordX,
                                   double worldCoordY)
creates the node after a drop
 operation.
view - The view to create the node inr - The realizer to useworldCoordX - The center world coordinates.worldCoordY - The center world coordinates.
protected Node createNode(Graph2DView view,
                          NodeRealizer r,
                          double worldCoordX,
                          double worldCoordY)
dropNodeRealizer(Graph2DView, NodeRealizer, double,
 double).
view - The view to create the node in.r - The realizer to create.worldCoordX - The center world coordinates.worldCoordY - The center world coordinates.
null.public boolean isEdgeSplittingEnabled()
 Defaults to false.
 
true if this drop support should split an edge when a
 dragged node is dropped onto it; false otherwise.setEdgeSplittingEnabled(boolean), 
EdgeSplitSupportImpl.getSplitEdge(Graph2DView, YPoint), 
EdgeSplitSupportImpl.splitEdge(Graph2D, y.base.Edge, YPoint, y.base.Node), 
EdgeSplitSupportImpl.setIndicatingSplitEdge(boolean)public void setEdgeSplittingEnabled(boolean enabled)
 Defaults to false.
 
enabled - if true an edge is split when a dragged node
 is dropped onto it.isEdgeSplittingEnabled(), 
EdgeSplitSupportImpl.getSplitEdge(Graph2DView, YPoint), 
EdgeSplitSupportImpl.splitEdge(Graph2D, y.base.Edge, YPoint, y.base.Node), 
EdgeSplitSupportImpl.setIndicatingSplitEdge(boolean)
protected void setParent(Node child,
                         Node parent)
child - the node that is assigned to a new group node.parent - the container group node.
protected boolean dropEdgeRealizer(Graph2DView view,
                                   EdgeRealizer realizer,
                                   double worldCoordX,
                                   double worldCoordY)
edge creation using the edit mode in
 the provided view.
view - The view to start the creation in.realizer - The realizer to use as a template.worldCoordX - The location of the mouse during the drop operation.worldCoordY - The location of the mouse during the drop operation.
protected boolean isEdgeCreationAllowed(EditMode editMode)
EditMode This implementation uses the
 EditMode.doAllowEdgeCreation() property to determine the result.
editMode - The mode to inspect
public java.awt.datatransfer.Transferable createTransferable(NodeRealizer nr)
Transferable for the given NodeRealizer that is understood
 by this instance's support for dropping nodes.
nr - The realizer to drag.
public java.awt.datatransfer.Transferable createTransferable(EdgeRealizer er)
Transferable for the given EdgeRealizer that is understood
 by this instance's support for dropEdgeRealizer(Graph2DView, EdgeRealizer, double, double)  dropping edges}.
er - The realizer to use for the edge creation.
| 
 | © Copyright 2000-2025, yWorks GmbH. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||