ilog.cpl.graph
Class IlpAbstractGraphModel

java.lang.Object
  extended by ilog.cpl.graph.IlpAbstractGraphModel
All Implemented Interfaces:
IlpGraphModel, IlvBatchable
Direct Known Subclasses:
IlpAbstractEquipmentModel, IlpAbstractNetworkModel

public abstract class IlpAbstractGraphModel
extends Object
implements IlpGraphModel, IlvBatchable

This class is an implementation of the 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.

Since:
JTGO 4.0

Constructor Summary
protected IlpAbstractGraphModel(Logger logger)
          Constructor.
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlpAbstractGraphModel

protected IlpAbstractGraphModel(Logger logger)
Constructor.

Parameters:
logger - The logger to be used to handle log messages within this class.
Method Detail

getObservationScope

protected final Map getObservationScope()
Returns the model observation scope.

Returns:
Observation scope
Since:
JViews 7.5
Internal method or field: do not use!

addToObservationScope

protected void addToObservationScope(IlpRepresentationNode object,
                                     int count)
Adds an object to the observation scope.

Internal method or field: do not use!

removeFromObservationScope

protected void removeFromObservationScope(IlpRepresentationNode object)
Removes an object from the observation scope

Internal method or field: do not use!

isInObservationScope

protected boolean isInObservationScope(IlpRepresentationNode object)
Returns if the given object is in the observation scope.

Parameters:
object -
Returns:
true if the object is in the scope
Internal method or field: do not use!

noteChildrenAdded

protected abstract void noteChildrenAdded(IlpRepresentationNode node,
                                          int[] indices,
                                          IlpRepresentationNode[] children)
Internal method or field: do not use!

noteChildrenRemoved

protected abstract void noteChildrenRemoved(IlpRepresentationNode node,
                                            int[] indices,
                                            IlpRepresentationNode[] children)
Internal method or field: do not use!

noteEndChanged

protected abstract void noteEndChanged(IlpRepresentationLink link,
                                       boolean origin,
                                       IlpRepresentationNode oldEnd,
                                       IlpRepresentationNode newEnd)
Internal method or field: do not use!

noteRootAdded

protected abstract void noteRootAdded(IlpRepresentationNode object)
Internal method or field: do not use!

noteRootsAdded

protected abstract void noteRootsAdded(Collection addedObjects)
Internal method or field: do not use!

noteRootRemoved

protected abstract void noteRootRemoved(IlpRepresentationNode object)
Internal method or field: do not use!

noteRootsRemoved

protected abstract void noteRootsRemoved(Collection removedObjects)
Internal method or field: do not use!

fireModelEvent

protected void fireModelEvent(GraphModelEvent event)
Notifies the listeners of a model event.


fireAttributeValueEvent

protected void fireAttributeValueEvent(AttributeValueEvent event)
Notifies the listeners of an attribute value change event.


getRootObjects

public Collection getRootObjects()
Returns an unmodifiable collection of the objects contained in the top level (given by the getChildren/getParent hierarchy) of the model.

Changes to this collection are signaled through GraphModelEvents of type ROOT_OBJECT_ADDED, ROOT_OBJECT_REMOVED.

Specified by:
getRootObjects in interface IlpGraphModel
Returns:
A collection of IlpRepresentationNodes.

isLeaf

public boolean isLeaf(IlpRepresentationObject object)
Returns 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.

Specified by:
isLeaf in interface IlpGraphModel
Returns:
true if the object cannot have children; false if it may have children.

getChildren

public List getChildren(IlpRepresentationObject object)
Returns a list of the child objects of this object.

Note: The order of the list as follows is important:

A change to the list of children must be signaled through a GraphModelEvent of type CHILDREN_ADDED or CHILDREN_REMOVED.

Specified by:
getChildren in interface IlpGraphModel
Parameters:
object - The parent object.
Returns:
An unmodifiable list of IlpRepresentationNodes.
See Also:
IlpGraphModel.getParent(ilog.cpl.model.IlpRepresentationObject)

