com.mxgraph.view.mxGraph.getSelectionCells()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中com.mxgraph.view.mxGraph.getSelectionCells()方法的一些代码示例,展示了mxGraph.getSelectionCells()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。mxGraph.getSelectionCells()方法的具体详情如下:
包路径:com.mxgraph.view.mxGraph
类名称:mxGraph
方法名:getSelectionCells

mxGraph.getSelectionCells介绍

暂无

代码示例

代码示例来源:origin: sc.fiji/TrackMate_

  1. private static List< mxCell > getSelectionVertices( final mxGraph graph )
  2. {
  3. // Build selection categories
  4. final Object[] selection = graph.getSelectionCells();
  5. final ArrayList< mxCell > vertices = new ArrayList< >();
  6. for ( final Object obj : selection )
  7. {
  8. final mxCell cell = ( mxCell ) obj;
  9. if ( cell.isVertex() )
  10. vertices.add( cell );
  11. }
  12. return vertices;
  13. }

代码示例来源:origin: fiji/TrackMate

  1. private static List< mxCell > getSelectionVertices( final mxGraph graph )
  2. {
  3. // Build selection categories
  4. final Object[] selection = graph.getSelectionCells();
  5. final ArrayList< mxCell > vertices = new ArrayList< >();
  6. for ( final Object obj : selection )
  7. {
  8. final mxCell cell = ( mxCell ) obj;
  9. if ( cell.isVertex() )
  10. vertices.add( cell );
  11. }
  12. return vertices;
  13. }

代码示例来源:origin: sc.fiji/TrackMate_

  1. private static List< mxCell > getSelectionEdges( final mxGraph graph )
  2. {
  3. // Build selection categories
  4. final Object[] selection = graph.getSelectionCells();
  5. final ArrayList< mxCell > edges = new ArrayList< >();
  6. for ( final Object obj : selection )
  7. {
  8. final mxCell cell = ( mxCell ) obj;
  9. if ( cell.isEdge() )
  10. edges.add( cell );
  11. }
  12. return edges;
  13. }
  14. }

