Package casa.lepton
Class OppNode
java.lang.Object
org.graphstream.graph.implementations.AbstractElement
org.graphstream.graph.implementations.AbstractNode
org.graphstream.graph.implementations.AdjacencyListNode
org.graphstream.graph.implementations.MultiNode
casa.lepton.OppNode
- All Implemented Interfaces:
Iterable<org.graphstream.graph.Edge>
,org.graphstream.graph.Element
,org.graphstream.graph.Node
public class OppNode
extends org.graphstream.graph.implementations.MultiNode
A
Node
representing a device in an
opprotunistic network. The device has a location, can be on/offline, and has
several connectivity types. For each connectivity type, it can have edges
with other nodes that are within a range defined for this connectivity type.-
Nested Class Summary
Nested classes/interfaces inherited from class org.graphstream.graph.implementations.AdjacencyListNode
org.graphstream.graph.implementations.AdjacencyListNode.EdgeIterator<T extends org.graphstream.graph.Edge>
Nested classes/interfaces inherited from class org.graphstream.graph.implementations.AbstractElement
org.graphstream.graph.implementations.AbstractElement.AttributeChangeEvent
-
Field Summary
Fields inherited from class org.graphstream.graph.implementations.MultiNode
neighborMap
Fields inherited from class org.graphstream.graph.implementations.AdjacencyListNode
degree, edges, GROWTH_FACTOR, I_EDGE, INITIAL_EDGE_CAPACITY, IO_EDGE, ioStart, O_EDGE, oStart
Fields inherited from class org.graphstream.graph.implementations.AbstractNode
graph
Fields inherited from class org.graphstream.graph.implementations.AbstractElement
attributes, attributesBeingRemoved, id
-
Constructor Summary
ConstructorDescriptionOppNode
(OppNetGraph graph, String id, String profile, OppNodeProperties props, String label, Walker walker) Construct a new node.OppNode
(OppNetGraph graph, String id, String profile, OppNodeProperties props, String label, casa.util.geom.CoordCar coord) Construct a new node. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addConnectivityType
(String connectivityType) Add a new enabled connectivity type.protected void
attributeChanged
(org.graphstream.graph.implementations.AbstractElement.AttributeChangeEvent event, String attribute, Object oldValue, Object newValue) Return the device's enabled connectivity types.casa.util.geom.CoordCar
getCoord()
Give the device location.getGraph()
getLabel()
getNeighbors
(String connectivityType, String edgeStatus) Give all the node's neighbors for a given connectivity type and a given status.Return the node's status for a given connectivity type.getTag()
boolean
hasConnectivityType
(String connectivityType) Return true if the device has the given connectivity type.void
init()
Attributes initializations.boolean
isMobile()
boolean
isNeighbor
(OppNode node, String connectivityType, String edgeStatus) Returns true if there is an edge with the node for the given connectivity type and status.boolean
isOnline()
Give the on/offline status of the device.boolean
isTagged()
boolean
removeConnectivityType
(String connectivityType) Disable a connectivity type.void
setCoord
(casa.util.geom.CoordCar coord) Change the coord attribute.final void
final void
setMobile
(boolean mobile) final boolean
setOnline
(boolean online) Change the on/offline status of the device.boolean
Update the status of the node for a given type.final void
toDGS()
Gives a string representation of the node to be printed to a DGS output.toString()
boolean
walk
(long time) Change the device's location and update its edges distances usingOppEdge.updateDistance()
.Methods inherited from class org.graphstream.graph.implementations.MultiNode
addEdgeCallback, clearCallback, getEdgeSetBetween, getEdgeSetBetween, getEdgeSetBetween, getNeighborNodeIterator, locateEdge, removeEdge
Methods inherited from class org.graphstream.graph.implementations.AdjacencyListNode
edgeType, getDegree, getEdge, getEdgeBetween, getEdgeFrom, getEdgeIterator, getEdgeToward, getEnteringEdge, getEnteringEdgeIterator, getInDegree, getLeavingEdge, getLeavingEdgeIterator, getOutDegree, removeEdgeCallback
Methods inherited from class org.graphstream.graph.implementations.AbstractNode
getBreadthFirstIterator, getBreadthFirstIterator, getDepthFirstIterator, getDepthFirstIterator, getEachEdge, getEachEnteringEdge, getEachLeavingEdge, getEdgeBetween, getEdgeBetween, getEdgeFrom, getEdgeFrom, getEdgeSet, getEdgeToward, getEdgeToward, getEnteringEdgeSet, getLeavingEdgeSet, hasEdgeBetween, hasEdgeBetween, hasEdgeBetween, hasEdgeFrom, hasEdgeFrom, hasEdgeFrom, hasEdgeToward, hasEdgeToward, hasEdgeToward, isEnteringEdge, isIncidentEdge, isLeavingEdge, iterator, nullAttributesAreErrors
Methods inherited from class org.graphstream.graph.implementations.AbstractElement
addAttribute, addAttributes, changeAttribute, clearAttributes, clearAttributesWithNoEvent, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute, setIndex
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.graphstream.graph.Element
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
OppNode
public OppNode(OppNetGraph graph, String id, String profile, OppNodeProperties props, String label, Walker walker) Construct a new node.- Parameters:
graph
- the graph representing the network.id
- the node id (unique).profile
- the profile nameprops
- the propertieswalker
- the walker that implements the node mobility
-
OppNode
public OppNode(OppNetGraph graph, String id, String profile, OppNodeProperties props, String label, casa.util.geom.CoordCar coord) Construct a new node.- Parameters:
graph
- the graph representing the network.id
- the node id (unique).profile
- the profile nameprops
- the propertiescoord
- the node initial location
-
-
Method Details
-
init
public void init()Attributes initializations. Must be invoked afterOppNetGraph.addNode(java.lang.String, java.lang.String)
-
toDGS
Gives a string representation of the node to be printed to a DGS output.- Returns:
- DGS sring representation of the node
-
getLabel
-
setLabel
-
toString
- Specified by:
toString
in interfaceorg.graphstream.graph.Node
- Overrides:
toString
in classorg.graphstream.graph.implementations.AbstractElement
-
isTagged
public boolean isTagged() -
getTag
-
setTag
-
setMobile
public final void setMobile(boolean mobile) -
isMobile
public boolean isMobile() -
getNeighbors
Give all the node's neighbors for a given connectivity type and a given status. If connectivityType is null, give all neighbors for any connectivity type. If status is null, give all neighbors for any status.- Parameters:
connectivityType
- the connectivity type (may be null).edgeStatus
- the status (may be null).- Returns:
- neighbors
-
isNeighbor
Returns true if there is an edge with the node for the given connectivity type and status. If connectivityType is null, return true if there is an edge for any connectivity type. If status is null, give all neighbors for any status.- Parameters:
node
- a node.connectivityType
- the connectivity type (may be null).edgeStatus
- the status (may be null).- Returns:
- true if the given node is a neighbor
-
setOnline
public final boolean setOnline(boolean online) Change the on/offline status of the device.- Parameters:
online
- the new status value.- Returns:
- true if the status has changed.
-
addConnectivityType
Add a new enabled connectivity type.- Parameters:
connectivityType
- the new connectivity type.- Returns:
- true if the types have changed.
-
removeConnectivityType
Disable a connectivity type.- Parameters:
connectivityType
- the connectivity type.- Returns:
- true if the types have changed.
-
walk
public boolean walk(long time) Change the device's location and update its edges distances usingOppEdge.updateDistance()
.- Parameters:
time
- the time when the device's location must be changed.- Returns:
- true if the device's location has changed.
-
setCoord
public void setCoord(casa.util.geom.CoordCar coord) Change the coord attribute.- Parameters:
coord
- the new coord attribute.
-
setStatus
Update the status of the node for a given type.- Parameters:
connectivityType
- the connectivity type.status
- the new status.- Returns:
- true if the status has been changed.
-
isOnline
public boolean isOnline()Give the on/offline status of the device.- Returns:
- true if the status is online.
-
hasConnectivityType
Return true if the device has the given connectivity type.- Parameters:
connectivityType
- a connectivity type- Returns:
- true if the device has the given connectivity type.
-
getConnectivityTypes
Return the device's enabled connectivity types.- Returns:
- a collection of the device's enabled connectivity types.
-
getCoord
public casa.util.geom.CoordCar getCoord()Give the device location.- Returns:
- the device location.
-
getStatus
Return the node's status for a given connectivity type.- Parameters:
connectivityType
- a connectivity type- Returns:
- the node's status for this connectivity type.
-
getGraph
- Specified by:
getGraph
in interfaceorg.graphstream.graph.Node
- Overrides:
getGraph
in classorg.graphstream.graph.implementations.AbstractNode
-
attributeChanged
protected void attributeChanged(org.graphstream.graph.implementations.AbstractElement.AttributeChangeEvent event, String attribute, Object oldValue, Object newValue) - Overrides:
attributeChanged
in classorg.graphstream.graph.implementations.AbstractNode
-