Package org.apache.batik.apps.svgbrowser
Class DOMDocumentTree.TreeDropTargetListener
- java.lang.Object
-
- org.apache.batik.apps.svgbrowser.DOMDocumentTree.TreeDropTargetListener
-
- All Implemented Interfaces:
java.awt.dnd.DropTargetListener,java.util.EventListener
- Enclosing class:
- DOMDocumentTree
public class DOMDocumentTree.TreeDropTargetListener extends java.lang.Object implements java.awt.dnd.DropTargetListenerTree as a drop target listener.
-
-
Field Summary
Fields Modifier and Type Field Description private static intAFTERInsert node after the current node.private static intBEFOREInsert node before the current node.private static intCURRENTInsert node as a child of the current node.private javax.swing.tree.TreePathdragOverTreePathThe tree path that is being dragged over.private java.awt.PointendPointThe end point of the 'visual tip' line.private javax.swing.TimerexpandControlTimerThe timer that controls the delay of expanding the tree path that is being dragged over.private intexpandTimeoutThe delay for expanding.private java.awt.ComponentoriginalGlassPaneThe original glass pane of the tree is stored here.private intpositionIndicatorIndicates the potential drop position relative to the current node where the dragged nodes are to be inserted.private java.awt.PointstartPointThe start point of the 'visual tip' line.private DOMDocumentTree.TransferDatatransferDataThe associated transfer data.private javax.swing.tree.TreePathtreePathToExpandThe tree path that is scheduled for expand.protected javax.swing.JPanelvisualTipGlassPaneGlasspane where 'visual tip' line is drawnprivate intvisualTipOffsetThe vertical offset where to catch the 'visual tips' of the tree node items rectangle.private intvisualTipThicknessThe thickness of the visual tip.
-
Constructor Summary
Constructors Constructor Description TreeDropTargetListener(DOMDocumentTree tree)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddOnAutoscrollListener(DOMDocumentTree tree)Adds the onAutoscroll listener.voiddragEnter(java.awt.dnd.DropTargetDragEvent dtde)voiddragExit(java.awt.dnd.DropTargetEvent dte)voiddragOver(java.awt.dnd.DropTargetDragEvent dtde)voiddrop(java.awt.dnd.DropTargetDropEvent dtde)voiddropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)private javax.swing.TimergetExpandTreeTimer(javax.swing.JTree tree)Gets the timer for treepath expand.private javax.swing.tree.TreeNodegetNode(java.awt.dnd.DropTargetDragEvent dtde)Gets the TreeNode from the DropTargetDragEventprivate javax.swing.tree.TreeNodegetNodeForPath(javax.swing.tree.TreePath path)Gets the TreeNode from the given TreePath.private javax.swing.tree.TreePathgetParentPathForPosition(javax.swing.tree.TreePath currentPath)Finds the parent TreePath of the given current path, according to the position indicator, where the dragged nodes should be appended.private javax.swing.tree.TreePathgetSiblingPathForPosition(javax.swing.tree.TreePath currentPath)Finds the TreePath that is going to be next sibling to the nodes that are being dragged.private voidscheduleExpand(javax.swing.tree.TreePath treePath, javax.swing.JTree tree)Schedules the expand of the given treePath on a tree.private voidsetOriginalGlassPane(javax.swing.JTree tree)Sets the original glass pane.private voidupdatePositionIndicator(java.awt.dnd.DropTargetDragEvent dtde)Sets the position indicator according to the current cursor location.private voidupdateVisualTipLine(javax.swing.JTree tree, javax.swing.tree.TreePath path)Draws the 'visual tip' line on the glass pane.
-
-
-
Field Detail
-
BEFORE
private static final int BEFORE
Insert node before the current node.- See Also:
- Constant Field Values
-
AFTER
private static final int AFTER
Insert node after the current node.- See Also:
- Constant Field Values
-
CURRENT
private static final int CURRENT
Insert node as a child of the current node.- See Also:
- Constant Field Values
-
transferData
private DOMDocumentTree.TransferData transferData
The associated transfer data.
-
originalGlassPane
private java.awt.Component originalGlassPane
The original glass pane of the tree is stored here.
-
visualTipOffset
private int visualTipOffset
The vertical offset where to catch the 'visual tips' of the tree node items rectangle.
-
visualTipThickness
private int visualTipThickness
The thickness of the visual tip.
-
positionIndicator
private int positionIndicator
Indicates the potential drop position relative to the current node where the dragged nodes are to be inserted.
-
startPoint
private java.awt.Point startPoint
The start point of the 'visual tip' line.
-
endPoint
private java.awt.Point endPoint
The end point of the 'visual tip' line.
-
visualTipGlassPane
protected javax.swing.JPanel visualTipGlassPane
Glasspane where 'visual tip' line is drawn
-
expandControlTimer
private javax.swing.Timer expandControlTimer
The timer that controls the delay of expanding the tree path that is being dragged over.
-
expandTimeout
private int expandTimeout
The delay for expanding.
-
dragOverTreePath
private javax.swing.tree.TreePath dragOverTreePath
The tree path that is being dragged over.
-
treePathToExpand
private javax.swing.tree.TreePath treePathToExpand
The tree path that is scheduled for expand.
-
-
Constructor Detail
-
TreeDropTargetListener
public TreeDropTargetListener(DOMDocumentTree tree)
Constructor.
-
-
Method Detail
-
dragEnter
public void dragEnter(java.awt.dnd.DropTargetDragEvent dtde)
- Specified by:
dragEnterin interfacejava.awt.dnd.DropTargetListener
-
dragOver
public void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
- Specified by:
dragOverin interfacejava.awt.dnd.DropTargetListener
-
dropActionChanged
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)
- Specified by:
dropActionChangedin interfacejava.awt.dnd.DropTargetListener
-
drop
public void drop(java.awt.dnd.DropTargetDropEvent dtde)
- Specified by:
dropin interfacejava.awt.dnd.DropTargetListener
-
dragExit
public void dragExit(java.awt.dnd.DropTargetEvent dte)
- Specified by:
dragExitin interfacejava.awt.dnd.DropTargetListener
-
updatePositionIndicator
private void updatePositionIndicator(java.awt.dnd.DropTargetDragEvent dtde)
Sets the position indicator according to the current cursor location.- Parameters:
dtde- DropTargetDragEvent
-
getParentPathForPosition
private javax.swing.tree.TreePath getParentPathForPosition(javax.swing.tree.TreePath currentPath)
Finds the parent TreePath of the given current path, according to the position indicator, where the dragged nodes should be appended.- Parameters:
currentPath- The current path (the items are dragged over this path)positionIndicator- AFTER or BEFORE - nodes should be appended to the parent path of the given path, as siblings of the current path CURRENT - nodes should be appended to the current path, as its children- Returns:
- TreePath where dragged nodes are to be inserted
-
getSiblingPathForPosition
private javax.swing.tree.TreePath getSiblingPathForPosition(javax.swing.tree.TreePath currentPath)
Finds the TreePath that is going to be next sibling to the nodes that are being dragged.- Parameters:
currentPath- The current path (the items are dragged over this path)- Returns:
- sibling TreePath
-
getNodeForPath
private javax.swing.tree.TreeNode getNodeForPath(javax.swing.tree.TreePath path)
Gets the TreeNode from the given TreePath.- Parameters:
path- The given TreePath- Returns:
- The TreeNode
-
getNode
private javax.swing.tree.TreeNode getNode(java.awt.dnd.DropTargetDragEvent dtde)
Gets the TreeNode from the DropTargetDragEvent- Parameters:
dtde- The DropTargetDragEvent- Returns:
- Associated TreeNode or null
-
updateVisualTipLine
private void updateVisualTipLine(javax.swing.JTree tree, javax.swing.tree.TreePath path)Draws the 'visual tip' line on the glass pane.- Parameters:
tree- The treepath- The path to get the bounds
-
addOnAutoscrollListener
private void addOnAutoscrollListener(DOMDocumentTree tree)
Adds the onAutoscroll listener.- Parameters:
tree- The DOMDocumentTree
-
setOriginalGlassPane
private void setOriginalGlassPane(javax.swing.JTree tree)
Sets the original glass pane.- Parameters:
dte- DropTargetEvent to get the tree
-
scheduleExpand
private void scheduleExpand(javax.swing.tree.TreePath treePath, javax.swing.JTree tree)Schedules the expand of the given treePath on a tree.- Parameters:
treePath- The treePath to expandtree- The JTree
-
getExpandTreeTimer
private javax.swing.Timer getExpandTreeTimer(javax.swing.JTree tree)
Gets the timer for treepath expand.- Parameters:
tree- The JTree- Returns:
- Timer
-
-