public abstract class SourceBase extends java.lang.Object implements Source
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.
Modifier and Type | Class and Description |
---|---|
static class |
SourceBase.ElementType |
Modifier and Type | Method and Description |
---|---|
void |
addAttributeSink(AttributeSink sink)
Add a sink for attribute events only.
|
void |
addElementSink(ElementSink sink)
Add a sink for elements events only.
|
void |
addSink(Sink sink)
Add a sink for all graph events (attributes and graph elements) coming from
this source.
|
java.lang.Iterable<AttributeSink> |
attributeSinks() |
void |
clearAttributeSinks()
Remove all listener attribute sinks.
|
void |
clearElementSinks()
Remove all listener element sinks.
|
void |
clearSinks()
Remove all listener sinks.
|
java.lang.Iterable<ElementSink> |
elementSinks() |
void |
removeAttributeSink(AttributeSink sink)
Remove an attribute sink.
|
void |
removeElementSink(ElementSink sink)
Remove an element sink.
|
void |
removeSink(Sink sink)
Remove a sink.
|
void |
sendAttributeChangedEvent(java.lang.String sourceId,
long timeId,
java.lang.String eltId,
SourceBase.ElementType eltType,
java.lang.String attribute,
AbstractElement.AttributeChangeEvent event,
java.lang.Object oldValue,
java.lang.Object newValue) |
void |
sendAttributeChangedEvent(java.lang.String sourceId,
java.lang.String eltId,
SourceBase.ElementType eltType,
java.lang.String attribute,
AbstractElement.AttributeChangeEvent event,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a add/change/remove attribute event on an element.
|
void |
sendEdgeAdded(java.lang.String sourceId,
long timeId,
java.lang.String edgeId,
java.lang.String fromNodeId,
java.lang.String toNodeId,
boolean directed)
Send an "edge added" event to all element sinks.
|
void |
sendEdgeAdded(java.lang.String sourceId,
java.lang.String edgeId,
java.lang.String fromNodeId,
java.lang.String toNodeId,
boolean directed)
Send an "edge added" event to all element sinks.
|
void |
sendEdgeAttributeAdded(java.lang.String sourceId,
long timeId,
java.lang.String edgeId,
java.lang.String attribute,
java.lang.Object value)
Send a "edge attribute added" event to all attribute sinks.
|
void |
sendEdgeAttributeAdded(java.lang.String sourceId,
java.lang.String edgeId,
java.lang.String attribute,
java.lang.Object value)
Send a "edge attribute added" event to all attribute sinks.
|
void |
sendEdgeAttributeChanged(java.lang.String sourceId,
long timeId,
java.lang.String edgeId,
java.lang.String attribute,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a "edge attribute changed" event to all attribute sinks.
|
void |
sendEdgeAttributeChanged(java.lang.String sourceId,
java.lang.String edgeId,
java.lang.String attribute,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a "edge attribute changed" event to all attribute sinks.
|
void |
sendEdgeAttributeRemoved(java.lang.String sourceId,
long timeId,
java.lang.String edgeId,
java.lang.String attribute)
Send a "edge attribute removed" event to all attribute sinks.
|
void |
sendEdgeAttributeRemoved(java.lang.String sourceId,
java.lang.String edgeId,
java.lang.String attribute)
Send a "edge attribute removed" event to all attribute sinks.
|
void |
sendEdgeRemoved(java.lang.String sourceId,
long timeId,
java.lang.String edgeId)
Send a "edge removed" event to all element sinks.
|
void |
sendEdgeRemoved(java.lang.String sourceId,
java.lang.String edgeId)
Send a "edge removed" event to all element sinks.
|
void |
sendGraphAttributeAdded(java.lang.String sourceId,
long timeId,
java.lang.String attribute,
java.lang.Object value)
Send a "graph attribute added" event to all attribute sinks.
|
void |
sendGraphAttributeAdded(java.lang.String sourceId,
java.lang.String attribute,
java.lang.Object value)
Send a "graph attribute added" event to all attribute sinks.
|
void |
sendGraphAttributeChanged(java.lang.String sourceId,
long timeId,
java.lang.String attribute,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a "graph attribute changed" event to all attribute sinks.
|
void |
sendGraphAttributeChanged(java.lang.String sourceId,
java.lang.String attribute,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a "graph attribute changed" event to all attribute sinks.
|
void |
sendGraphAttributeRemoved(java.lang.String sourceId,
long timeId,
java.lang.String attribute)
Send a "graph attribute removed" event to all attribute sinks.
|
void |
sendGraphAttributeRemoved(java.lang.String sourceId,
java.lang.String attribute)
Send a "graph attribute removed" event to all attribute sinks.
|
void |
sendGraphCleared(java.lang.String sourceId)
Send a "graph cleared" event to all element sinks.
|
void |
sendGraphCleared(java.lang.String sourceId,
long timeId)
Send a "graph cleared" event to all element sinks.
|
void |
sendNodeAdded(java.lang.String sourceId,
long timeId,
java.lang.String nodeId)
Send a "node added" event to all element sinks.
|
void |
sendNodeAdded(java.lang.String sourceId,
java.lang.String nodeId)
Send a "node added" event to all element sinks.
|
void |
sendNodeAttributeAdded(java.lang.String sourceId,
long timeId,
java.lang.String nodeId,
java.lang.String attribute,
java.lang.Object value)
Send a "node attribute added" event to all attribute sinks.
|
void |
sendNodeAttributeAdded(java.lang.String sourceId,
java.lang.String nodeId,
java.lang.String attribute,
java.lang.Object value)
Send a "node attribute added" event to all attribute sinks.
|
void |
sendNodeAttributeChanged(java.lang.String sourceId,
long timeId,
java.lang.String nodeId,
java.lang.String attribute,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a "node attribute changed" event to all attribute sinks.
|
void |
sendNodeAttributeChanged(java.lang.String sourceId,
java.lang.String nodeId,
java.lang.String attribute,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a "node attribute changed" event to all attribute sinks.
|
void |
sendNodeAttributeRemoved(java.lang.String sourceId,
long timeId,
java.lang.String nodeId,
java.lang.String attribute)
Send a "node attribute removed" event to all attribute sinks.
|
void |
sendNodeAttributeRemoved(java.lang.String sourceId,
java.lang.String nodeId,
java.lang.String attribute)
Send a "node attribute removed" event to all attribute sinks.
|
void |
sendNodeRemoved(java.lang.String sourceId,
long timeId,
java.lang.String nodeId)
Send a "node removed" event to all element sinks.
|
void |
sendNodeRemoved(java.lang.String sourceId,
java.lang.String nodeId)
Send a "node removed" event to all element sinks.
|
void |
sendStepBegins(java.lang.String sourceId,
double step)
Send a "step begins" event to all element sinks.
|
void |
sendStepBegins(java.lang.String sourceId,
long timeId,
double step)
Send a "step begins" event to all element sinks.
|
public java.lang.Iterable<AttributeSink> attributeSinks()
public java.lang.Iterable<ElementSink> elementSinks()
public void addSink(Sink sink)
Source
public void addAttributeSink(AttributeSink sink)
Source
addAttributeSink
in interface Source
sink
- The sink to register.public void addElementSink(ElementSink sink)
Source
addElementSink
in interface Source
sink
- The sink to register.public void clearSinks()
Source
clearSinks
in interface Source
public void clearElementSinks()
Source
clearElementSinks
in interface Source
public void clearAttributeSinks()
Source
clearAttributeSinks
in interface Source
public void removeSink(Sink sink)
Source
removeSink
in interface Source
sink
- The sink to remove, if it does not exist, this is ignored
silently.public void removeAttributeSink(AttributeSink sink)
Source
removeAttributeSink
in interface Source
sink
- The sink to remove, if it does not exist, this is ignored
silently.public void removeElementSink(ElementSink sink)
Source
removeElementSink
in interface Source
sink
- The sink to remove, if it does not exist, this is ignored
silently.public void sendGraphCleared(java.lang.String sourceId)
sourceId
- The source identifier.public void sendGraphCleared(java.lang.String sourceId, long timeId)
sourceId
- The source identifier.timeId
- public void sendStepBegins(java.lang.String sourceId, double step)
sourceId
- The graph identifier.step
- The step time stamp.public void sendStepBegins(java.lang.String sourceId, long timeId, double step)
sourceId
- The graph identifier.timeId
- step
- The step time stamp.public void sendNodeAdded(java.lang.String sourceId, java.lang.String nodeId)
sourceId
- The source identifier.nodeId
- The node identifier.public void sendNodeAdded(java.lang.String sourceId, long timeId, java.lang.String nodeId)
sourceId
- The source identifier.timeId
- nodeId
- The node identifier.public void sendNodeRemoved(java.lang.String sourceId, java.lang.String nodeId)
sourceId
- The graph identifier.nodeId
- The node identifier.public void sendNodeRemoved(java.lang.String sourceId, long timeId, java.lang.String nodeId)
sourceId
- The graph identifier.timeId
- nodeId
- The node identifier.public void sendEdgeAdded(java.lang.String sourceId, java.lang.String edgeId, java.lang.String fromNodeId, java.lang.String toNodeId, boolean directed)
sourceId
- The source identifier.edgeId
- The edge identifier.fromNodeId
- The edge start node.toNodeId
- The edge end node.directed
- Is the edge directed?.public void sendEdgeAdded(java.lang.String sourceId, long timeId, java.lang.String edgeId, java.lang.String fromNodeId, java.lang.String toNodeId, boolean directed)
sourceId
- The source identifier.timeId
- edgeId
- The edge identifier.fromNodeId
- The edge start node.toNodeId
- The edge end node.directed
- Is the edge directed?.public void sendEdgeRemoved(java.lang.String sourceId, java.lang.String edgeId)
sourceId
- The source identifier.edgeId
- The edge identifier.public void sendEdgeRemoved(java.lang.String sourceId, long timeId, java.lang.String edgeId)
sourceId
- The source identifier.timeId
- edgeId
- The edge identifier.public void sendEdgeAttributeAdded(java.lang.String sourceId, java.lang.String edgeId, java.lang.String attribute, java.lang.Object value)
sourceId
- The source identifier.edgeId
- The edge identifier.attribute
- The attribute name.value
- The attribute value.public void sendEdgeAttributeAdded(java.lang.String sourceId, long timeId, java.lang.String edgeId, java.lang.String attribute, java.lang.Object value)
sourceId
- The source identifier.timeId
- edgeId
- The edge identifier.attribute
- The attribute name.value
- The attribute value.public void sendEdgeAttributeChanged(java.lang.String sourceId, java.lang.String edgeId, java.lang.String attribute, java.lang.Object oldValue, java.lang.Object newValue)
sourceId
- The source identifier.edgeId
- The edge identifier.attribute
- The attribute name.oldValue
- The old attribute value.newValue
- The new attribute value.public void sendEdgeAttributeChanged(java.lang.String sourceId, long timeId, java.lang.String edgeId, java.lang.String attribute, java.lang.Object oldValue, java.lang.Object newValue)
sourceId
- The source identifier.timeId
- edgeId
- The edge identifier.attribute
- The attribute name.oldValue
- The old attribute value.newValue
- The new attribute value.public void sendEdgeAttributeRemoved(java.lang.String sourceId, java.lang.String edgeId, java.lang.String attribute)
sourceId
- The source identifier.edgeId
- The edge identifier.attribute
- The attribute name.public void sendEdgeAttributeRemoved(java.lang.String sourceId, long timeId, java.lang.String edgeId, java.lang.String attribute)
sourceId
- The source identifier.timeId
- edgeId
- The edge identifier.attribute
- The attribute name.public void sendGraphAttributeAdded(java.lang.String sourceId, java.lang.String attribute, java.lang.Object value)
sourceId
- The source identifier.attribute
- The attribute name.value
- The attribute value.public void sendGraphAttributeAdded(java.lang.String sourceId, long timeId, java.lang.String attribute, java.lang.Object value)
sourceId
- The source identifier.timeId
- attribute
- The attribute name.value
- The attribute value.public void sendGraphAttributeChanged(java.lang.String sourceId, java.lang.String attribute, java.lang.Object oldValue, java.lang.Object newValue)
sourceId
- The source identifier.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void sendGraphAttributeChanged(java.lang.String sourceId, long timeId, java.lang.String attribute, java.lang.Object oldValue, java.lang.Object newValue)
sourceId
- The source identifier.timeId
- attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void sendGraphAttributeRemoved(java.lang.String sourceId, java.lang.String attribute)
sourceId
- The source identifier.attribute
- The attribute name.public void sendGraphAttributeRemoved(java.lang.String sourceId, long timeId, java.lang.String attribute)
sourceId
- The source identifier.timeId
- attribute
- The attribute name.public void sendNodeAttributeAdded(java.lang.String sourceId, java.lang.String nodeId, java.lang.String attribute, java.lang.Object value)
sourceId
- The source identifier.nodeId
- The node identifier.attribute
- The attribute name.value
- The attribute value.public void sendNodeAttributeAdded(java.lang.String sourceId, long timeId, java.lang.String nodeId, java.lang.String attribute, java.lang.Object value)
sourceId
- The source identifier.timeId
- nodeId
- The node identifier.attribute
- The attribute name.value
- The attribute value.public void sendNodeAttributeChanged(java.lang.String sourceId, java.lang.String nodeId, java.lang.String attribute, java.lang.Object oldValue, java.lang.Object newValue)
sourceId
- The source identifier.nodeId
- The node identifier.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void sendNodeAttributeChanged(java.lang.String sourceId, long timeId, java.lang.String nodeId, java.lang.String attribute, java.lang.Object oldValue, java.lang.Object newValue)
sourceId
- The source identifier.timeId
- nodeId
- The node identifier.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void sendNodeAttributeRemoved(java.lang.String sourceId, java.lang.String nodeId, java.lang.String attribute)
sourceId
- The source identifier.nodeId
- The node identifier.attribute
- The attribute name.public void sendNodeAttributeRemoved(java.lang.String sourceId, long timeId, java.lang.String nodeId, java.lang.String attribute)
sourceId
- The source identifier.timeId
- nodeId
- The node identifier.attribute
- The attribute name.public void sendAttributeChangedEvent(java.lang.String sourceId, java.lang.String eltId, SourceBase.ElementType eltType, java.lang.String attribute, AbstractElement.AttributeChangeEvent event, java.lang.Object oldValue, java.lang.Object newValue)
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).public void sendAttributeChangedEvent(java.lang.String sourceId, long timeId, java.lang.String eltId, SourceBase.ElementType eltType, java.lang.String attribute, AbstractElement.AttributeChangeEvent event, java.lang.Object oldValue, java.lang.Object newValue)