本文整理汇总了Java中java.awt.dnd.DragGestureEvent.getDragOrigin方法的典型用法代码示例。如果您正苦于以下问题:Java DragGestureEvent.getDragOrigin方法的具体用法?Java DragGestureEvent.getDragOrigin怎么用?Java DragGestureEvent.getDragOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.dnd.DragGestureEvent
的用法示例。
在下文中一共展示了DragGestureEvent.getDragOrigin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void start(final DragGestureEvent e) {
originalLocationOnScreen = source.getComponent().getLocationOnScreen();
final Rectangle tabRect = source.getTabBounds(tabIndex);
if( prefs.getBoolean(WinSysPrefs.DND_SMALLWINDOWS, true) ) {
originalLocationOnScreen.x += tabRect.x;
}
DragWindow tmp = createDragWindow( tabIndex );
if( null != tmp ) {
dragOffset = new Point( 0, 0 );
Point loc = new Point( e.getDragOrigin() );
SwingUtilities.convertPointToScreen(loc, e.getComponent());
tmp.setLocation( loc.x-dragOffset.x, loc.y-dragOffset.y );
//let the JNA transparency stuff to kick in
try {
tmp.setVisible( true );
//make drag window visible, i.e. move to proper location,
//dragImage.setLocation( startingPoint );
dragWindow = tmp;
} catch( UnsatisfiedLinkError ulE ) {
Logger.getLogger(DragAndDropFeedbackVisualizer.class.getName()).log(Level.INFO, null, ulE);
} catch( Throwable ex ) {
Logger.getLogger(DragAndDropFeedbackVisualizer.class.getName()).log(Level.FINE, null, ex);
}
}
}
示例2: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
Point p = dge.getDragOrigin();
Component c = dge.getComponent();
JFrame f = (JFrame)SwingUtilities.getWindowAncestor(c);
p = SwingUtilities.convertPoint(c, p, f);
for(int a = 0; a<componentList.length; a++) {
if(triggerDrag(f,p,dge,componentList[a]))
return;
}
//double-check for separators & gaps:
for(int a = 0; a<getComponentCount(); a++) {
if(triggerDrag(f,p,dge,(JComponent)getComponent(a)))
return;
}
}
示例3: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
Point p = dge.getDragOrigin();
MockComponent mc = (MockComponent)dge.getComponent();
Transferable transferable = new MockComponentTransferable(mc);
BufferedImage bi = mc.getBufferedImage();
if(mc instanceof MockDefaultToolbar) {
toolbar.draggingComponent = "";
} else if(mc.getName().equals("-")) {
toolbar.draggingComponent = toolbar.getNewSeparatorName();
} else if(mc.getName().equals(" ")) {
toolbar.draggingComponent = toolbar.getNewSpaceName();
} else if(mc.getName().equals("\t")) {
toolbar.draggingComponent = toolbar.getNewFlexibleSpaceName();
} else {
toolbar.draggingComponent = mc.getName();
}
toolbar.draggingDefaults = (mc instanceof MockDefaultToolbar);
toolbar.draggingFromToolbar = false;
dge.startDrag(DragSource.DefaultMoveDrop,
bi,
new Point(-p.x, -p.y),
transferable,
dragSourceListener);
}
示例4: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
if (dge.getDragAction() == DnDConstants.ACTION_COPY) {
Point p = dge.getDragOrigin();
for (int i = 0; i < constraints.size(); i++) {
Component cmp = operationPanel.getComponent(i);
if (cmp.getBounds().contains(p)) {
rootFrame.glassPane.setImage(PivotSlice.getScreenShot(cmp));
dge.startDrag(DragSource.DefaultCopyDrop, new Constraint.TransferableConstraint(constraints.get(i)));
rootFrame.logger.logAction("historypanel-drag attribute");
break;
}
}
}
}
示例5: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent event) {
// ignore right-click-drags
if (((MouseEvent) event.getTriggerEvent()).isPopupTrigger())
return;
// figure out what's being dragged
Point p = event.getDragOrigin();
BaseSample bar = bgp.getBar(p);
// this only makes sense with Files...
if(bar.getLoader() instanceof FileElement) {
// make a Transferable to send
Transferable transfer = new Tree.TransferableFile(
((FileElement)bar.getLoader()).getFilename());
// let the drag begin!
event.startDrag(DragSource.DefaultCopyDrop, transfer, this);
}
}
示例6: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
if (!tabbedPane.isEnabled()) {
return;
}
dragOrigin = dge.getDragOrigin();
Tab draggedTab = getDraggableTabAt(dragOrigin);
if (draggedTab != null) {
Window window = SwingUtilities.getWindowAncestor(tabbedPane);
Dimension sourceWindowSize = null;
if (window != null) {
sourceWindowSize = window.getSize();
}
Point p = SwingUtilities.convertPoint(tabbedPane, dragOrigin, draggedTab);
double grabX = p.x / (double) draggedTab.getWidth();
dragInfo = new TabDragInfo(draggedTab, dragOrigin, grabX, floatingTabHandler, sourceWindowSize);
source.startDrag(dge, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR), transferableStore.createTransferable(dragInfo), this);
}
}
示例7: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
Point mousePosition = dge.getDragOrigin();
Point piecePosition = new Point(myStack.pos);
// Check drag starts inside piece
Rectangle r = myStack.stackConfigurer.getPieceBoundingBox();
r.translate(piecePosition.x, piecePosition.y);
if (!r.contains(mousePosition)) {
return;
}
originalPieceOffsetX = piecePosition.x - mousePosition.x;
originalPieceOffsetY = piecePosition.y - mousePosition.y;
drawWin = null;
makeDragCursor();
setDragCursor();
SwingUtilities.convertPointToScreen(mousePosition, drawWin);
moveDragCursor(mousePosition.x, mousePosition.y);
// begin dragging
try {
dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
new StringSelection(""), this); // DEBUG
dge.getDragSource().addDragSourceMotionListener(this);
}
catch (InvalidDnDOperationException e) {
ErrorDialog.bug(e);
}
}
示例8: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
final Point mousePosition = dge.getDragOrigin();
dragStart = new Point(mousePosition);
final Region r = grid.getRegion(mousePosition);
if (r == null) {
return;
}
Point piecePosition = new Point(r.getOrigin());
originalPieceOffsetX = piecePosition.x - mousePosition.x;
originalPieceOffsetY = piecePosition.y - mousePosition.y;
drawWin = null;
makeDragCursor();
setDragCursor();
SwingUtilities.convertPointToScreen(drawOffset, drawWin);
SwingUtilities.convertPointToScreen(mousePosition, drawWin);
moveDragCursor(mousePosition.x, mousePosition.y);
// begin dragging
try {
dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
new StringSelection(""), this); //$NON-NLS-1$
dge.getDragSource().addDragSourceMotionListener(this);
}
catch (InvalidDnDOperationException e) {
ErrorDialog.bug(e);
}
}
示例9: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent event)
{
if (_holdDrag)
{
_holdDrag = false;
return;
}
Point point = event.getDragOrigin();
TreePath treePath = getPathForLocation(point.x, point.y);
if (treePath == null)
return;
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
Object userObject = treeNode.getUserObject();
StringSelection text = null;
SB_Canvas canvas = ComponentRegistry.getContent().getActiveCanvas();
canvas._allowDrop = true;
if (userObject instanceof SB_Variable)
{
text = new StringSelection("Local:" + ((UserObject) userObject).getName());
canvas._dropType = SB_Canvas.kDropLocal;
}
if (text != null)
{
_dragSource.startDrag(event, DragSource.DefaultCopyDrop, text, this);
setEditable(false);
}
}
示例10: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
TreePath selectedPath = getSelectionPath();
if (selectedPath == null) {
finishDnD();
return;
}
KatNode node = (KatNode) selectedPath.getLastPathComponent();
if (node == null || node instanceof ProjectNode || node instanceof DataFileNode) {
finishDnD();
return;
}
Point clickPoint = dge.getDragOrigin();
Rectangle pathBounds = getPathBounds(selectedPath);
Point clickOffset = new Point(clickPoint.x - pathBounds.x, clickPoint.y - pathBounds.y);
BufferedImage image = new BufferedImage(pathBounds.width, pathBounds.height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2d = image.createGraphics();
Component renderer = getCellRenderer().getTreeCellRendererComponent(this, node, true, false, node.isLeaf(), getRowForPath(selectedPath), false);
renderer.setSize(pathBounds.width, pathBounds.height);
renderer.paint(g2d);
g2d.dispose();
dragSource.startDrag(dge, DragSource.DefaultMoveDrop, image, clickOffset, node, this);
}
示例11: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
rootFrame.glassPane.setImage(PivotSlice.getScreenShot(this));
Point p = dge.getDragOrigin();
Constraint.ConstraintData cdata = parentConstr.getConstraintData();
if (dge.getDragAction() == DnDConstants.ACTION_COPY) {
if (attributeLabel == this)
dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(cdata.facetID,
cdata.valueIDs.get(showIndex)));
else if (fromLabel == this)
dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(cdata.facetID,
cdata.fromValue, cdata.fromValue));
else if (toLabel == this)
dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(cdata.facetID,
cdata.toValue, cdata.toValue));
}
else {
if (attributeLabel == this) {
dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(cdata.facetID,
cdata.valueIDs.get(showIndex)));
removePressed();
}
else if (cdata.fromValue != cdata.toValue) {
if (fromLabel == this) {
dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(cdata.facetID,
cdata.fromValue, cdata.fromValue));
nextPressed(this);
}
else if (toLabel == this) {
dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(cdata.facetID,
cdata.toValue, cdata.toValue));
prevPressed(this);
}
}
}
rootFrame.logger.logAction("filter-drag attribute");
}
示例12: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
// System.out.println("dragGestureRecognized");
Point pt = dge.getDragOrigin();
TreePath path = getPathForLocation(pt.x, pt.y);
if (path == null || path.getParentPath() == null) {
return;
}
// System.out.println("start "+path.toString());
draggedNode = (TreeNode) path.getLastPathComponent();
Transferable trans = new RJLTransferable(draggedNode);
new DragSource().startDrag(dge, Cursor.getDefaultCursor(), trans, this);
}
示例13: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
// Initialize the transferable with the default cell server state
// factory
Transferable t = new CellServerStateTransferable(cellFactory);
// Begin with the drag setting up the origin so that it aligns with
// the image.
Point dragOrigin = dge.getDragOrigin();
dragOrigin.setLocation(-dragOrigin.x, -dragOrigin.y);
dge.startDrag(DragSource.DefaultCopyNoDrop, previewImage, dragOrigin, t, null);
}
示例14: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized( DragGestureEvent dge )
{
// System.out.println( "dragGestureRecognized" );
// find object at this x,y
Point clickPoint = dge.getDragOrigin();
int index = locationToIndex( clickPoint );
if ( index == -1 )
return;
Object target = getModel().getElementAt( index );
Transferable trans = new RJLTransferable( target );
draggedIndex = index;
dragSource.startDrag( dge, Cursor.getDefaultCursor(), trans, this );
}
示例15: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent e) {
Component c = e.getComponent();
if( !(c instanceof JComponent) )
return;
Transferable t = null;
try {
final DataObject dob = (DataObject) ((JComponent) c).getClientProperty("file");
if( dob != null && c.getParent() instanceof Toolbar && buttonDndAllowed ) {
//dragging a toolbar button
sourceToolbar = (Toolbar) c.getParent();
t = new ExTransferable.Single(buttonDataFlavor) {
public Object getData() {
return dob;
}
};
isToolbarDrag = false;
isButtonDrag = true;
dragSourceButtonIndex = sourceToolbar.getComponentIndex(c);
} else if( Boolean.TRUE.equals( ((JComponent) c).getClientProperty(ToolbarContainer.PROP_DRAGGER) ) ) {
//dragging the whole toolbar
final ToolbarContainer container = (ToolbarContainer) c.getParent().getParent();
if( container.isShowing() ) {
sourceContainer = container;
sourceRow = (ToolbarRow) container.getParent();
t = new ExTransferable.Single(toolbarDataFlavor) {
public Object getData() {
return container;
}
};
isToolbarDrag = true;
isButtonDrag = false;
startingPoint = new Point(e.getDragOrigin());
Rectangle bounds = new Rectangle(sourceContainer.getPreferredSize());
bounds.setLocation(sourceContainer.getLocationOnScreen());
dragImage = createContentImage(sourceContainer, bounds.getSize());
sourceRow.dragStarted( sourceContainer );
dragWindow = createDragWindow( dragImage, bounds );
}
}
if( c instanceof JButton ) {
((JButton) c).getModel().setArmed(false);
((JButton) c).getModel().setPressed(false);
((JButton) c).getModel().setRollover(true);
}
if( t != null ) {
e.startDrag(dragMoveCursor, t, this);
}
} catch( InvalidDnDOperationException idoE ) {
log.log(Level.INFO, null, idoE);
}
}