/** * (non-Javadoc) * * @see javax.swing.TransferHandler#createTransferable(javax.swing.JComponent) */ public Transferable createTransferable(JComponent c) { if (c instanceof mxGraphComponent) { mxGraphComponent graphComponent = (mxGraphComponent) c; mxGraph graph = graphComponent.getGraph(); if (!graph.isSelectionEmpty()) { originalCells = graphComponent.getExportableCells(graph .getSelectionCells()); if (originalCells.length > 0) { ImageIcon icon = (transferImageEnabled) ? createTransferableImage( graphComponent, originalCells) : null; return createGraphTransferable(graphComponent, originalCells, icon); } } } return null; }
/** * (non-Javadoc) * * @see javax.swing.TransferHandler#createTransferable(javax.swing.JComponent) */ public Transferable createTransferable(JComponent c) { if (c instanceof mxGraphComponent) { mxGraphComponent graphComponent = (mxGraphComponent) c; mxGraph graph = graphComponent.getGraph(); if (!graph.isSelectionEmpty()) { originalCells = graphComponent.getExportableCells(graph .getSelectionCells()); if (originalCells.length > 0) { ImageIcon icon = (transferImageEnabled) ? createTransferableImage( graphComponent, originalCells) : null; return createGraphTransferable(graphComponent, originalCells, icon); } } } return null; }
/** * */ public mxGraphTransferable createGraphTransferable( mxGraphComponent graphComponent, Object[] cells, ImageIcon icon) { mxGraph graph = graphComponent.getGraph(); mxPoint tr = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxRectangle bounds = graph.getPaintBounds(cells); // Removes the scale and translation from the bounds bounds.setX(bounds.getX() / scale - tr.getX()); bounds.setY(bounds.getY() / scale - tr.getY()); bounds.setWidth(bounds.getWidth() / scale); bounds.setHeight(bounds.getHeight() / scale); return createGraphTransferable(graphComponent, cells, bounds, icon); }
/** * */ public mxGraphTransferable createGraphTransferable( mxGraphComponent graphComponent, Object[] cells, ImageIcon icon) { mxGraph graph = graphComponent.getGraph(); mxPoint tr = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxRectangle bounds = graph.getPaintBounds(cells); // Removes the scale and translation from the bounds bounds.setX(bounds.getX() / scale - tr.getX()); bounds.setY(bounds.getY() / scale - tr.getY()); bounds.setWidth(bounds.getWidth() / scale); bounds.setHeight(bounds.getHeight() / scale); return createGraphTransferable(graphComponent, cells, bounds, icon); }