/** * */ public mxGraphTransferable createGraphTransferable( mxGraphComponent graphComponent, Object[] cells, mxRectangle bounds, ImageIcon icon) { return new mxGraphTransferable(graphComponent.getGraph().cloneCells( cells), bounds, icon); }
throws UnsupportedFlavorException, IOException if (isRicherFlavor(flavor)) return getRicherData(flavor); else if (isImageFlavor(flavor)) else if (isHtmlFlavor(flavor)) String data = getHtmlData(); data = (data == null) ? "" : data; else if (isPlainFlavor(flavor)) String data = getPlainData(); data = (data == null) ? "" : data; else if (isStringFlavor(flavor)) String data = getPlainData(); data = (data == null) ? "" : data;
DataFlavor[] richerFlavors = getRicherFlavors(); int nHtml = (isHtmlSupported()) ? htmlFlavors.length : 0; int nPlain = (isPlainSupported()) ? plainFlavors.length : 0; int nString = (isPlainSupported()) ? stringFlavors.length : 0; int nImage = (isImageSupported()) ? imageFlavors.length : 0; int nFlavors = nRicher + nHtml + nPlain + nString + nImage;
.getTransferData(mxGraphTransferable.dataFlavor); if (gt.getCells() != null)
/** * * @param flavor * @return Returns true if the given flavor is a richer flavor of this * transferable. */ protected boolean isRicherFlavor(DataFlavor flavor) { DataFlavor[] richerFlavors = getRicherFlavors(); int nFlavors = (richerFlavors != null) ? richerFlavors.length : 0; for (int i = 0; i < nFlavors; i++) { if (richerFlavors[i].equals(flavor)) { return true; } } return false; }
/** * Returns whether or not the specified data flavor is supported for this * object. * * @param flavor * the requested flavor for the data * @return boolean indicating whether or not the data flavor is supported */ public boolean isDataFlavorSupported(DataFlavor flavor) { DataFlavor[] flavors = getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++) { if (flavors[i] != null && flavors[i].equals(flavor)) { return true; } } return false; }
mxRectangle bounds = gt.getBounds(); double dx = 0, dy = 0;
.getTransferData(mxGraphTransferable.dataFlavor); if (gt.getCells() != null)
/** * * @param flavor * @return Returns true if the given flavor is a richer flavor of this * transferable. */ protected boolean isRicherFlavor(DataFlavor flavor) { DataFlavor[] richerFlavors = getRicherFlavors(); int nFlavors = (richerFlavors != null) ? richerFlavors.length : 0; for (int i = 0; i < nFlavors; i++) { if (richerFlavors[i].equals(flavor)) { return true; } } return false; }
/** * Returns whether or not the specified data flavor is supported for this * object. * * @param flavor * the requested flavor for the data * @return boolean indicating whether or not the data flavor is supported */ public boolean isDataFlavorSupported(DataFlavor flavor) { DataFlavor[] flavors = getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++) { if (flavors[i] != null && flavors[i].equals(flavor)) { return true; } } return false; }
mxRectangle bounds = gt.getBounds(); double dx = 0, dy = 0;
throws UnsupportedFlavorException, IOException if (isRicherFlavor(flavor)) return getRicherData(flavor); else if (isImageFlavor(flavor)) else if (isHtmlFlavor(flavor)) String data = getHtmlData(); data = (data == null) ? "" : data; else if (isPlainFlavor(flavor)) String data = getPlainData(); data = (data == null) ? "" : data; else if (isStringFlavor(flavor)) String data = getPlainData(); data = (data == null) ? "" : data;
DataFlavor[] richerFlavors = getRicherFlavors(); int nHtml = (isHtmlSupported()) ? htmlFlavors.length : 0; int nPlain = (isPlainSupported()) ? plainFlavors.length : 0; int nString = (isPlainSupported()) ? stringFlavors.length : 0; int nImage = (isImageSupported()) ? imageFlavors.length : 0; int nFlavors = nRicher + nHtml + nPlain + nString + nImage;
/** * Returns the drop target for the given transferable and location. */ protected Object getDropTarget(mxGraphComponent graphComponent, mxGraphTransferable gt) { Object[] cells = gt.getCells(); Object target = null; // Finds the target cell at the given location and checks if the // target is not already the parent of the first imported cell if (location != null) { target = graphComponent.getGraph().getDropTarget(cells, location, graphComponent.getCellAt(location.x, location.y)); if (cells.length > 0 && graphComponent.getGraph().getModel().getParent(cells[0]) == target) { target = null; } } return target; }
/** * */ public mxGraphTransferable createGraphTransferable( mxGraphComponent graphComponent, Object[] cells, mxRectangle bounds, ImageIcon icon) { return new mxGraphTransferable(graphComponent.getGraph().cloneCells( cells), bounds, icon); }
/** * Returns the drop target for the given transferable and location. */ protected Object getDropTarget(mxGraphComponent graphComponent, mxGraphTransferable gt) { Object[] cells = gt.getCells(); Object target = null; // Finds the target cell at the given location and checks if the // target is not already the parent of the first imported cell if (location != null) { target = graphComponent.getGraph().getDropTarget(cells, location, graphComponent.getCellAt(location.x, location.y)); if (cells.length > 0 && graphComponent.getGraph().getModel().getParent(cells[0]) == target) { target = null; } } return target; }
/** * Gets a drop target using getDropTarget and imports the cells using * mxGraph.splitEdge or mxGraphComponent.importCells depending on the * drop target and the return values of mxGraph.isSplitEnabled and * mxGraph.isSplitTarget. Selects and returns the cells that have been * imported. */ protected Object[] importCells(mxGraphComponent graphComponent, mxGraphTransferable gt, double dx, double dy) { Object target = getDropTarget(graphComponent, gt); mxGraph graph = graphComponent.getGraph(); Object[] cells = gt.getCells(); cells = graphComponent.getImportableCells(cells); if (graph.isSplitEnabled() && graph.isSplitTarget(target, cells)) { graph.splitEdge(target, cells, dx, dy); } else { cells = graphComponent.importCells(cells, dx, dy, target, location); graph.setSelectionCells(cells); } return cells; }
/** * Gets a drop target using getDropTarget and imports the cells using * mxGraph.splitEdge or mxGraphComponent.importCells depending on the * drop target and the return values of mxGraph.isSplitEnabled and * mxGraph.isSplitTarget. Selects and returns the cells that have been * imported. */ protected Object[] importCells(mxGraphComponent graphComponent, mxGraphTransferable gt, double dx, double dy) { Object target = getDropTarget(graphComponent, gt); mxGraph graph = graphComponent.getGraph(); Object[] cells = gt.getCells(); cells = graphComponent.getImportableCells(cells); if (graph.isSplitEnabled() && graph.isSplitTarget(target, cells)) { graph.splitEdge(target, cells, dx, dy); } else { cells = graphComponent.importCells(cells, dx, dy, target, location); graph.setSelectionCells(cells); } return cells; }