public abstract class IlpAbstractGraphModel extends Object implements IlpGraphModel, IlvBatchable
IlpGraphModel
interface which handles the notification to listeners of the model.
It does not, however, constrain the type of objects being stored or
the storage data structure. It is therefore an abstract class, see
IlpDefaultNetworkModel
and IlpDefaultEquipmentModel
for concrete, fully implemented subclasses.
Modifier | Constructor and Description |
---|---|
protected |
IlpAbstractGraphModel(Logger logger)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addModelListener(GraphModelListener listener)
Adds a listener that is notified each time a change to this model occurs.
|
void |
addRootObject(IlpRepresentationObject object)
Adds a top-level object to the model.
|
void |
addRootObjects(Collection objects)
Adds several top-level objects to the model.
|
protected void |
addToObservationScope(IlpRepresentationNode object,
int count)
Adds an object to the observation scope.
|
void |
clear()
Removes all objects from the model.
|
void |
endBatch()
Tells the model that a temporary inhibition of events
is terminated, and sends the events buffered since
the last call to
startBatch . |
protected void |
fireAttributeValueEvent(AttributeValueEvent event)
Notifies the listeners of an attribute value change event.
|
protected void |
fireModelEvent(GraphModelEvent event)
Notifies the listeners of a model event.
|
List |
getChildren(IlpRepresentationObject object)
Returns a list of the child objects of this object.
|
IlpRepresentationObject |
getFrom(IlpRepresentationObject link)
Returns the from end of a link.
|
protected Map |
getObservationScope()
Returns the model observation scope.
|
IlpRepresentationNode |
getParent(IlpRepresentationObject object)
Returns the parent object of an object.
|
Collection |
getRootObjects()
Returns an unmodifiable collection of the objects contained in the top
level (given by the
getChildren /getParent
hierarchy) of the model. |
IlpRepresentationObject |
getTo(IlpRepresentationObject link)
Returns the
to end of a link. |
protected boolean |
isInObservationScope(IlpRepresentationNode object)
Returns if the given object is in the observation scope.
|
boolean |
isLeaf(IlpRepresentationObject object)
Returns
true if this object, by its nature, has no children. |
abstract boolean |
isLink(IlpRepresentationObject object)
Returns true if a representation object is a link in this model.
|
abstract boolean |
isNode(IlpRepresentationObject object)
Returns
true if a representation object is a node in
this model. |
protected abstract void |
noteChildrenAdded(IlpRepresentationNode node,
int[] indices,
IlpRepresentationNode[] children) |
protected abstract void |
noteChildrenRemoved(IlpRepresentationNode node,
int[] indices,
IlpRepresentationNode[] children) |
protected abstract void |
noteEndChanged(IlpRepresentationLink link,
boolean origin,
IlpRepresentationNode oldEnd,
IlpRepresentationNode newEnd) |
protected abstract void |
noteRootAdded(IlpRepresentationNode object) |
protected abstract void |
noteRootRemoved(IlpRepresentationNode object) |
protected abstract void |
noteRootsAdded(Collection addedObjects) |
protected abstract void |
noteRootsRemoved(Collection removedObjects) |
protected void |
removeFromObservationScope(IlpRepresentationNode object)
Removes an object from the observation scope
|
protected void |
removeModelListener(GraphModelListener listener)
Removes a listener previously added with
addModelListener . |
void |
removeRootObject(IlpRepresentationObject object)
Removes a top-level object from the model.
|
void |
removeRootObjects(Collection objects)
Removes several top-level objects from the model.
|
void |
startBatch()
Tells the model temporarily not to send events.
|
protected IlpAbstractGraphModel(Logger logger)
logger
- The logger to be used to handle log messages within this
class.protected final Map getObservationScope()
protected void addToObservationScope(IlpRepresentationNode object, int count)
protected void removeFromObservationScope(IlpRepresentationNode object)
protected boolean isInObservationScope(IlpRepresentationNode object)
object
- true
if the object is in the scopeprotected abstract void noteChildrenAdded(IlpRepresentationNode node, int[] indices, IlpRepresentationNode[] children)
protected abstract void noteChildrenRemoved(IlpRepresentationNode node, int[] indices, IlpRepresentationNode[] children)
protected abstract void noteEndChanged(IlpRepresentationLink link, boolean origin, IlpRepresentationNode oldEnd, IlpRepresentationNode newEnd)
protected abstract void noteRootAdded(IlpRepresentationNode object)
protected abstract void noteRootsAdded(Collection addedObjects)
protected abstract void noteRootRemoved(IlpRepresentationNode object)
protected abstract void noteRootsRemoved(Collection removedObjects)
protected void fireModelEvent(GraphModelEvent event)
protected void fireAttributeValueEvent(AttributeValueEvent event)
public Collection getRootObjects()
getChildren
/getParent
hierarchy) of the model.
Changes to this collection are signaled through
GraphModelEvent
s of type
ROOT_OBJECT_ADDED
, ROOT_OBJECT_REMOVED
.
getRootObjects
in interface IlpGraphModel
IlpRepresentationNode
s.public boolean isLeaf(IlpRepresentationObject object)
true
if this object, by its nature, has no children.
When this method returns false
, there may or may not be
children attached to the object; children can be added or removed
dynamically.
The result of this function cannot change as long as the object is contained in the model.
isLeaf
in interface IlpGraphModel
true
if the object cannot have children;
false
if it may have children.public List getChildren(IlpRepresentationObject object)
Note: The order of the list as follows is important:
RepresentationNodeEvent
events, which indicate the children added (after addition) or removed
(before removal).
A change to the list of children must be signaled through a
GraphModelEvent
of type CHILDREN_ADDED
or CHILDREN_REMOVED
.
getChildren
in interface IlpGraphModel
object
- The parent object.IlpRepresentationNode
s.IlpGraphModel.getParent(ilog.cpl.model.IlpRepresentationObject)
public IlpRepresentationNode getParent(IlpRepresentationObject object)
The result of this function cannot change as long as the object is contained in the model.
getParent
in interface IlpGraphModel
object
- The object.null
for a top-level object, non-null
for a lower-level object.IlpGraphModel.getChildren(ilog.cpl.model.IlpRepresentationObject)
public abstract boolean isNode(IlpRepresentationObject object)
true
if a representation object is a node in
this model.isNode
in interface IlpGraphModel
object
- The object to be checked.true
if the object is an instance of
IlpRepresentationNode
and not an instance of
IlpRepresentationLink
.IlpGraphModel.isLink(ilog.cpl.model.IlpRepresentationObject)
public abstract boolean isLink(IlpRepresentationObject object)
In this implementation, true is returned if the object is an
instance of IlpRepresentationLink
.
isLink
in interface IlpGraphModel
object
- The object to be checked.true
if the object is a link in this model;
false
otherwise.IlpGraphModel.isNode(ilog.cpl.model.IlpRepresentationObject)
public IlpRepresentationObject getFrom(IlpRepresentationObject link)
In this implementation, the corresponding
IlpRepresentationLink
method is called.
Note:The returned node may or may not be in the model at this moment; it may appear in the model later.
getFrom
in interface IlpGraphModel
link
- The link.IlpRepresentationNode
that is the
from
end.IlpGraphModel.getTo(ilog.cpl.model.IlpRepresentationObject)
public IlpRepresentationObject getTo(IlpRepresentationObject link)
to
end of a link.
In this implementation, the corresponding
IlpRepresentationLink
method is called.
Note:The returned node may or may not be in the model at this moment; it may appear in the model later.
getTo
in interface IlpGraphModel
link
- The link.IlpRepresentationNode
that is the to
end.IlpGraphModel.getFrom(ilog.cpl.model.IlpRepresentationObject)
protected void addModelListener(GraphModelListener listener)
IlpNetworkModel
and IlpEquipmentModel
.protected void removeModelListener(GraphModelListener listener)
addModelListener
.
This method should be called by implementations of
IlpNetworkModel
and IlpEquipmentModel
.public void addRootObject(IlpRepresentationObject object)
object
- Root representation objectpublic void addRootObjects(Collection objects)
objects
- The representation objects to be added.public void removeRootObject(IlpRepresentationObject object)
public void removeRootObjects(Collection objects)
objects
- The representation objects to be removedpublic void clear()
public void startBatch()
fireRepresentationModelEvent
delay the events until the next call to endBatch
.
Note: When using a data source call
IlpAbstractDataSource.startBatch()
instead.
startBatch
in interface IlvBatchable
IlpAbstractDataSource.startBatch()
,
endBatch()
public void endBatch()
startBatch
.
Note: When using a data source call
IlpAbstractDataSource.endBatch()
instead.
endBatch
in interface IlvBatchable
IlpAbstractDataSource.endBatch()
,
startBatch()
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.