本文整理汇总了Java中java.awt.dnd.DropTargetDropEvent.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java DropTargetDropEvent.getLocation方法的具体用法?Java DropTargetDropEvent.getLocation怎么用?Java DropTargetDropEvent.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.dnd.DropTargetDropEvent
的用法示例。
在下文中一共展示了DropTargetDropEvent.getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
if (dtde.getDropTargetContext().getComponent() == theMap) {
final MouseEvent evt = new MouseEvent(
theMap,
MouseEvent.MOUSE_RELEASED,
System.currentTimeMillis(),
0,
dtde.getLocation().x,
dtde.getLocation().y,
1,
false
);
theMap.dispatchEvent(evt);
dtde.dropComplete(true);
}
if (scroller.isRunning()) scroller.stop();
}
示例2: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent e)
{
if (dragSource != null)
{
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Point p = e.getLocation();
int targetRow = rowAtPoint(p);
Object edge = graph.insertEdge(null, null, null,
dragSource.cell, JTableRenderer.this.cell, "sourceRow="
+ sourceRow + ";targetRow=" + targetRow);
graph.setSelectionCell(edge);
// System.out.println("clearing drag source");
dragSource = null;
e.dropComplete(true);
}
else
{
e.rejectDrop();
}
}
示例3: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent e) {
if (dragSource != null) {
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Point p = e.getLocation();
int targetRow = rowAtPoint(p);
Object edge = graph.insertEdge(null, null, null, dragSource.cell, JTableRenderer.this.cell,
"sourceRow=" + sourceRow + ";targetRow=" + targetRow);
graph.setSelectionCell(edge);
// System.out.println("clearing drag source");
dragSource = null;
e.dropComplete(true);
} else {
e.rejectDrop();
}
}
示例4: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent e)
{
if (dragSource != null)
{
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Point p = e.getLocation();
int targetRow = rowAtPoint(p);
Object edge = graph.insertEdge(null, null, null,
dragSource.cell, JTableRenderer.this.cell, "sourceRow="
+ sourceRow + ";targetRow=" + targetRow, null);
graph.setSelectionCell(edge);
// System.out.println("clearing drag source");
dragSource = null;
e.dropComplete(true);
}
else
{
e.rejectDrop();
}
}
示例5: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(@Nonnull final DropTargetDropEvent dtde) {
if (this.dragAcceptableType) {
final Point dragPoint = dtde.getLocation();
final TreePath path = getPathForLocation(dragPoint.x, dragPoint.y);
if (path != null) {
final Object dropTargetNode = path.getLastPathComponent();
if (dropTargetNode instanceof NodeFileOrFolder) {
final NodeFileOrFolder node = (NodeFileOrFolder) dropTargetNode;
if (!node.isLeaf()) {
//TODO processing of file drag in tree
System.out.println("Not implemented yet!"); //NOI18N
} else {
dtde.rejectDrop();
}
}
}
repaint();
}
}
示例6: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
//System.out.println("drop(DropTargetDragEvent)");
if (dtde.getSource() != dropTarget) {
dtde.rejectDrop();
panel.setDropLocation(-1, null);
return;
}
Point dropPoint = dtde.getLocation();
int index = list.locationToIndex(dropPoint);
boolean dropped = false;
if (index == -1 || index == draggedIndex) {
//System.out.println("dropped onto self");
dtde.rejectDrop();
panel.setDropLocation(-1, null);
return;
}
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
//System.out.println("accepted: " + draggedIndex + "/" + index);
panel.setDropLocation(-1, null);
panel.moveStep(draggedIndex, index);
dropped = true;
dtde.dropComplete(dropped);
}
示例7: WidgetDropTargetDropEvent
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
* Creates a drop target drop event.
* @param id the event id
* @param event the Swing event
*/
public WidgetDropTargetDropEvent (long id, DropTargetDropEvent event) {
this.id = id;
this.event = event;
Point location = event.getLocation ();
x = location.x;
y = location.y;
}
示例8: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent event) {
removeDragCursor();
Point pos = event.getLocation();
pos.translate(currentPieceOffsetX, currentPieceOffsetY);
myStack.pos.x = pos.x;
myStack.pos.y = pos.y;
myStack.stackConfigurer.updateDisplay();
repaint();
return;
}
示例9: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent event) {
removeDragCursor();
final Point dragEnd = event.getLocation();
int x = dragEnd.x - dragStart.x;
int y = dragEnd.y - dragStart.y;
for (Region r : config.selectedRegions) {
r.move(x, y, this);
config.setDirty(true);
}
repaint();
}
示例10: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public final void drop(DropTargetDropEvent dtde) {
try {
if (drawImage) {
clearImage();
}
int action = dtde.getDropAction();
Transferable transferable = dtde.getTransferable();
Point pt = dtde.getLocation();
if (transferable.isDataFlavorSupported(NODE_FLAVOR)
&& controller.canPerformAction(tree, draggedNode, action, pt)) {
TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
Object node = transferable.getTransferData(NODE_FLAVOR);
Object newParentNode = pathTarget.getLastPathComponent();
if (controller.executeDrop(tree, node, newParentNode, action)) {
dtde.acceptDrop(action);
dtde.dropComplete(true);
return;
}
}
dtde.rejectDrop();
dtde.dropComplete(false);
} catch (Exception e) {
dtde.rejectDrop();
dtde.dropComplete(false);
}
}
示例11: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
if(draggingComponent==null) {
dtde.rejectDrop();
} else {
if(draggingDefaults) {
setContents(getDefaultContents());
} else {
Point p = dtde.getLocation();
p = SwingUtilities.convertPoint(
((DropTarget)dtde.getSource()).getComponent(),
p,
CustomizedToolbar.this );
String[] contents = getContents(p);
setContents(contents);
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
JComponent theComponent = getComponent(draggingComponent);
Rectangle r = (Rectangle)theComponent.getClientProperty(AnimatedLayout.DESTINATION);
if(r!=null) {
theComponent.setBounds( r );
}
if(hideActiveComponents)
theComponent.setVisible(true);
}
}
dtde.dropComplete(true);
}
示例12: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
Point p = dtde.getLocation();
DropTargetContext dtc = dtde.getDropTargetContext();
JTree tree = (JTree) dtc.getComponent();
// Sets the original glass pane
setOriginalGlassPane(tree);
// Cancel tree item expanding
dragOverTreePath = null;
// Get the parent and sibling paths and nodes
TreePath currentPath = tree.getPathForLocation(p.x, p.y);
DefaultMutableTreeNode parent =
(DefaultMutableTreeNode) getNodeForPath
(getParentPathForPosition(currentPath));
Node dropTargetNode = getDomNodeFromTreeNode(parent);
DefaultMutableTreeNode sibling =
(DefaultMutableTreeNode)
getNodeForPath(getSiblingPathForPosition(currentPath));
Node siblingNode = getDomNodeFromTreeNode(sibling);
if (this.transferData != null) {
ArrayList nodelist =
getNodeListForParent(this.transferData.getNodeList(),
dropTargetNode);
fireDropCompleted
(new DOMDocumentTreeEvent
(new DropCompletedInfo
(dropTargetNode, siblingNode, nodelist)));
dtde.dropComplete(true);
return;
}
dtde.rejectDrop();
}
示例13: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public synchronized void drop(DropTargetDropEvent dtde) {
try {
TreeNode sourceNode = (TreeNode) dtde.getTransferable().getTransferData(
NodeTransferWrapper.ATLAS_OBJECT_FLAVOR);
Point pt = dtde.getLocation();
DropTargetContext dtc = dtde.getDropTargetContext();
JTree tree = (JTree) dtc.getComponent();
TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
TreeNode targetNode = (TreeNode) parentpath.getLastPathComponent();
if (targetNode.equals(sourceNode) || targetNode.getParent().equals(sourceNode)) {
dtde.rejectDrop();
return;
}
AtlasTreeModel atlasTreeModel = (AtlasTreeModel) atlasTree.getModel();
if (sourceNode instanceof LayerInterface && targetNode instanceof LayerInterface)
mergeLayers(atlasTreeModel, (LayerInterface) sourceNode,
(LayerInterface) targetNode);
if (targetNode instanceof MapInterface)
// We can not make a map child of another map
// -> use it's layer instead
targetNode = targetNode.getParent();
if (sourceNode instanceof MapInterface && targetNode instanceof LayerInterface)
moveMap(atlasTreeModel, (MapInterface) sourceNode, (LayerInterface) targetNode);
} catch (Exception e) {
log.error("", e);
atlasTree.getTreeModel().notifyStructureChanged();
dtde.rejectDrop();
}
}
示例14: dropObjectFromModelBrowser
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
*
* Accepts a drag of a class from the ModelBrowser. A new object of this
* class will be created.
* @param dtde
*/
public void dropObjectFromModelBrowser( DropTargetDropEvent dtde ) {
try {
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
Transferable transferable = dtde.getTransferable();
// we accept only Strings
if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String s = (String) transferable
.getTransferData(DataFlavor.stringFlavor);
if (s.startsWith("CLASS-")) {
Point p = dtde.getLocation();
if ( isDoAutoLayout() ) {
getRandomNextPosition();
} else {
nextNodePosition.x = p.getX();
nextNodePosition.y = p.getY();
}
String clsName = s.substring(6);
fParent.createObject(clsName);
}
}
dtde.dropComplete(true);
} catch (IOException exception) {
exception.printStackTrace();
System.err.println("Exception" + exception.getMessage());
dtde.dropComplete(false);
} catch (UnsupportedFlavorException ufException) {
ufException.printStackTrace();
System.err.println("Exception" + ufException.getMessage());
dtde.dropComplete(false);
}
}
示例15: extractDropLocation
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
private void extractDropLocation(DropTargetDropEvent dtde) {
if (dtde == null) {
System.out.println("ERROR> BDnDC::getTransferData(): dropEvent is null");
return;
}
dropLocation = dtde.getLocation();
}