private static List< mxCell > getSelectionVertices( final mxGraph graph ) { // Build selection categories final Object[] selection = graph.getSelectionCells(); final ArrayList< mxCell > vertices = new ArrayList< >(); for ( final Object obj : selection ) { final mxCell cell = ( mxCell ) obj; if ( cell.isVertex() ) vertices.add( cell ); } return vertices; }
private static List< mxCell > getSelectionVertices( final mxGraph graph ) { // Build selection categories final Object[] selection = graph.getSelectionCells(); final ArrayList< mxCell > vertices = new ArrayList< >(); for ( final Object obj : selection ) { final mxCell cell = ( mxCell ) obj; if ( cell.isVertex() ) vertices.add( cell ); } return vertices; }
private static List< mxCell > getSelectionEdges( final mxGraph graph ) { // Build selection categories final Object[] selection = graph.getSelectionCells(); final ArrayList< mxCell > edges = new ArrayList< >(); for ( final Object obj : selection ) { final mxCell cell = ( mxCell ) obj; if ( cell.isEdge() ) edges.add( cell ); } return edges; } }
private static List< mxCell > getSelectionEdges( final mxGraph graph ) { // Build selection categories final Object[] selection = graph.getSelectionCells(); final ArrayList< mxCell > edges = new ArrayList< >(); for ( final Object obj : selection ) { final mxCell cell = ( mxCell ) obj; if ( cell.isEdge() ) edges.add( cell ); } return edges; } }
/** * Sets the key to value in the styles of the given cells. This will modify * the existing cell styles in-place and override any existing assignment * for the given key. If no cells are specified, then the selection cells * are changed. If no value is specified, then the respective key is * removed from the styles. * * @param key String representing the key to be assigned. * @param value String representing the new value for the key. * @param cells Array of cells to change the style for. */ public Object[] setCellStyles(String key, String value, Object[] cells) { if (cells == null) { cells = getSelectionCells(); } mxStyleUtils.setCellStyles(model, cells, key, value); return cells; }
/** * Sets the key to value in the styles of the given cells. This will modify * the existing cell styles in-place and override any existing assignment * for the given key. If no cells are specified, then the selection cells * are changed. If no value is specified, then the respective key is * removed from the styles. * * @param key String representing the key to be assigned. * @param value String representing the new value for the key. * @param cells Array of cells to change the style for. */ public Object[] setCellStyles(String key, String value, Object[] cells) { if (cells == null) { cells = getSelectionCells(); } mxStyleUtils.setCellStyles(model, cells, key, value); return cells; }
/** * */ public Object[] getCells(mxCellState initialState) { mxGraph graph = graphComponent.getGraph(); return graph.getMovableCells(graph.getSelectionCells()); }
/** * */ public Object[] getCells(Object initialCell) { mxGraph graph = graphComponent.getGraph(); return graph.getMovableCells(graph.getSelectionCells()); }
/** * */ public Object[] getCells(mxCellState initialState) { mxGraph graph = graphComponent.getGraph(); return graph.getMovableCells(graph.getSelectionCells()); }
/** * */ public Object[] getCells(Object initialCell) { mxGraph graph = graphComponent.getGraph(); return graph.getMovableCells(graph.getSelectionCells()); }
/** * */ protected mxRectangle getPlaceholderBounds(mxCellState startState) { mxGraph graph = graphComponent.getGraph(); return graph.getView().getBounds(graph.getSelectionCells()); }
/** * */ protected mxRectangle getPlaceholderBounds(mxCellState startState) { mxGraph graph = graphComponent.getGraph(); return graph.getView().getBounds(graph.getSelectionCells()); }
/** * (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; }
/** * Moves the given cells to the front or back. The change is carried out * using cellsOrdered. This method fires mxEvent.ORDER_CELLS while the * transaction is in progress. * * @param back Specifies if the cells should be moved to back. * @param cells Array of cells whose order should be changed. If null is * specified then the selection cells are used. */ public Object[] orderCells(boolean back, Object[] cells) { if (cells == null) { cells = mxUtils.sortCells(getSelectionCells(), true); } model.beginUpdate(); try { cellsOrdered(cells, back); fireEvent(new mxEventObject(mxEvent.ORDER_CELLS, "cells", cells, "back", back)); } finally { model.endUpdate(); } return cells; }
/** * Removes the specified cells from their parents and adds them to the * default parent. * * @param cells Array of cells to be removed from their parents. * @return Returns the cells that were removed from their parents. */ public Object[] removeCellsFromParent(Object[] cells) { if (cells == null) { cells = getSelectionCells(); } model.beginUpdate(); try { Object parent = getDefaultParent(); int index = model.getChildCount(parent); cellsAdded(cells, parent, index, null, null, true); fireEvent(new mxEventObject(mxEvent.REMOVE_CELLS_FROM_PARENT, "cells", cells)); } finally { model.endUpdate(); } return cells; }
@Override public void zoomTo( final double newScale, final boolean center ) { final mxGraphView view = graph.getView(); final double scale = view.getScale(); final mxPoint translate = ( pageVisible && centerPage ) ? getPageTranslate( newScale ) : new mxPoint(); graph.getView().scaleAndTranslate( newScale, translate.getX(), translate.getY() ); if ( keepSelectionVisibleOnZoom && !graph.isSelectionEmpty() ) { getGraphControl().scrollRectToVisible( view.getBoundingBox( graph.getSelectionCells() ).getRectangle() ); } else { maintainScrollBar( true, newScale / scale, center ); maintainScrollBar( false, newScale / scale, center ); } }
@Override public void zoomTo( final double newScale, final boolean center ) { final mxGraphView view = graph.getView(); final double scale = view.getScale(); final mxPoint translate = ( pageVisible && centerPage ) ? getPageTranslate( newScale ) : new mxPoint(); graph.getView().scaleAndTranslate( newScale, translate.getX(), translate.getY() ); if ( keepSelectionVisibleOnZoom && !graph.isSelectionEmpty() ) { getGraphControl().scrollRectToVisible( view.getBoundingBox( graph.getSelectionCells() ).getRectangle() ); } else { maintainScrollBar( true, newScale / scale, center ); maintainScrollBar( false, newScale / scale, center ); } }
/** * */ public void zoom(double factor) { mxGraphView view = graph.getView(); double newScale = (double) ((int) (view.getScale() * 100 * factor)) / 100; if (newScale != view.getScale() && newScale > 0.04) { mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale) : new mxPoint(); graph.getView().scaleAndTranslate(newScale, translate.getX(), translate.getY()); if (keepSelectionVisibleOnZoom && !graph.isSelectionEmpty()) { getGraphControl().scrollRectToVisible( view.getBoundingBox(graph.getSelectionCells()) .getRectangle()); } else { maintainScrollBar(true, factor, centerZoom); maintainScrollBar(false, factor, centerZoom); } } }
/** * */ public void zoom(double factor) { mxGraphView view = graph.getView(); double newScale = (double) ((int) (view.getScale() * 100 * factor)) / 100; if (newScale != view.getScale() && newScale > 0.04) { mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale) : new mxPoint(); graph.getView().scaleAndTranslate(newScale, translate.getX(), translate.getY()); if (keepSelectionVisibleOnZoom && !graph.isSelectionEmpty()) { getGraphControl().scrollRectToVisible( view.getBoundingBox(graph.getSelectionCells()) .getRectangle()); } else { maintainScrollBar(true, factor, centerZoom); maintainScrollBar(false, factor, centerZoom); } } }