/** * * @return Returns the selection cells. */ public Object[] getSelectionCells() { return selectionModel.getCells(); }
/** * */ public void removeSelectionCells(Object[] cells) { selectionModel.removeCells(cells); }
public void valueChanged(ListSelectionEvent e) { int[] rows = startelementstable.getSelectedRows(); VElement[] elements = new VElement[rows.length]; for (int i = 0; i < rows.length; ++i) { elements[i] = modelcontainer.getGraph().getVisualElementById((String) startelementstable.getValueAt(rows[i], 1)); } modelcontainer.getGraph().getSelectionModel().removeListener(graphselectionlistener); modelcontainer.getGraph().setSelectionCells(elements); modelcontainer.getGraph().getSelectionModel().addListener(mxEvent.CHANGE, graphselectionlistener); } };
graph.getSelectionModel().addListener(mxEvent.CHANGE, new SelectionController(modelcontainer));
/** * */ public void execute() { if (removed != null) { Iterator<Object> it = removed.iterator(); while (it.hasNext()) { model.cellRemoved(it.next()); } } if (added != null) { Iterator<Object> it = added.iterator(); while (it.hasNext()) { model.cellAdded(it.next()); } } Collection<Object> tmp = added; added = removed; removed = tmp; model.fireEvent(new mxEventObject(mxEvent.CHANGE, "added", added, "removed", removed)); }
Object[] selcells = modelcontainer.getGraph().getSelectionModel().getCells(); modelcontainer.getGraph().getSelectionModel().removeCells(selcells);
/** * */ public void setSelectionCells(Object[] cells) { selectionModel.setCells(cells); }
/** * Terminates. */ public void terminate() { terminateEditing(); modelcontainer.getGraph().getSelectionModel().removeListener(graphselectionlistener); }
/** * Adds the given cell to the selection. */ public void addCell(Object cell) { if (cell != null) { addCells(new Object[] { cell }); } }
/** * */ public void addSelectionCell(Object cell) { selectionModel.addCell(cell); }
/** * Constructs a new selection model to be used in this graph. */ protected mxGraphSelectionModel createSelectionModel() { return new mxGraphSelectionModel(this); }
public void stateChanged(ChangeEvent e) { JTabbedPane tabpane = (JTabbedPane) e.getSource(); if (startelementsindex == tabpane.getSelectedIndex()) { modelcontainer.setEditMode(ModelContainer.EDIT_MODE_STEALTH_SELECTION); modelcontainer.getGraph().getSelectionModel().addListener(mxEvent.CHANGE, graphselectionlistener); wasstealth = true; } else { if (wasstealth) { wasstealth = false; modelcontainer.getGraph().clearSelection(); modelcontainer.getGraph().getSelectionModel().removeListener(graphselectionlistener); modelcontainer.setEditMode(ModelContainer.EDIT_MODE_SELECTION); } } terminateEditing(); } });
/** * Installs the listeners to update the handles after any changes. */ protected void addGraphListeners(mxGraph graph) { // LATER: Install change listener for graph model, selection model, view if (graph != null) { graph.getSelectionModel().addListener(mxEvent.CHANGE, refreshHandler); graph.getModel().addListener(mxEvent.CHANGE, refreshHandler); graph.getView().addListener(mxEvent.SCALE, refreshHandler); graph.getView().addListener(mxEvent.TRANSLATE, refreshHandler); graph.getView().addListener(mxEvent.SCALE_AND_TRANSLATE, refreshHandler); graph.getView().addListener(mxEvent.DOWN, refreshHandler); graph.getView().addListener(mxEvent.UP, refreshHandler); // Refreshes the handles if moveVertexLabels or moveEdgeLabels changes graph.addPropertyChangeListener(labelMoveHandler); } }
/** * */ public void execute() { if (removed != null) { Iterator<Object> it = removed.iterator(); while (it.hasNext()) { model.cellRemoved(it.next()); } } if (added != null) { Iterator<Object> it = added.iterator(); while (it.hasNext()) { model.cellAdded(it.next()); } } Collection<Object> tmp = added; added = removed; removed = tmp; model.fireEvent(new mxEventObject(mxEvent.CHANGE, "added", added, "removed", removed)); }
/** * */ public void setSelectionCells(Object[] cells) { selectionModel.setCells(cells); }
/** * Removes all installed listeners. */ protected void removeGraphListeners(mxGraph graph) { if (graph != null) { graph.getSelectionModel().removeListener(refreshHandler, mxEvent.CHANGE); graph.getModel().removeListener(refreshHandler, mxEvent.CHANGE); graph.getView().removeListener(refreshHandler, mxEvent.SCALE); graph.getView().removeListener(refreshHandler, mxEvent.TRANSLATE); graph.getView().removeListener(refreshHandler, mxEvent.SCALE_AND_TRANSLATE); graph.getView().removeListener(refreshHandler, mxEvent.DOWN); graph.getView().removeListener(refreshHandler, mxEvent.UP); // Refreshes the handles if moveVertexLabels or moveEdgeLabels changes graph.removePropertyChangeListener(labelMoveHandler); } }
/** * Adds the given cell to the selection. */ public void addCell(Object cell) { if (cell != null) { addCells(new Object[] { cell }); } }
/** * */ public void addSelectionCell(Object cell) { selectionModel.addCell(cell); }
/** * Constructs a new selection model to be used in this graph. */ protected mxGraphSelectionModel createSelectionModel() { return new mxGraphSelectionModel(this); }