Package org.graphstream.stream
Class SourceBase
java.lang.Object
org.graphstream.stream.SourceBase
- All Implemented Interfaces:
Source
- Direct Known Subclasses:
BarnesHutLayout,ByteProxy,FileSourceBase,FileSourceParser,FileSourceXML,GraphListeners,GraphReplay,NetStreamDecoder,PipeBase,ThreadProxyPipe,ViewerPipe
public abstract class SourceBase extends Object implements Source
Base implementation of an input that provide basic sink handling.
This implementation can register a set of graph sinks (or separate sets of attributes or elements sinks) and provides protected methods to easily broadcast events to all the sinks (beginning with "send").
Each time you want to produce an event toward all registered sinks, you call one of the "send*" methods with correct parameters. The parameters of the "send*" methods maps to the usual GraphStream events.
This class is "reentrant". This means that if a send*() method is called during the execution of another or the same send*() method, the event is deferred until the first send*() method is finished. This avoid recursive loops if a sink modifies the input during event handling.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSourceBase.ElementType -
Method Summary
Modifier and Type Method Description voidaddAttributeSink(AttributeSink sink)Add a sink for attribute events only.voidaddElementSink(ElementSink sink)Add a sink for elements events only.voidaddSink(Sink sink)Add a sink for all graph events (attributes and graph elements) coming from this source.Iterable<AttributeSink>attributeSinks()voidclearAttributeSinks()Remove all listener attribute sinks.voidclearElementSinks()Remove all listener element sinks.voidclearSinks()Remove all listener sinks.Iterable<ElementSink>elementSinks()voidremoveAttributeSink(AttributeSink sink)Remove an attribute sink.voidremoveElementSink(ElementSink sink)Remove an element sink.voidremoveSink(Sink sink)Remove a sink.voidsendAttributeChangedEvent(String sourceId, long timeId, String eltId, SourceBase.ElementType eltType, String attribute, AbstractElement.AttributeChangeEvent event, Object oldValue, Object newValue)voidsendAttributeChangedEvent(String sourceId, String eltId, SourceBase.ElementType eltType, String attribute, AbstractElement.AttributeChangeEvent event, Object oldValue, Object newValue)Send a add/change/remove attribute event on an element.voidsendEdgeAdded(String sourceId, long timeId, String edgeId, String fromNodeId, String toNodeId, boolean directed)Send an "edge added" event to all element sinks.voidsendEdgeAdded(String sourceId, String edgeId, String fromNodeId, String toNodeId, boolean directed)Send an "edge added" event to all element sinks.voidsendEdgeAttributeAdded(String sourceId, long timeId, String edgeId, String attribute, Object value)Send a "edge attribute added" event to all attribute sinks.voidsendEdgeAttributeAdded(String sourceId, String edgeId, String attribute, Object value)Send a "edge attribute added" event to all attribute sinks.voidsendEdgeAttributeChanged(String sourceId, long timeId, String edgeId, String attribute, Object oldValue, Object newValue)Send a "edge attribute changed" event to all attribute sinks.voidsendEdgeAttributeChanged(String sourceId, String edgeId, String attribute, Object oldValue, Object newValue)Send a "edge attribute changed" event to all attribute sinks.voidsendEdgeAttributeRemoved(String sourceId, long timeId, String edgeId, String attribute)Send a "edge attribute removed" event to all attribute sinks.voidsendEdgeAttributeRemoved(String sourceId, String edgeId, String attribute)Send a "edge attribute removed" event to all attribute sinks.voidsendEdgeRemoved(String sourceId, long timeId, String edgeId)Send a "edge removed" event to all element sinks.voidsendEdgeRemoved(String sourceId, String edgeId)Send a "edge removed" event to all element sinks.voidsendGraphAttributeAdded(String sourceId, long timeId, String attribute, Object value)Send a "graph attribute added" event to all attribute sinks.voidsendGraphAttributeAdded(String sourceId, String attribute, Object value)Send a "graph attribute added" event to all attribute sinks.voidsendGraphAttributeChanged(String sourceId, long timeId, String attribute, Object oldValue, Object newValue)Send a "graph attribute changed" event to all attribute sinks.voidsendGraphAttributeChanged(String sourceId, String attribute, Object oldValue, Object newValue)Send a "graph attribute changed" event to all attribute sinks.voidsendGraphAttributeRemoved(String sourceId, long timeId, String attribute)Send a "graph attribute removed" event to all attribute sinks.voidsendGraphAttributeRemoved(String sourceId, String attribute)Send a "graph attribute removed" event to all attribute sinks.voidsendGraphCleared(String sourceId)Send a "graph cleared" event to all element sinks.voidsendGraphCleared(String sourceId, long timeId)Send a "graph cleared" event to all element sinks.voidsendNodeAdded(String sourceId, long timeId, String nodeId)Send a "node added" event to all element sinks.voidsendNodeAdded(String sourceId, String nodeId)Send a "node added" event to all element sinks.voidsendNodeAttributeAdded(String sourceId, long timeId, String nodeId, String attribute, Object value)Send a "node attribute added" event to all attribute sinks.voidsendNodeAttributeAdded(String sourceId, String nodeId, String attribute, Object value)Send a "node attribute added" event to all attribute sinks.voidsendNodeAttributeChanged(String sourceId, long timeId, String nodeId, String attribute, Object oldValue, Object newValue)Send a "node attribute changed" event to all attribute sinks.voidsendNodeAttributeChanged(String sourceId, String nodeId, String attribute, Object oldValue, Object newValue)Send a "node attribute changed" event to all attribute sinks.voidsendNodeAttributeRemoved(String sourceId, long timeId, String nodeId, String attribute)Send a "node attribute removed" event to all attribute sinks.voidsendNodeAttributeRemoved(String sourceId, String nodeId, String attribute)Send a "node attribute removed" event to all attribute sinks.voidsendNodeRemoved(String sourceId, long timeId, String nodeId)Send a "node removed" event to all element sinks.voidsendNodeRemoved(String sourceId, String nodeId)Send a "node removed" event to all element sinks.voidsendStepBegins(String sourceId, double step)Send a "step begins" event to all element sinks.voidsendStepBegins(String sourceId, long timeId, double step)Send a "step begins" event to all element sinks.
-
Method Details
-
attributeSinks
-
elementSinks
-
addSink
Description copied from interface:SourceAdd a sink for all graph events (attributes and graph elements) coming from this source. This is similar to registering a sink for attributes an another for elements. -
addAttributeSink
Description copied from interface:SourceAdd a sink for attribute events only. Attribute events include attribute addition change and removal.- Specified by:
addAttributeSinkin interfaceSource- Parameters:
sink- The sink to register.
-
addElementSink
Description copied from interface:SourceAdd a sink for elements events only. Elements events include, addition and removal of nodes and edges, as well as step events.- Specified by:
addElementSinkin interfaceSource- Parameters:
sink- The sink to register.
-
clearSinks
public void clearSinks()Description copied from interface:SourceRemove all listener sinks.- Specified by:
clearSinksin interfaceSource
-
clearElementSinks
public void clearElementSinks()Description copied from interface:SourceRemove all listener element sinks.- Specified by:
clearElementSinksin interfaceSource
-
clearAttributeSinks
public void clearAttributeSinks()Description copied from interface:SourceRemove all listener attribute sinks.- Specified by:
clearAttributeSinksin interfaceSource
-
removeSink
Description copied from interface:SourceRemove a sink.- Specified by:
removeSinkin interfaceSource- Parameters:
sink- The sink to remove, if it does not exist, this is ignored silently.
-
removeAttributeSink
Description copied from interface:SourceRemove an attribute sink.- Specified by:
removeAttributeSinkin interfaceSource- Parameters:
sink- The sink to remove, if it does not exist, this is ignored silently.
-
removeElementSink
Description copied from interface:SourceRemove an element sink.- Specified by:
removeElementSinkin interfaceSource- Parameters:
sink- The sink to remove, if it does not exist, this is ignored silently.
-
sendGraphCleared
Send a "graph cleared" event to all element sinks.- Parameters:
sourceId- The source identifier.
-
sendGraphCleared
Send a "graph cleared" event to all element sinks.- Parameters:
sourceId- The source identifier.timeId-
-
sendStepBegins
Send a "step begins" event to all element sinks.- Parameters:
sourceId- The graph identifier.step- The step time stamp.
-
sendStepBegins
Send a "step begins" event to all element sinks.- Parameters:
sourceId- The graph identifier.timeId-step- The step time stamp.
-
sendNodeAdded
Send a "node added" event to all element sinks.- Parameters:
sourceId- The source identifier.nodeId- The node identifier.
-
sendNodeAdded
Send a "node added" event to all element sinks.- Parameters:
sourceId- The source identifier.timeId-nodeId- The node identifier.
-
sendNodeRemoved
Send a "node removed" event to all element sinks.- Parameters:
sourceId- The graph identifier.nodeId- The node identifier.
-
sendNodeRemoved
Send a "node removed" event to all element sinks.- Parameters:
sourceId- The graph identifier.timeId-nodeId- The node identifier.
-
sendEdgeAdded
public void sendEdgeAdded(String sourceId, String edgeId, String fromNodeId, String toNodeId, boolean directed)Send an "edge added" event to all element sinks.- Parameters:
sourceId- The source identifier.edgeId- The edge identifier.fromNodeId- The edge start node.toNodeId- The edge end node.directed- Is the edge directed?.
-
sendEdgeAdded
public void sendEdgeAdded(String sourceId, long timeId, String edgeId, String fromNodeId, String toNodeId, boolean directed)Send an "edge added" event to all element sinks.- Parameters:
sourceId- The source identifier.timeId-edgeId- The edge identifier.fromNodeId- The edge start node.toNodeId- The edge end node.directed- Is the edge directed?.
-
sendEdgeRemoved
Send a "edge removed" event to all element sinks.- Parameters:
sourceId- The source identifier.edgeId- The edge identifier.
-
sendEdgeRemoved
Send a "edge removed" event to all element sinks.- Parameters:
sourceId- The source identifier.timeId-edgeId- The edge identifier.
-
sendEdgeAttributeAdded
Send a "edge attribute added" event to all attribute sinks.- Parameters:
sourceId- The source identifier.edgeId- The edge identifier.attribute- The attribute name.value- The attribute value.
-
sendEdgeAttributeAdded
public void sendEdgeAttributeAdded(String sourceId, long timeId, String edgeId, String attribute, Object value)Send a "edge attribute added" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-edgeId- The edge identifier.attribute- The attribute name.value- The attribute value.
-
sendEdgeAttributeChanged
public void sendEdgeAttributeChanged(String sourceId, String edgeId, String attribute, Object oldValue, Object newValue)Send a "edge attribute changed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.edgeId- The edge identifier.attribute- The attribute name.oldValue- The old attribute value.newValue- The new attribute value.
-
sendEdgeAttributeChanged
public void sendEdgeAttributeChanged(String sourceId, long timeId, String edgeId, String attribute, Object oldValue, Object newValue)Send a "edge attribute changed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-edgeId- The edge identifier.attribute- The attribute name.oldValue- The old attribute value.newValue- The new attribute value.
-
sendEdgeAttributeRemoved
Send a "edge attribute removed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.edgeId- The edge identifier.attribute- The attribute name.
-
sendEdgeAttributeRemoved
public void sendEdgeAttributeRemoved(String sourceId, long timeId, String edgeId, String attribute)Send a "edge attribute removed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-edgeId- The edge identifier.attribute- The attribute name.
-
sendGraphAttributeAdded
Send a "graph attribute added" event to all attribute sinks.- Parameters:
sourceId- The source identifier.attribute- The attribute name.value- The attribute value.
-
sendGraphAttributeAdded
Send a "graph attribute added" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-attribute- The attribute name.value- The attribute value.
-
sendGraphAttributeChanged
public void sendGraphAttributeChanged(String sourceId, String attribute, Object oldValue, Object newValue)Send a "graph attribute changed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.attribute- The attribute name.oldValue- The attribute old value.newValue- The attribute new value.
-
sendGraphAttributeChanged
public void sendGraphAttributeChanged(String sourceId, long timeId, String attribute, Object oldValue, Object newValue)Send a "graph attribute changed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-attribute- The attribute name.oldValue- The attribute old value.newValue- The attribute new value.
-
sendGraphAttributeRemoved
Send a "graph attribute removed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.attribute- The attribute name.
-
sendGraphAttributeRemoved
Send a "graph attribute removed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-attribute- The attribute name.
-
sendNodeAttributeAdded
Send a "node attribute added" event to all attribute sinks.- Parameters:
sourceId- The source identifier.nodeId- The node identifier.attribute- The attribute name.value- The attribute value.
-
sendNodeAttributeAdded
public void sendNodeAttributeAdded(String sourceId, long timeId, String nodeId, String attribute, Object value)Send a "node attribute added" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-nodeId- The node identifier.attribute- The attribute name.value- The attribute value.
-
sendNodeAttributeChanged
public void sendNodeAttributeChanged(String sourceId, String nodeId, String attribute, Object oldValue, Object newValue)Send a "node attribute changed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.nodeId- The node identifier.attribute- The attribute name.oldValue- The attribute old value.newValue- The attribute new value.
-
sendNodeAttributeChanged
public void sendNodeAttributeChanged(String sourceId, long timeId, String nodeId, String attribute, Object oldValue, Object newValue)Send a "node attribute changed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-nodeId- The node identifier.attribute- The attribute name.oldValue- The attribute old value.newValue- The attribute new value.
-
sendNodeAttributeRemoved
Send a "node attribute removed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.nodeId- The node identifier.attribute- The attribute name.
-
sendNodeAttributeRemoved
public void sendNodeAttributeRemoved(String sourceId, long timeId, String nodeId, String attribute)Send a "node attribute removed" event to all attribute sinks.- Parameters:
sourceId- The source identifier.timeId-nodeId- The node identifier.attribute- The attribute name.
-
sendAttributeChangedEvent
public void sendAttributeChangedEvent(String sourceId, String eltId, SourceBase.ElementType eltType, String attribute, AbstractElement.AttributeChangeEvent event, Object oldValue, Object newValue)Send a add/change/remove attribute event on an element. This method is a generic way of notifying of an attribute change and is equivalent to individual send*Attribute*() methods.- Parameters:
sourceId- The source identifier.eltId- The changed element identifier.eltType- The changed element type.attribute- The changed attribute.event- The add/change/remove action.oldValue- The old attribute value (null if the attribute is removed or added).newValue- The new attribute value (null if removed).
-
sendAttributeChangedEvent
public void sendAttributeChangedEvent(String sourceId, long timeId, String eltId, SourceBase.ElementType eltType, String attribute, AbstractElement.AttributeChangeEvent event, Object oldValue, Object newValue)
-