当前位置: 首页>>代码示例>>Java>>正文


Java DropTargetDragEvent.rejectDrag方法代码示例

本文整理汇总了Java中java.awt.dnd.DropTargetDragEvent.rejectDrag方法的典型用法代码示例。如果您正苦于以下问题:Java DropTargetDragEvent.rejectDrag方法的具体用法?Java DropTargetDragEvent.rejectDrag怎么用?Java DropTargetDragEvent.rejectDrag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.dnd.DropTargetDragEvent的用法示例。


在下文中一共展示了DropTargetDragEvent.rejectDrag方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dragEnter

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public void dragEnter(DropTargetDragEvent dtde) {
	if (
		((dtde.getDropAction() & DnDConstants.ACTION_MOVE) != 0) &&
		(dtde.getTransferable().isDataFlavorSupported(JDDLTransferData.DATA_FLAVOR))
	) {
		dtde.acceptDrag(DnDConstants.ACTION_MOVE);
	} else {
		dtde.rejectDrag();
	}
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:12,代码来源:TrashDropTargetListener.java

示例2: dragOver

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public void dragOver(DropTargetDragEvent dtde) {
	if ((dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor) || (uriFlavor != null && dtde
			.isDataFlavorSupported(uriFlavor)))
			&& canOpenFile())
		dtde.acceptDrag(DnDConstants.ACTION_REFERENCE);
	else
		dtde.rejectDrag();
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:10,代码来源:FileDropTargetListener.java

示例3: dragEnter

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
public void dragEnter(DropTargetDragEvent e) {
    if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
        isButtonDrag = true; //in case use is dragging something from the customizer window
    } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        e.rejectDrag();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DnDSupport.java

示例4: dragOver

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
public void dragOver(DropTargetDragEvent e) {
    if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) {
        updateDropGesture( e );
        if( !validateDropPosition() ) {
            e.rejectDrag();
        } else {
            e.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE );
        }
    } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        e.rejectDrag();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:DnDSupport.java

