@Override public void removeNode(Point node) { // collect data of removed connections but only if there is a listener final List<Connection<?>> removedConnections = newArrayList(); if (eventDispatcher.hasListenerFor(EventTypes.REMOVE_CONNECTION)) { for (final Point p : delegate.getIncomingConnections(node)) { removedConnections.add(delegate.getConnection(p, node)); } for (final Point p : delegate.getOutgoingConnections(node)) { removedConnections.add(delegate.getConnection(node, p)); } } delegate.removeNode(node); // notify listeners for (final Connection<?> c : removedConnections) { eventDispatcher.dispatchEvent(new GraphEvent( EventTypes.REMOVE_CONNECTION, this, c)); } }
@Override public void removeNode(Point node) { // collect data of removed connections but only if there is a listener final List<Connection<?>> removedConnections = newArrayList(); if (eventDispatcher.hasListenerFor(EventTypes.REMOVE_CONNECTION)) { for (final Point p : delegate.getIncomingConnections(node)) { removedConnections.add(delegate.getConnection(p, node)); } for (final Point p : delegate.getOutgoingConnections(node)) { removedConnections.add(delegate.getConnection(node, p)); } } delegate.removeNode(node); // notify listeners for (final Connection<?> c : removedConnections) { eventDispatcher.dispatchEvent(new GraphEvent( EventTypes.REMOVE_CONNECTION, this, c)); } }
new GraphEvent(ADD_CONNECTION, graph1, Connection.create(a, c, Optional.<ConnectionData>absent())), history .getHistory().get(0)); assertEquals( new GraphEvent(ADD_CONNECTION, graph1, Connection.create(c, a, Optional.<ConnectionData>absent())), history
@Override public Optional<E> setConnectionData(Point from, Point to, E connectionData) { final Optional<E> val = delegate.setConnectionData(from, to, connectionData); eventDispatcher.dispatchEvent(new GraphEvent( EventTypes.CHANGE_CONNECTION_DATA, this, getConnection(from, to))); return val; }
@Override public void removeConnection(Point from, Point to) { final Connection<?> conn = delegate.getConnection(from, to); delegate.removeConnection(from, to); eventDispatcher .dispatchEvent(new GraphEvent( EventTypes.REMOVE_CONNECTION, this, conn)); }
@Override public void addConnection(Point from, Point to, E connData) { delegate.addConnection(from, to, connData); eventDispatcher.dispatchEvent(new GraphEvent(EventTypes.ADD_CONNECTION, this, getConnection(from, to))); }
@Override public void addConnection(Connection<E> connection) { delegate.addConnection(connection); eventDispatcher.dispatchEvent(new GraphEvent(EventTypes.ADD_CONNECTION, this, connection)); }
@Override public void addConnection(Point from, Point to) { delegate.addConnection(from, to); eventDispatcher.dispatchEvent(new GraphEvent(EventTypes.ADD_CONNECTION, this, getConnection(from, to))); }
@Override public void removeConnection(Point from, Point to) { final Connection<?> conn = delegate.getConnection(from, to); delegate.removeConnection(from, to); eventDispatcher .dispatchEvent(new GraphEvent( EventTypes.REMOVE_CONNECTION, this, conn)); }
@Override public Optional<E> removeConnectionData(Point from, Point to) { final Optional<E> val = delegate.removeConnectionData(from, to); eventDispatcher.dispatchEvent(new GraphEvent( EventTypes.CHANGE_CONNECTION_DATA, this, getConnection(from, to))); return val; }
@Override public void addConnection(Point from, Point to) { delegate.addConnection(from, to); eventDispatcher.dispatchEvent(new GraphEvent(EventTypes.ADD_CONNECTION, this, getConnection(from, to))); }
@Override public Optional<E> setConnectionData(Point from, Point to, E connectionData) { final Optional<E> val = delegate.setConnectionData(from, to, connectionData); eventDispatcher.dispatchEvent(new GraphEvent( EventTypes.CHANGE_CONNECTION_DATA, this, getConnection(from, to))); return val; }
@Override public void addConnection(Point from, Point to, E connData) { delegate.addConnection(from, to, connData); eventDispatcher.dispatchEvent(new GraphEvent(EventTypes.ADD_CONNECTION, this, getConnection(from, to))); }
@Override public Optional<E> removeConnectionData(Point from, Point to) { final Optional<E> val = delegate.removeConnectionData(from, to); eventDispatcher.dispatchEvent(new GraphEvent( EventTypes.CHANGE_CONNECTION_DATA, this, getConnection(from, to))); return val; }
@Override public void addConnection(Connection<E> connection) { delegate.addConnection(connection); eventDispatcher.dispatchEvent(new GraphEvent(EventTypes.ADD_CONNECTION, this, connection)); }