|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.memphis.ccrg.lida.framework.shared.NodeStructureImpl
public class NodeStructureImpl
Default implementation of NodeStructure
. The source and sink of a
link must be present before it can be added. Links can connect two nodes
(simple link) or can connect a node and another SIMPLE link. Nodes and links
are copied when added. This prevents having the same node (object) in two
different NS.
ExtendedId
,
Serialized FormConstructor Summary | |
---|---|
NodeStructureImpl()
Default constructor. |
|
NodeStructureImpl(NodeStructure original)
Copy constructor. |
|
NodeStructureImpl(java.lang.String nodeType,
java.lang.String linkType)
Creates a new NodeStructureImpl with specified default Node type and link Type. |
Method Summary | |
---|---|
Link |
addDefaultLink(int sourceId,
ExtendedId sinkId,
LinkCategory category,
double activation,
double removalThreshold)
Creates and adds a new Link with specified attributes. |
Link |
addDefaultLink(int sourceId,
int sinkId,
LinkCategory category,
double activation,
double removalThreshold)
Creates and adds a new Link with specified attributes. |
Link |
addDefaultLink(Link l)
Copies specified Link and then adds the copy to this NodeStructure. |
Link |
addDefaultLink(Node source,
Linkable sink,
LinkCategory category,
double activation,
double removalThreshold)
|
java.util.Collection<Link> |
addDefaultLinks(java.util.Collection<Link> links)
Copies specified Links and then adds the copies to this NodeStructure. |
Node |
addDefaultNode(Node n)
Adds a COPY of specified Node to this NodeStructure. |
java.util.Collection<Node> |
addDefaultNodes(java.util.Collection<Node> nodes)
|
Link |
addLink(Link l,
java.lang.String linkType)
Adds copy of specified Link. |
protected Node |
addNode(Node n,
boolean copy)
If copy is false, this method adds a already generated Node
to this NodeStructure without copying it. |
Node |
addNode(Node n,
java.lang.String nodeType)
Add a Node of a specified factory type to this NodeStructure |
void |
clearLinks()
Removes all links from this NodeStructure |
void |
clearNodeStructure()
Removes all nodes and links from this nodestructure |
static boolean |
compareNodeStructures(NodeStructure ns1,
NodeStructure ns2)
Returns true if two NodeStructures are meaningfully equal, else false. |
boolean |
containsLink(ExtendedId id)
Returns whether this NodeStructure contains Link with specified ExtendedId . |
boolean |
containsLink(Link l)
Returns whether this NodeStructure contains specified Link. |
boolean |
containsLinkable(ExtendedId id)
Returns whether this NodeStructure contains Linkable with specified ExtendedId . |
boolean |
containsLinkable(Linkable l)
Returns whether this NodeStructure contains specified Linkable . |
boolean |
containsNode(ExtendedId id)
Returns whether this NodeStructure contains Node with specified ExtendedId. |
boolean |
containsNode(int id)
Returns whether this NodeStructure contains Node with specified id. |
boolean |
containsNode(Node n)
Returns whether this NodeStructure contains specified Node. |
NodeStructure |
copy()
Returns a deep copy of this NodeStructure |
void |
decayNodeStructure(long ticks)
Decays the Linkable s of this NodeStructure . |
java.util.Set<Link> |
getAttachedLinks(Linkable linkable)
Gets all Link s directly connected to specified Linkable. |
java.util.Set<Link> |
getAttachedLinks(Linkable linkable,
LinkCategory category)
Gets all Link s directly connected to specified Linkable with specified LinkCategory |
java.util.Map<Linkable,Link> |
getConnectedSinks(Node n)
Finds and returns a Map of all sink Linkable s connected to specified Node . |
java.util.Map<Node,Link> |
getConnectedSources(Linkable linkable)
Finds and returns a Map of all source Nodes connected to specified Linkable . |
java.lang.String |
getDefaultLinkType()
Gets defaultLinkType |
java.lang.String |
getDefaultNodeType()
Gets defaultNodeType |
Link |
getLink(ExtendedId ids)
Gets Link with specified ExtendedId if present. |
Linkable |
getLinkable(ExtendedId ids)
Gets Linkable with specified ExtendedId |
int |
getLinkableCount()
Returns count of Linkable s |
java.util.Map<Linkable,java.util.Set<Link>> |
getLinkableMap()
Returns linkableMap |
java.util.Collection<Linkable> |
getLinkables()
Returns all Linkables, all Nodes and Links, in this NodeStructure |
int |
getLinkCount()
returns a count of links |
java.util.Collection<Link> |
getLinks()
Returns the Links of this NodeStructure |
java.util.Set<Link> |
getLinks(LinkCategory category)
Returns all Links of this NodeStructure with specified LinkCategory |
protected Link |
getNewLink(Link oLink,
java.lang.String newType,
Node source,
Linkable sink,
LinkCategory category)
This method can be overwritten to customize the Link Creation. |
protected Node |
getNewNode(Node oNode,
java.lang.String desiredType)
This method can be overwritten to customize the Node Creation. |
Node |
getNode(ExtendedId id)
Returns a copy of the node in this nodestructure with specified ExtendedId |
Node |
getNode(int id)
Returns a copy of the node in this nodestructure with specified id |
int |
getNodeCount()
Returns a count of nodes |
java.util.Collection<Node> |
getNodes()
Returns all Node s |
void |
mergeWith(NodeStructure ns)
Merges specified NodeStructure into this one. |
void |
removeLink(Link l)
Removes specified Link if present. |
void |
removeLinkable(ExtendedId id)
Removes Linkable with specified ExtendedId if present. |
void |
removeLinkable(Linkable linkable)
Removes specified Linkable if present. |
void |
removeNode(Node n)
Removes specified Node if present. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NodeStructureImpl()
public NodeStructureImpl(java.lang.String nodeType, java.lang.String linkType)
nodeType
- kind of node used in this NodeStructurelinkType
- kind of link used in this NodeStructureElementFactory
public NodeStructureImpl(NodeStructure original)
original
- original NodeStructuremergeWith(NodeStructure)
Method Detail |
---|
public NodeStructure copy()
NodeStructure
NodeStructure
copy
in interface NodeStructure
NodeStructure
public Link addDefaultLink(Link l)
NodeStructure
NodeStructure
when
it is added.
addDefaultLink
in interface NodeStructure
l
- Link to copy and add.
public Link addDefaultLink(int sourceId, ExtendedId sinkId, LinkCategory category, double activation, double removalThreshold)
NodeStructure
addDefaultLink
in interface NodeStructure
sourceId
- id of link's sourcesinkId
- ExtendedId
of link's sinkcategory
- Link's LinkCategory
activation
- initial link activationremovalThreshold
- amount of activation Link must maintain to remain in this NodeStructure after decaying.
public Link addDefaultLink(int sourceId, int sinkId, LinkCategory category, double activation, double removalThreshold)
NodeStructure
addDefaultLink
in interface NodeStructure
sourceId
- id of link's sourcesinkId
- id of link's sinkcategory
- Link's LinkCategory
activation
- initial link activationremovalThreshold
- amount of activation Link must maintain to remain in this NodeStructure after decaying.
public Link addDefaultLink(Node source, Linkable sink, LinkCategory category, double activation, double removalThreshold)
addDefaultLink
in interface NodeStructure
source
- Link's source Node
sink
- Link's sink, a Node
or a Link
category
- Link's LinkCategory
activation
- initial link activationremovalThreshold
- amount of activation Link must maintain to remain in this NodeStructure after decaying.
public java.util.Collection<Link> addDefaultLinks(java.util.Collection<Link> links)
NodeStructure
NodeStructure
when
they are added.
Note if Links in supplied Collection link to each other then this method does NOT guarantee
that all Links will be added properly. Links should be added one at a time in this case after
the dependent links are already present.
addDefaultLinks
in interface NodeStructure
links
- Links to copy and add.
public Node addDefaultNode(Node n)
NodeStructure
addDefaultNode
in interface NodeStructure
n
- Node to add.
public Link addLink(Link l, java.lang.String linkType)
NodeStructure
addLink
in interface NodeStructure
l
- original Link
linkType
- type of copied Link
Link
or null if such a link cannot be created.public Node addNode(Node n, java.lang.String nodeType)
NodeStructure
addNode
in interface NodeStructure
n
- NodenodeType
- name of node's type in the factory
protected Node addNode(Node n, boolean copy)
Node
to this NodeStructure without copying it.
If copy is true, NodeStructure.addDefaultNode(Node)
is used.
If a Node with the same id is already in this NodeStructure, the new
Node is not added.
This method is intended for internal use only.
n
- the Node to addcopy
- determines if the node is copied or not.
public java.util.Collection<Node> addDefaultNodes(java.util.Collection<Node> nodes)
addDefaultNodes
in interface NodeStructure
nodes
- Node to be added.
NodeStructure.addDefaultNode(Node)
protected Node getNewNode(Node oNode, java.lang.String desiredType)
oNode
- The original NodedesiredType
- the ElementFactory
name of the desired node type
protected Link getNewLink(Link oLink, java.lang.String newType, Node source, Linkable sink, LinkCategory category)
oLink
- original Link
newType
- the ElementFactory
name of the new node typesource
- The new sourcesink
- The new sinkcategory
- the type of the link
public void mergeWith(NodeStructure ns)
NodeStructure
mergeWith
in interface NodeStructure
ns
- NodeStructurepublic void removeLink(Link l)
NodeStructure
Link
if present.
removeLink
in interface NodeStructure
l
- Link to remove.public void removeLinkable(Linkable linkable)
NodeStructure
Linkable
if present.
removeLinkable
in interface NodeStructure
linkable
- Linkable to remove.public void removeLinkable(ExtendedId id)
NodeStructure
Linkable
with specified ExtendedId
if present.
removeLinkable
in interface NodeStructure
id
- ExtendedId of Linkable to remove.public void removeNode(Node n)
NodeStructure
Node
if present.
removeNode
in interface NodeStructure
n
- Node to remove.public void clearLinks()
NodeStructure
NodeStructure
clearLinks
in interface NodeStructure
public void clearNodeStructure()
NodeStructure
clearNodeStructure
in interface NodeStructure
public void decayNodeStructure(long ticks)
NodeStructure
Linkable
s of this NodeStructure
.
decayNodeStructure
in interface NodeStructure
ticks
- the number of ticks to decay for.public Link getLink(ExtendedId ids)
NodeStructure
getLink
in interface NodeStructure
ids
- ExtendedId
of sought Link.
public java.util.Collection<Link> getLinks()
NodeStructure
getLinks
in interface NodeStructure
public java.util.Set<Link> getAttachedLinks(Linkable linkable)
NodeStructure
Link
s directly connected to specified Linkable.
getAttachedLinks
in interface NodeStructure
linkable
- Linkable to find Links to and from.
public java.util.Set<Link> getAttachedLinks(Linkable linkable, LinkCategory category)
NodeStructure
Link
s directly connected to specified Linkable with specified LinkCategory
getAttachedLinks
in interface NodeStructure
linkable
- a Linkablecategory
- LinkCategory
public java.util.Collection<Node> getNodes()
NodeStructure
Node
s
getNodes
in interface NodeStructure
Node
s in this NodeStructure.public java.util.Map<Linkable,java.util.Set<Link>> getLinkableMap()
NodeStructure
getLinkableMap
in interface NodeStructure
public Node getNode(int id)
NodeStructure
getNode
in interface NodeStructure
id
- id of node
public Node getNode(ExtendedId id)
NodeStructure
getNode
in interface NodeStructure
id
- ExtendedId of node
public int getLinkCount()
NodeStructure
getLinkCount
in interface NodeStructure
public int getNodeCount()
NodeStructure
getNodeCount
in interface NodeStructure
public int getLinkableCount()
NodeStructure
Linkable
s
getLinkableCount
in interface NodeStructure
Linkable
spublic java.util.Set<Link> getLinks(LinkCategory category)
NodeStructure
LinkCategory
getLinks
in interface NodeStructure
category
- LinkCategory to search for.
LinkCategory
public Linkable getLinkable(ExtendedId ids)
NodeStructure
Linkable
with specified ExtendedId
getLinkable
in interface NodeStructure
ids
- ExtendedId
public java.lang.String getDefaultLinkType()
NodeStructure
getDefaultLinkType
in interface NodeStructure
public java.lang.String getDefaultNodeType()
NodeStructure
getDefaultNodeType
in interface NodeStructure
public java.util.Collection<Linkable> getLinkables()
NodeStructure
NodeStructure
getLinkables
in interface NodeStructure
public java.util.Map<Linkable,Link> getConnectedSinks(Node n)
NodeStructure
Map
of all sink Linkable
s connected to specified Node
.
Keys are the connected sinks
Values are the Link
s connecting the sinks to the specified Node
getConnectedSinks
in interface NodeStructure
n
- supplied node
public java.util.Map<Node,Link> getConnectedSources(Linkable linkable)
NodeStructure
Map
of all source Nodes connected to specified Linkable
.
Keys are the connected sources
Values are the Link
s connecting the sources to the specified Linkable
getConnectedSources
in interface NodeStructure
linkable
- specified linkable
public boolean containsLink(Link l)
NodeStructure
containsLink
in interface NodeStructure
l
- Link checked for.
public boolean containsLink(ExtendedId id)
NodeStructure
ExtendedId
.
containsLink
in interface NodeStructure
id
- Link checked for.
Link
with the same ExtendedId
.public boolean containsLinkable(Linkable l)
NodeStructure
Linkable
.
containsLinkable
in interface NodeStructure
l
- Linkable
checked for.
Linkable
with the same ExtendedId
.public boolean containsLinkable(ExtendedId id)
NodeStructure
Linkable
with specified ExtendedId
.
containsLinkable
in interface NodeStructure
id
- Linkable
checked for.
Linkable
with the same ExtendedId
.public boolean containsNode(int id)
NodeStructure
containsNode
in interface NodeStructure
id
- id of Node checked for.
public boolean containsNode(ExtendedId id)
NodeStructure
containsNode
in interface NodeStructure
id
- ExtendedId of Node checked for.
public boolean containsNode(Node n)
NodeStructure
containsNode
in interface NodeStructure
n
- Node checked for.
public java.lang.String toString()
toString
in class java.lang.Object
public static boolean compareNodeStructures(NodeStructure ns1, NodeStructure ns2)
ns1
- first NodeStructure
ns2
- second NodeStructure
NodeStructure
s are equal
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |