/** * Creates a graph cell and initializes it with the specified user object. * The GraphCell allows children only if specified. * * @param userObject an Object provided by the user that constitutes * the cell's data * @param storageMap the storage attribute map for this cell * @param children array of children */ public DefaultGraphCell(Object userObject, AttributeMap storageMap, MutableTreeNode[] children) { super(userObject, true); setAttributes(storageMap); if (children != null) for (int i = 0; i < children.length; i++) add(children[i]); }
private void updateStateMachine() { if (oldStateDiagram) { this.repaint(); } else { K currentStateKey = stateMachine.getCurrentStateKey(); DefaultGraphCell currentStateCell = stateCells.get(currentStateKey); GraphConstants.setBackground(graph.getAttributes(currentStateCell), Color.RED); currentStateCell.setAttributes(graph.getAttributes(currentStateCell)); for (Entry<K, DefaultGraphCell> entry : stateCells.entrySet()) { if (entry.getKey() != currentStateKey) { DefaultGraphCell stateCell = entry.getValue(); GraphConstants.setBackground(graph.getAttributes(stateCell), Color.CYAN); stateCell.setAttributes(graph.getAttributes(stateCell)); } } graph.repaint(); graph.refresh(); } }
@Override public void stateChanged(K oldState, K newState) { if (oldStateDiagram) { this.repaint(); } else { if (oldState != null) { // At initialization, the state key is null. DefaultGraphCell oldStateCell = stateCells.get(oldState); GraphConstants.setBackground(graph.getAttributes(oldStateCell), Color.CYAN); oldStateCell.setAttributes(graph.getAttributes(oldStateCell)); } DefaultGraphCell newStateCell = stateCells.get(newState); GraphConstants.setBackground(graph.getAttributes(newStateCell), Color.RED); newStateCell.setAttributes(graph.getAttributes(newStateCell)); graph.repaint(); this.repaint(); graph.refresh(); } }
rec.setSize(new Dimension(length, height + 5)); GraphConstants.setBounds(m, rec); ((DefaultGraphCell)this.getCell()).setAttributes(m);
public void stateChanged(State<E> oldState, State<E> newState, double time) { if (oldStateDiagram) { this.repaint(); } else { int newIndex = indexOfStateInStateCells(newState); int oldIndex = indexOfStateInStateCells(oldState); GraphConstants.setBackground(graph.getAttributes(stateCells[oldIndex]), Color.CYAN); GraphConstants.setBackground(graph.getAttributes(stateCells[newIndex]), Color.RED); stateCells[oldIndex].setAttributes(graph.getAttributes(stateCells[oldIndex])); stateCells[newIndex].setAttributes(graph.getAttributes(stateCells[newIndex])); graph.repaint(); this.repaint(); graph.refresh(); } }
public void stateChanged(State<E> oldState, State<E> newState, double time) { if (oldStateDiagram) { this.repaint(); } else { int newIndex = indexOfStateInStateCells(newState); int oldIndex = indexOfStateInStateCells(oldState); GraphConstants.setBackground(graph.getAttributes(stateCells[oldIndex]), Color.CYAN); GraphConstants.setBackground(graph.getAttributes(stateCells[newIndex]), Color.RED); stateCells[oldIndex].setAttributes(graph.getAttributes(stateCells[oldIndex])); stateCells[newIndex].setAttributes(graph.getAttributes(stateCells[newIndex])); graph.repaint(); this.repaint(); graph.refresh(); } }
public void updateStateMachine() { State<E> currentState = stateMachine.getCurrentState(); if (oldStateDiagram) { this.repaint(); } else { int currentIndex = indexOfStateInStateCells(currentState); GraphConstants.setBackground(graph.getAttributes(stateCells[currentIndex]), Color.RED); stateCells[currentIndex].setAttributes(graph.getAttributes(stateCells[currentIndex])); for (int i = 0; i < stateCells.length; i++) { if (i != currentIndex) { GraphConstants.setBackground(graph.getAttributes(stateCells[i]), Color.CYAN); stateCells[i].setAttributes(graph.getAttributes(stateCells[i])); } } graph.repaint(); graph.refresh(); } }
public void updateStateMachine() { State<E> currentState = stateMachine.getCurrentState(); if (oldStateDiagram) { this.repaint(); } else { int currentIndex = indexOfStateInStateCells(currentState); GraphConstants.setBackground(graph.getAttributes(stateCells[currentIndex]), Color.RED); stateCells[currentIndex].setAttributes(graph.getAttributes(stateCells[currentIndex])); for (int i = 0; i < stateCells.length; i++) { if (i != currentIndex) { GraphConstants.setBackground(graph.getAttributes(stateCells[i]), Color.CYAN); stateCells[i].setAttributes(graph.getAttributes(stateCells[i])); } } graph.repaint(); graph.refresh(); } }