getParent

public IlpRepresentationNode getParent(IlpRepresentationObject object)
Returns the parent object of an object.

The result of this function cannot change as long as the object is contained in the model.

Specified by:
getParent in interface IlpGraphModel
Parameters:
object - The object.
Returns:
null for a top-level object, non-null for a lower-level object.
See Also:
IlpGraphModel.getChildren(ilog.cpl.model.IlpRepresentationObject)

isNode

public abstract boolean isNode(IlpRepresentationObject object)
Returns true if a representation object is a node in this model.

Specified by:
isNode in interface IlpGraphModel
Parameters:
object - The object to be checked.
Returns:
true if the object is an instance of IlpRepresentationNode and not an instance of IlpRepresentationLink.
See Also:
IlpGraphModel.isLink(ilog.cpl.model.IlpRepresentationObject)

isLink

public abstract boolean isLink(IlpRepresentationObject object)
Returns true if a representation object is a link in this model.

In this implementation, true is returned if the object is an instance of IlpRepresentationLink.

Specified by:
isLink in interface IlpGraphModel
Parameters:
object - The object to be checked.
Returns:
true if the object is a link in this model; false otherwise.
See Also:
IlpGraphModel.isNode(ilog.cpl.model.IlpRepresentationObject)

getFrom

public IlpRepresentationObject getFrom(IlpRepresentationObject link)
Returns the from 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.

Specified by:
getFrom in interface IlpGraphModel
Parameters:
link - The link.
Returns:
The IlpRepresentationNode that is the from end.
See Also:
IlpGraphModel.getTo(ilog.cpl.model.IlpRepresentationObject)

getTo

public IlpRepresentationObject getTo(IlpRepresentationObject link)
Returns the 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.

Specified by:
getTo in interface IlpGraphModel
Parameters:
link - The link.
Returns:
The IlpRepresentationNode that is the to end.
See Also:
IlpGraphModel.getFrom(ilog.cpl.model.IlpRepresentationObject)

addModelListener

protected void addModelListener(GraphModelListener listener)
Adds a listener that is notified each time a change to this model occurs. This method should be called by implementations of IlpNetworkModel and IlpEquipmentModel.

Internal method or field: do not use!

removeModelListener

protected void removeModelListener(GraphModelListener listener)
Removes a listener previously added with addModelListener. This method should be called by implementations of IlpNetworkModel and IlpEquipmentModel.

Internal method or field: do not use!

addRootObject

public void addRootObject(IlpRepresentationObject object)
Adds a top-level object to the model.

Parameters:
object - Root representation object

addRootObjects

public void addRootObjects(Collection objects)
Adds several top-level objects to the model.

Parameters:
objects - The representation objects to be added.

removeRootObject

public void removeRootObject(IlpRepresentationObject object)
Removes a top-level object from the model.


removeRootObjects

public void removeRootObjects(Collection objects)
Removes several top-level objects from the model.

Parameters:
objects - The representation objects to be removed

clear

public void clear()
Removes all objects from the model.


startBatch

public void startBatch()
Tells the model temporarily not to send events. After this call, calls to fireRepresentationModelEvent delay the events until the next call to endBatch.

Note: When using a data source call IlpAbstractDataSource.startBatch() instead.

Specified by:
startBatch in interface IlvBatchable
Since:
JTGO 4.0
See Also:
IlpAbstractDataSource.startBatch(), endBatch()

endBatch

public void endBatch()
Tells the model that a temporary inhibition of events is terminated, and sends the events buffered since the last call to startBatch.

Note: When using a data source call IlpAbstractDataSource.endBatch() instead.

Specified by:
endBatch in interface IlvBatchable
Since:
JTGO 4.0
See Also:
IlpAbstractDataSource.endBatch(), startBatch()


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.