示例5: dragEnter

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
/** User is starting to drag over us */
public void dragEnter(DropTargetDragEvent dtde) {
    if (!checkConditions(dtde)) {
        dtde.rejectDrag();
    } else {
        lastIndex = comp.locationToIndex(dtde.getLocation());
        cellRenderer.draggingEnter(lastIndex, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
        comp.repaint(comp.getCellBounds(lastIndex, lastIndex));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:IndexedCustomizer.java

示例6: dragOver

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
/** User drag over us */
public void dragOver(DropTargetDragEvent dtde) {
    if (!checkConditions(dtde)) {
        dtde.rejectDrag();

        if (lastIndex >= 0) {
            cellRenderer.draggingExit();
            comp.repaint(comp.getCellBounds(lastIndex, lastIndex));
            lastIndex = -1;
        }
    } else {
        dtde.acceptDrag(DnDConstants.ACTION_MOVE);

        int index = comp.locationToIndex(dtde.getLocation());

        if (lastIndex == index) {
            cellRenderer.draggingOver(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
        } else {
            if (lastIndex < 0) {
                lastIndex = index;
            }

            cellRenderer.draggingExit();
            cellRenderer.draggingEnter(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
            comp.repaint(comp.getCellBounds(lastIndex, index));
            lastIndex = index;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:IndexedCustomizer.java

示例7: dragEnter

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public final void dragEnter(DropTargetDragEvent dtde) {
	Point pt = dtde.getLocation();
	int action = dtde.getDropAction();
	if (drawImage) {
		paintImage(pt);
	}
	if (controller.canPerformAction(tree, draggedNode, action, pt)) {
		dtde.acceptDrag(action);
	} else {
		dtde.rejectDrag();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:14,代码来源:JTreeUtil.java

示例8: dragOver

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public final void dragOver(DropTargetDragEvent dtde) {
	Point pt = dtde.getLocation();
	int action = dtde.getDropAction();
	autoscroll(tree, pt);
	if (drawImage) {
		paintImage(pt);
	}
	if (controller.canPerformAction(tree, draggedNode, action, pt)) {
		dtde.acceptDrag(action);
	} else {
		dtde.rejectDrag();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:JTreeUtil.java

示例9: dropActionChanged

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public final void dropActionChanged(DropTargetDragEvent dtde) {
	Point pt = dtde.getLocation();
	int action = dtde.getDropAction();
	if (drawImage) {
		paintImage(pt);
	}
	if (controller.canPerformAction(tree, draggedNode, action, pt)) {
		dtde.acceptDrag(action);
	} else {
		dtde.rejectDrag();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:14,代码来源:JTreeUtil.java

示例10: dragOver

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
/**
 * 
 * @param e
 */
public void dragOver(DropTargetDragEvent e)
{
	if (canImport)
	{
		mouseDragged(createEvent(e));
		mxGraphTransferHandler handler = getGraphTransferHandler(e);

		if (handler != null)
		{
			mxGraph graph = graphComponent.getGraph();
			double scale = graph.getView().getScale();
			Point pt = SwingUtilities.convertPoint(graphComponent,
					e.getLocation(), graphComponent.getGraphControl());

			pt = graphComponent.snapScaledPoint(new mxPoint(pt)).getPoint();
			handler.setLocation(new Point(pt));

			int dx = 0;
			int dy = 0;

			// Centers the preview image
			if (centerPreview && transferBounds != null)
			{
				dx -= Math.round(transferBounds.getWidth() * scale / 2);
				dy -= Math.round(transferBounds.getHeight() * scale / 2);
			}

			// Sets the drop offset so that the location in the transfer
			// handler reflects the actual mouse position
			handler.setOffset(new Point((int) graph.snap(dx / scale),
					(int) graph.snap(dy / scale)));
			pt.translate(dx, dy);

			// Shifts the preview so that overlapping parts do not
			// affect the centering
			if (transferBounds != null && dragImage != null)
			{
				dx = (int) Math
						.round((dragImage.getIconWidth() - 2 - transferBounds
								.getWidth() * scale) / 2);
				dy = (int) Math
						.round((dragImage.getIconHeight() - 2 - transferBounds
								.getHeight() * scale) / 2);
				pt.translate(-dx, -dy);
			}

			if (!handler.isLocalDrag() && previewBounds != null)
			{
				setPreviewBounds(new Rectangle(pt, previewBounds.getSize()));
			}
		}
	}
	else
	{
		e.rejectDrag();
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:62,代码来源:mxGraphHandler.java

示例11: dragEnter

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
/**
 * 
 */
public void dragEnter(DropTargetDragEvent e) {
  JComponent component = getDropTarget(e);
  TransferHandler th = component.getTransferHandler();
  boolean isLocal =
      th instanceof mxGraphTransferHandler && ((mxGraphTransferHandler) th).isLocalDrag();

  if (isLocal) {
    canImport = true;
  } else {
    canImport =
        graphComponent.isImportEnabled() && th.canImport(component, e.getCurrentDataFlavors());
  }

  if (canImport) {
    transferBounds = null;
    setVisible(false);

    try {
      Transferable t = e.getTransferable();

      if (t.isDataFlavorSupported(mxGraphTransferable.dataFlavor)) {
        mxGraphTransferable gt =
            (mxGraphTransferable) t.getTransferData(mxGraphTransferable.dataFlavor);
        dragCells = gt.getCells();

        if (gt.getBounds() != null) {
          mxGraph graph = graphComponent.getGraph();
          double scale = graph.getView().getScale();
          transferBounds = gt.getBounds();
          int w = (int) Math.ceil((transferBounds.getWidth() + 1) * scale);
          int h = (int) Math.ceil((transferBounds.getHeight() + 1) * scale);
          setPreviewBounds(
              new Rectangle((int) transferBounds.getX(), (int) transferBounds.getY(), w, h));

          if (imagePreview) {
            // Does not render fixed cells for local preview
            // but ignores movable state for non-local previews
            if (isLocal) {
              if (!isLivePreview()) {
                updateDragImage(graph.getMovableCells(dragCells));
              }
            } else {
              Object[] tmp = graphComponent.getImportableCells(dragCells);
              updateDragImage(tmp);

              // Shows no drag icon if import is allowed but none
              // of the cells can be imported
              if (tmp == null || tmp.length == 0) {
                canImport = false;
                e.rejectDrag();

                return;
              }
            }
          }

          setVisible(true);
        }
      }

      e.acceptDrag(TransferHandler.COPY_OR_MOVE);
    } catch (Exception ex) {
      // do nothing
      ex.printStackTrace();
    }

  } else {
    e.rejectDrag();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:74,代码来源:mxGraphHandler.java

示例12: dragOver

import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
/**
 * 
 * @param e
 */
public void dragOver(DropTargetDragEvent e) {
  if (canImport) {
    mouseDragged(createEvent(e));
    mxGraphTransferHandler handler = getGraphTransferHandler(e);

    if (handler != null) {
      mxGraph graph = graphComponent.getGraph();
      double scale = graph.getView().getScale();
      Point pt = SwingUtilities.convertPoint(graphComponent, e.getLocation(),
          graphComponent.getGraphControl());

      pt = graphComponent.snapScaledPoint(new mxPoint(pt)).getPoint();
      handler.setLocation(new Point(pt));

      int dx = 0;
      int dy = 0;

      // Centers the preview image
      if (centerPreview && transferBounds != null) {
        dx -= Math.round(transferBounds.getWidth() * scale / 2);
        dy -= Math.round(transferBounds.getHeight() * scale / 2);
      }

      // Sets the drop offset so that the location in the transfer
      // handler reflects the actual mouse position
      handler.setOffset(new Point((int) graph.snap(dx / scale), (int) graph.snap(dy / scale)));
      pt.translate(dx, dy);

      // Shifts the preview so that overlapping parts do not
      // affect the centering
      if (transferBounds != null && dragImage != null) {
        dx = (int) Math
            .round((dragImage.getIconWidth() - 2 - transferBounds.getWidth() * scale) / 2);
        dy = (int) Math
            .round((dragImage.getIconHeight() - 2 - transferBounds.getHeight() * scale) / 2);
        pt.translate(-dx, -dy);
      }

      if (!handler.isLocalDrag() && previewBounds != null) {
        setPreviewBounds(new Rectangle(pt, previewBounds.getSize()));
      }
    }
  } else {
    e.rejectDrag();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:51,代码来源:mxGraphHandler.java


注:本文中的java.awt.dnd.DropTargetDragEvent.rejectDrag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。