代码示例来源:origin: fiji/TrackMate

  1. private static List< mxCell > getSelectionEdges( final mxGraph graph )
  2. {
  3. // Build selection categories
  4. final Object[] selection = graph.getSelectionCells();
  5. final ArrayList< mxCell > edges = new ArrayList< >();
  6. for ( final Object obj : selection )
  7. {
  8. final mxCell cell = ( mxCell ) obj;
  9. if ( cell.isEdge() )
  10. edges.add( cell );
  11. }
  12. return edges;
  13. }
  14. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. * Sets the key to value in the styles of the given cells. This will modify
  3. * the existing cell styles in-place and override any existing assignment
  4. * for the given key. If no cells are specified, then the selection cells
  5. * are changed. If no value is specified, then the respective key is
  6. * removed from the styles.
  7. *
  8. * @param key String representing the key to be assigned.
  9. * @param value String representing the new value for the key.
  10. * @param cells Array of cells to change the style for.
  11. */
  12. public Object[] setCellStyles(String key, String value, Object[] cells)
  13. {
  14. if (cells == null)
  15. {
  16. cells = getSelectionCells();
  17. }
  18. mxStyleUtils.setCellStyles(model, cells, key, value);
  19. return cells;
  20. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. * Sets the key to value in the styles of the given cells. This will modify
  3. * the existing cell styles in-place and override any existing assignment
  4. * for the given key. If no cells are specified, then the selection cells
  5. * are changed. If no value is specified, then the respective key is
  6. * removed from the styles.
  7. *
  8. * @param key String representing the key to be assigned.
  9. * @param value String representing the new value for the key.
  10. * @param cells Array of cells to change the style for.
  11. */
  12. public Object[] setCellStyles(String key, String value, Object[] cells)
  13. {
  14. if (cells == null)
  15. {
  16. cells = getSelectionCells();
  17. }
  18. mxStyleUtils.setCellStyles(model, cells, key, value);
  19. return cells;
  20. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. *
  3. */
  4. public Object[] getCells(mxCellState initialState)
  5. {
  6. mxGraph graph = graphComponent.getGraph();
  7. return graph.getMovableCells(graph.getSelectionCells());
  8. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. *
  3. */
  4. public Object[] getCells(Object initialCell)
  5. {
  6. mxGraph graph = graphComponent.getGraph();
  7. return graph.getMovableCells(graph.getSelectionCells());
  8. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. *
  3. */
  4. public Object[] getCells(mxCellState initialState)
  5. {
  6. mxGraph graph = graphComponent.getGraph();
  7. return graph.getMovableCells(graph.getSelectionCells());
  8. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. *
  3. */
  4. public Object[] getCells(Object initialCell)
  5. {
  6. mxGraph graph = graphComponent.getGraph();
  7. return graph.getMovableCells(graph.getSelectionCells());
  8. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. *
  3. */
  4. protected mxRectangle getPlaceholderBounds(mxCellState startState)
  5. {
  6. mxGraph graph = graphComponent.getGraph();
  7. return graph.getView().getBounds(graph.getSelectionCells());
  8. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. *
  3. */
  4. protected mxRectangle getPlaceholderBounds(mxCellState startState)
  5. {
  6. mxGraph graph = graphComponent.getGraph();
  7. return graph.getView().getBounds(graph.getSelectionCells());
  8. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. * (non-Javadoc)
  3. *
  4. * @see javax.swing.TransferHandler#createTransferable(javax.swing.JComponent)
  5. */
  6. public Transferable createTransferable(JComponent c)
  7. {
  8. if (c instanceof mxGraphComponent)
  9. {
  10. mxGraphComponent graphComponent = (mxGraphComponent) c;
  11. mxGraph graph = graphComponent.getGraph();
  12. if (!graph.isSelectionEmpty())
  13. {
  14. originalCells = graphComponent.getExportableCells(graph
  15. .getSelectionCells());
  16. if (originalCells.length > 0)
  17. {
  18. ImageIcon icon = (transferImageEnabled) ? createTransferableImage(
  19. graphComponent, originalCells) : null;
  20. return createGraphTransferable(graphComponent,
  21. originalCells, icon);
  22. }
  23. }
  24. }
  25. return null;
  26. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. * (non-Javadoc)
  3. *
  4. * @see javax.swing.TransferHandler#createTransferable(javax.swing.JComponent)
  5. */
  6. public Transferable createTransferable(JComponent c)
  7. {
  8. if (c instanceof mxGraphComponent)
  9. {
  10. mxGraphComponent graphComponent = (mxGraphComponent) c;
  11. mxGraph graph = graphComponent.getGraph();
  12. if (!graph.isSelectionEmpty())
  13. {
  14. originalCells = graphComponent.getExportableCells(graph
  15. .getSelectionCells());
  16. if (originalCells.length > 0)
  17. {
  18. ImageIcon icon = (transferImageEnabled) ? createTransferableImage(
  19. graphComponent, originalCells) : null;
  20. return createGraphTransferable(graphComponent,
  21. originalCells, icon);
  22. }
  23. }
  24. }
  25. return null;
  26. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. * Moves the given cells to the front or back. The change is carried out
  3. * using cellsOrdered. This method fires mxEvent.ORDER_CELLS while the
  4. * transaction is in progress.
  5. *
  6. * @param back Specifies if the cells should be moved to back.
  7. * @param cells Array of cells whose order should be changed. If null is
  8. * specified then the selection cells are used.
  9. */
  10. public Object[] orderCells(boolean back, Object[] cells)
  11. {
  12. if (cells == null)
  13. {
  14. cells = mxUtils.sortCells(getSelectionCells(), true);
  15. }
  16. model.beginUpdate();
  17. try
  18. {
  19. cellsOrdered(cells, back);
  20. fireEvent(new mxEventObject(mxEvent.ORDER_CELLS, "cells", cells,
  21. "back", back));
  22. }
  23. finally
  24. {
  25. model.endUpdate();
  26. }
  27. return cells;
  28. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. * Removes the specified cells from their parents and adds them to the
  3. * default parent.
  4. *
  5. * @param cells Array of cells to be removed from their parents.
  6. * @return Returns the cells that were removed from their parents.
  7. */
  8. public Object[] removeCellsFromParent(Object[] cells)
  9. {
  10. if (cells == null)
  11. {
  12. cells = getSelectionCells();
  13. }
  14. model.beginUpdate();
  15. try
  16. {
  17. Object parent = getDefaultParent();
  18. int index = model.getChildCount(parent);
  19. cellsAdded(cells, parent, index, null, null, true);
  20. fireEvent(new mxEventObject(mxEvent.REMOVE_CELLS_FROM_PARENT,
  21. "cells", cells));
  22. }
  23. finally
  24. {
  25. model.endUpdate();
  26. }
  27. return cells;
  28. }

代码示例来源:origin: sc.fiji/TrackMate_

  1. @Override
  2. public void zoomTo( final double newScale, final boolean center )
  3. {
  4. final mxGraphView view = graph.getView();
  5. final double scale = view.getScale();
  6. final mxPoint translate = ( pageVisible && centerPage ) ? getPageTranslate( newScale ) : new mxPoint();
  7. graph.getView().scaleAndTranslate( newScale, translate.getX(), translate.getY() );
  8. if ( keepSelectionVisibleOnZoom && !graph.isSelectionEmpty() )
  9. {
  10. getGraphControl().scrollRectToVisible( view.getBoundingBox( graph.getSelectionCells() ).getRectangle() );
  11. }
  12. else
  13. {
  14. maintainScrollBar( true, newScale / scale, center );
  15. maintainScrollBar( false, newScale / scale, center );
  16. }
  17. }

代码示例来源:origin: fiji/TrackMate

  1. @Override
  2. public void zoomTo( final double newScale, final boolean center )
  3. {
  4. final mxGraphView view = graph.getView();
  5. final double scale = view.getScale();
  6. final mxPoint translate = ( pageVisible && centerPage ) ? getPageTranslate( newScale ) : new mxPoint();
  7. graph.getView().scaleAndTranslate( newScale, translate.getX(), translate.getY() );
  8. if ( keepSelectionVisibleOnZoom && !graph.isSelectionEmpty() )
  9. {
  10. getGraphControl().scrollRectToVisible( view.getBoundingBox( graph.getSelectionCells() ).getRectangle() );
  11. }
  12. else
  13. {
  14. maintainScrollBar( true, newScale / scale, center );
  15. maintainScrollBar( false, newScale / scale, center );
  16. }
  17. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. *
  3. */
  4. public void zoom(double factor)
  5. {
  6. mxGraphView view = graph.getView();
  7. double newScale = (double) ((int) (view.getScale() * 100 * factor)) / 100;
  8. if (newScale != view.getScale() && newScale > 0.04)
  9. {
  10. mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale)
  11. : new mxPoint();
  12. graph.getView().scaleAndTranslate(newScale, translate.getX(),
  13. translate.getY());
  14. if (keepSelectionVisibleOnZoom && !graph.isSelectionEmpty())
  15. {
  16. getGraphControl().scrollRectToVisible(
  17. view.getBoundingBox(graph.getSelectionCells())
  18. .getRectangle());
  19. }
  20. else
  21. {
  22. maintainScrollBar(true, factor, centerZoom);
  23. maintainScrollBar(false, factor, centerZoom);
  24. }
  25. }
  26. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. *
  3. */
  4. public void zoom(double factor)
  5. {
  6. mxGraphView view = graph.getView();
  7. double newScale = (double) ((int) (view.getScale() * 100 * factor)) / 100;
  8. if (newScale != view.getScale() && newScale > 0.04)
  9. {
  10. mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale)
  11. : new mxPoint();
  12. graph.getView().scaleAndTranslate(newScale, translate.getX(),
  13. translate.getY());
  14. if (keepSelectionVisibleOnZoom && !graph.isSelectionEmpty())
  15. {
  16. getGraphControl().scrollRectToVisible(
  17. view.getBoundingBox(graph.getSelectionCells())
  18. .getRectangle());
  19. }
  20. else
  21. {
  22. maintainScrollBar(true, factor, centerZoom);
  23. maintainScrollBar(false, factor, centerZoom);
  24. }
  25. }
  26. }

相关文章

mxGraph类方法