📄 mxgraphmodel.java
字号:
root = previous; previous = ((mxGraphModel) model).rootChanged(previous); } } public static class mxChildChange extends mxAtomicGraphModelChange { /** * */ protected Object parent, previous, child; /** * */ protected int index, previousIndex; /** * */ protected boolean added; /** * */ public mxChildChange(mxGraphModel model, Object parent, Object child) { this(model, parent, child, 0); } /** * */ public mxChildChange(mxGraphModel model, Object parent, Object child, int index) { super(model); this.parent = parent; previous = this.parent; this.child = child; this.index = index; previousIndex = index; added = (parent == null); } /** * @return the parent */ public Object getParent() { return parent; } /** * @return the previous */ public Object getPrevious() { return previous; } /** * @return the child */ public Object getChild() { return child; } /** * @return the index */ public int getIndex() { return index; } /** * @return the previousIndex */ public int getPreviousIndex() { return previousIndex; } /** * @return the isAdded */ public boolean isAdded() { return added; } /** * Gets the source or target terminal field for the given * edge even if the edge is not stored as an incoming or * outgoing edge in the respective terminal. */ protected Object getTerminal(Object edge, boolean source) { return model.getTerminal(edge, source); } /** * Sets the source or target terminal field for the given edge * without inserting an incoming or outgoing edge in the * respective terminal. */ protected void setTerminal(Object edge, Object terminal, boolean source) { ((mxICell) edge).setTerminal((mxICell) terminal, source); } /** * */ protected void connect(Object cell, boolean isConnect) { Object source = getTerminal(cell, true); Object target = getTerminal(cell, false); if (source != null) { if (isConnect) { ((mxGraphModel) model).terminalForCellChanged(cell, source, true); } else { ((mxGraphModel) model).terminalForCellChanged(cell, null, true); } } if (target != null) { if (isConnect) { ((mxGraphModel) model).terminalForCellChanged(cell, target, false); } else { ((mxGraphModel) model).terminalForCellChanged(cell, null, false); } } // Stores the previous terminals in the edge setTerminal(cell, source, true); setTerminal(cell, target, false); int childCount = model.getChildCount(cell); for (int i = 0; i < childCount; i++) { connect((mxICell) model.getChildAt(cell, i), isConnect); } } /** * Returns the index of the given child inside the given parent. */ protected int getChildIndex(Object parent, Object child) { return (parent instanceof mxICell && child instanceof mxICell) ? ((mxICell) parent) .getIndex((mxICell) child) : 0; } /** * Changes the root of the model. */ public void execute() { Object tmp = model.getParent(child); int tmp2 = getChildIndex(tmp, child); if (previous == null) { connect(child, false); } tmp = ((mxGraphModel) model).parentForCellChanged(child, previous, previousIndex); if (previous != null) { connect(child, true); } parent = previous; previous = tmp; index = previousIndex; previousIndex = tmp2; added = !added; } } public static class mxTerminalChange extends mxAtomicGraphModelChange { /** * */ protected Object cell, terminal, previous; /** * */ protected boolean isSource; /** * */ public mxTerminalChange(mxGraphModel model, Object cell, Object terminal, boolean isSource) { super(model); this.cell = cell; this.terminal = terminal; this.previous = this.terminal; this.isSource = isSource; } /** * @return the cell */ public Object getCell() { return cell; } /** * @return the terminal */ public Object getTerminal() { return terminal; } /** * @return the previous */ public Object getPrevious() { return previous; } /** * @return the isSource */ public boolean isSource() { return isSource; } /** * Changes the root of the model. */ public void execute() { terminal = previous; previous = ((mxGraphModel) model).terminalForCellChanged(cell, previous, isSource); } } public static class mxValueChange extends mxAtomicGraphModelChange { /** * */ protected Object cell, value, previous; /** * */ public mxValueChange(mxGraphModel model, Object cell, Object value) { super(model); this.cell = cell; this.value = value; this.previous = this.value; } /** * @return the cell */ public Object getCell() { return cell; } /** * @return the value */ public Object getValue() { return value; } /** * @return the previous */ public Object getPrevious() { return previous; } /** * Changes the root of the model. */ public void execute() { value = previous; previous = ((mxGraphModel) model).valueForCellChanged(cell, previous); } } public static class mxStyleChange extends mxAtomicGraphModelChange { /** * */ protected Object cell; /** * */ protected String style, previous; /** * */ public mxStyleChange(mxGraphModel model, Object cell, String style) { super(model); this.cell = cell; this.style = style; this.previous = this.style; } /** * @return the cell */ public Object getCell() { return cell; } /** * @return the style */ public String getStyle() { return style; } /** * @return the previous */ public String getPrevious() { return previous; } /** * Changes the root of the model. */ public void execute() { style = previous; previous = ((mxGraphModel) model).styleForCellChanged(cell, previous); } } public static class mxGeometryChange extends mxAtomicGraphModelChange { /** * */ protected Object cell; /** * */ protected mxGeometry geometry, previous; /** * */ public mxGeometryChange(mxGraphModel model, Object cell, mxGeometry geometry) { super(model); this.cell = cell; this.geometry = geometry; this.previous = this.geometry; } /** * @return the cell */ public Object getCell() { return cell; } /** * @return the geometry */ public mxGeometry getGeometry() { return geometry; } /** * @return the previous */ public mxGeometry getPrevious() { return previous; } /** * Changes the root of the model. */ public void execute() { geometry = previous; previous = ((mxGraphModel) model).geometryForCellChanged(cell, previous); } } public static class mxCollapseChange extends mxAtomicGraphModelChange { /** * */ protected Object cell; /** * */ protected boolean collapsed, previous; /** * */ public mxCollapseChange(mxGraphModel model, Object cell, boolean collapsed) { super(model); this.cell = cell; this.collapsed = collapsed; this.previous = this.collapsed; } /** * @return the cell */ public Object getCell() { return cell; } /** * @return the collapsed */ public boolean isCollapsed() { return collapsed; } /** * @return the previous */ public boolean getPrevious() { return previous; } /** * Changes the root of the model. */ public void execute() { collapsed = previous; previous = ((mxGraphModel) model).collapsedStateForCellChanged( cell, previous); } } public static class mxVisibleChange extends mxAtomicGraphModelChange { /** * */ protected Object cell; /** * */ protected boolean visible, previous; /** * */ public mxVisibleChange(mxGraphModel model, Object cell, boolean visible) { super(model); this.cell = cell; this.visible = visible; this.previous = this.visible; } /** * @return the cell */ public Object getCell() { return cell; } /** * @return the visible */ public boolean isVisible() { return visible; } /** * @return the previous */ public boolean getPrevious() { return visible; } /** * Changes the root of the model. */ public void execute() { visible = previous; previous = ((mxGraphModel) model).visibleStateForCellChanged(cell, previous); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -