ilog.views.graphlayout
Class IlvGraphModel

java.lang.Object
  extended by ilog.views.graphlayout.IlvGraphModel
Direct Known Subclasses:
IlvGrapherAdapter

public abstract class IlvGraphModel
extends Object

IlvGraphModel defines a suitable generic API for graphs that have to be laid out with ILOG JViews graph layout algorithms.

The concept of the graph model is in many ways similar to Swing's TreeModel and TableModel. Instead of asking programmers to extend their data objects from a predefined base class, it allows the use of any application object as a graph, a node, or a link. This makes it much easier to add graph layout features to existing applications.

All the layout algorithms provided in ILOG JViews are designed to lay out a graph model. This allows any application to benefit from the JViews graph layout algorithms, whether or not it uses the ILOG JViews grapher (IlvGrapher). However, to make things simple for the common case of applications that use an IlvGrapher, it is not mandatory to work directly with the graph model, except when using some of the advanced features, such as filtering (see the methods IlvGrapherAdapter.setFilter and IlvGrapherAdapter.addLayer), or when using some features that are needed only when laying out an IlvGrapher, such as the reference transformer (IlvGrapherAdapter.setReferenceTransformer) and the reference view (IlvGrapherAdapter.setReferenceView).

Learning to use these classes is a bit difficult because they are very general and use class java.lang.Object for the arguments of many methods (representing nodes, links, and subgraphs). But if you are spending the time learning Swing, especially the packages javax.swing.tree and javax.swing.table, you will be learning the same concepts. For laying out IlvGrapher graphs, most often it is sufficient to use the API of the layout algorithms.

This class is abstract. Since its purpose is not to provide a concrete implementation of a graph data structure, a complete implementation must be provided by "adapter" classes. Thus, to create a concrete Graph Model, you need to provide an implementation for the abstract methods in an "adapter" class. The adapters extend the graph model and must use an underlying graph data structure. A special adapter class, IlvGrapherAdapter, is provided in order to use an IlvGrapher as the underlying graph data structure.

Note that if an application uses the class IlvGrapher, the grapher can be attached directly to the layout instance without explicitly using a graph model (see the method IlvGraphLayout.attach). In this case the appropriate adapter (IlvGrapherAdapter) is created internally. If necessary, this adapter can be retrieved using the method IlvGraphLayout.getGraphModel(), which in this circumstance returns an instance of IlvGrapherAdapter.

The methods defined in this class can be divided into the following categories:

Some of these methods are abstract and must be implemented by the adapter class. (Of course, the IlvGrapherAdapter provides implementation for all the methods.)

Other methods are useful for managing nested graphs, that is, if a node of a graph can be a graph:

Finally, the method performLayout(ilog.views.graphlayout.IlvLayoutProvider, boolean, boolean, boolean) allows you to perform layout algorithms on a nested graph. To customize the layout to be applied to each subgraph, you can implement the interface IlvLayoutProvider or use its default implementation IlvDefaultLayoutProvider (in most cases the latter is the easiest choice).

Note that the efficiency of the layout algorithms directly depends on the efficiency of the implementation of the adapter class as well as the efficiency of the implementation of the underlying graph data structure.

If the graph model is subclassed in order to use a graph data structure other than IlvGrapher, the performance can be improved by replacing, in the adapter class, the default implementation of the nonabstract methods with an overridden version that is optimized for the particular graph data structure. The IlvGrapherAdapter provides the optimized methods for the ILOG JViews grapher (IlvGrapher).

The default implementations of the following methods, although functional, are particularly inefficient. Any time the underlying graph allows a more efficient implementation, these methods should be overridden:

Note that any adapter (subclass of IlvGraphModel) that uses an IlvGrapher as an underlying graph must be implemented as a subclass of IlvGrapherAdapter.

Note that you must call the method dispose() after detaching the layouts when you no longer need the graph model instance; otherwise, some objects may not be garbage collected. This is necessary only if the graph model instance is directly created by your code. Calling dispose() is not necessary if the graph model instance is created internally by the ILOG JViews Graph Layout library, for instance, when directly attaching an IlvGrapher to a layout instance using IlvGraphLayout.attach(IlvGrapher) or when using an IlvDefaultLayoutProvider for recursive layout.

Since:
JViews 3.0
See Also:
IlvGraphLayout.attach(ilog.views.graphlayout.IlvGraphModel), IlvGraphLayout.attach(ilog.views.IlvGrapher), IlvGrapherAdapter

Constructor Summary
IlvGraphModel()
          Creates a new IlvGraphModel.
 
Method Summary
 void addGraphModelListener(GraphModelListener listener)
          Adds a listener to listen for modifications of the graph models.
 void adjustmentEnd()
          Notifies the graph model that it is the end of a series of events.
 void afterAnimationStep()
          Notifies the graph model that a layout animation step has finished.
protected  void afterAttach(IlvGraphLayout layout)
          Notifies the graph model that it has been attached to a layout.
protected  void afterDetach(IlvGraphLayout layout)
          Notifies the graph model that it has been detached from a layout.
 void afterLayout(IlvGraphLayout layout, IlvGraphLayoutReport layoutReport, boolean redraw)
          Notifies the graph model that a layout session has finished.
 void beforeAnimationStep()
          Notifies the graph model that a layout animation step has been started.
 void beforeLayout(IlvGraphLayout layout, boolean redraw)
          Notifies the graph model that a layout session has been started.
 IlvRect boundingBox()
          Returns the bounding rectangle of the graph.
abstract  IlvRect boundingBox(Object nodeOrLink)
          Returns the bounding rectangle of a node or a link.
protected abstract  IlvGraphModel createGraphModel(Object subgraph)
          Creates a new graph model for a subgraph.
 void dispose()
          Disposes of this IlvGraphModel and releases any resources that it is using.
protected  void fireGraphModelEvent(GraphModelEvent event)
          This method must be called by the adapter classes when the contents of the graph have changed.
 void fireGraphModelEvent(Object nodeOrLink, int eventType, boolean adjusting)
          Notifies the graph-model-event listeners that nodes or links have been added or removed, or that their geometry has changed (nodes or links were moved or reshaped).
 void geometryChanged(boolean adjusting)
          Deprecated. Beginning with ILOG JViews 5.5, use the method fireGraphModelEvent(java.lang.Object, int, boolean) instead.
abstract  Object getFrom(Object link)
          Returns the origin node of a link.
 IlvGrapher getGrapher()
          Returns the IlvGrapher that stores the nodes and links of the graph.
 IlvGraphModel getGraphModel(Object subgraph)
          Returns a graph model instance for a subgraph of a nested graph.
 int getInstanceId()
          A utility method that returns a unique integer value for each graph model instance inside the same Java program.
abstract  Enumeration getInterGraphLinks()
          Returns the intergraph links contained in this graph.
 int getInterGraphLinksCount()
          Returns the number of intergraph links contained in this graph.
 IlvGraphLayout getLayout(IlvLayoutProvider layoutProvider, Object subgraph)
          Returns the layout instance for a subgraph of the nested graph encapsulated by this graph model.
 Enumeration getLayouts(IlvLayoutProvider layoutProvider, boolean preOrder)
          Returns the instances of IlvGraphLayout for the nested graph encapsulated by this graph model.
 IlvPoint getLinkPointAt(Object link, int index)
          Returns the point of a link at a specified index.
abstract  IlvPoint[] getLinkPoints(Object link)
          Returns the points that define a link.
abstract  int getLinkPointsCount(Object link)
          Returns the number of points that define a link, including the connection points of the link on the origin and destination nodes.
abstract  Enumeration getLinks()
          Returns an enumeration of the links.
 Enumeration getLinks(Object node)
          Returns an enumeration of all the links that have node as their origin or destination.
 int getLinksCount()
          Returns the number of links.
 int getLinksCount(Object node)
          Returns the number of links adjacent to a node.
abstract  Enumeration getLinksFrom(Object node)
          Returns an enumeration of all the links that have node as their origin.
 int getLinksFromCount(Object node)
          Returns the number of links that have node as their origin.
abstract  Enumeration getLinksTo(Object node)
          Returns an enumeration of all the links that have node as their destination.
 int getLinksToCount(Object node)
          Returns the number of links that have node as their destination.
 float getLinkWidth(Object link)
          Returns the width of a link.
 Enumeration getNeighbors(Object node)
          Returns an enumeration of all the nodes that are the "neighbors" of node, that is, the nodes that have a common normal link with node.
 int getNodeDegree(Object node)
          Returns the degree of a node, that is, the number of its neighbors.
abstract  Enumeration getNodes()
          Returns an enumeration of the nodes.
 Enumeration getNodesAndLinks()
          Returns an enumeration of the nodes and links.
 int getNodesCount()
          Returns the number of nodes.
 Object getOpposite(Object link, Object node)
          Returns the opposite node on a link.
 IlvGraphLayout getOriginatingLayout()
          Returns the layout that created this model internally because an IlvGrapher got directly attached.
abstract  IlvGraphModel getParentModel()
          Returns the graph model that encapsulates the parent graph of the graph encapsulated by this graph model, or null.
 Object getProperty(Object nodeOrLink, String key)
          Returns the value of a property.
 Object getProperty(String key)
          Returns the value of a property of the graph model.
 IlvGraphModel getRootModel()
          Returns the root graph model of this graph model, if any, or null otherwise.
abstract  Enumeration getSubgraphs()
          Returns an enumeration of the subgraphs of the graph encapsulated by this graph model.
 int getSubgraphsCount()
          Returns the number of subgraphs.
abstract  Object getTo(Object link)
          Returns the destination node of a link.
 boolean hasMoveableConnectionPoint(Object link, boolean origin)
          Returns true if the connection point of link on the origin or destination node can be moved by a call to the method reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean).
 boolean hasPinnedConnectionPoint(Object link, boolean origin)
          Returns true if the connection point of link on the origin or destination node is "pinned," and false otherwise.
 boolean isConnectionPointCheckEnabled()
          Returns true if the checks for the connection points of the links are enabled, and false otherwise.
abstract  boolean isInterGraphLink(Object obj)
          Returns true if the object is a valid intergraph link, and false otherwise.
 boolean isInternalGraphModelChecking()
          Returns true if the extended checking of internally created graph models is enabled.
 boolean isLayoutNeeded(IlvGraphLayout layout)
          Returns true if a given layout that has been already applied to this graph is still valid.
abstract  boolean isLink(Object obj)
          Returns true if the object is a valid normal link, and false otherwise.
 boolean isLinkBetween(Object node1, Object node2)
          Tests whether a normal link exists between two nodes.
 boolean isLinkCheckEnabled()
          Returns true if the checks for the links are enabled, and false otherwise.
abstract  boolean isNode(Object obj)
          Returns true if an object is a valid node, and false otherwise.
 boolean isReshapeableLink(Object link, boolean toStraightLine)
          Returns true if link can be reshaped, and false otherwise.
abstract  boolean isSubgraph(Object obj)
          Returns true if the object is a valid subgraph, and false otherwise.
 void move(float x, float y, boolean redraw)
          Moves the entire graph.
abstract  void moveNode(Object node, float x, float y, boolean redraw)
          Changes the position of the specified node.
 int performLayout(IlvLayoutProvider layoutProvider, boolean force, boolean redraw, boolean traverse)
          Applies layout instances recursively to this graph model.
 int performLayout(IlvLayoutProvider layoutProvider, IlvGraphLayout recursiveLayout, boolean force, boolean redraw, boolean traverse)
          Applies layout instances recursively to this graph model.
 void removeGraphModelListener(GraphModelListener listener)
          Removes a listener added with addGraphModelListener.
abstract  void reshapeLink(Object link, IlvPoint fromPoint, IlvPoint[] points, int startIndex, int length, IlvPoint toPoint, boolean redraw)
          Reshapes all the points of a link, given an array of intermediate points, the start position in the array of points, the number of intermediate points, and the connection points.
 void setConnectionPointCheckEnabled(boolean enable)
          Enables or disables the checks of the connection points of the links on the origin or destination node.
 void setInternalGraphModelChecking(boolean flag)
          Enables or disables the extended checking of internally created graph models, that is, the grapher adapter that is internally created inside IlvGraphLayout.attach(IlvGrapher).
 void setLinkCheckEnabled(boolean enable)
          Enables or disables the checks of the links.
 void setProperty(Object nodeOrLink, String key, Object value)
          Sets the value of a property for a node or a link.
 void setProperty(String key, Object value)
          Sets the value of a property for the graph model.
 void structureChanged(boolean adjusting)
          Deprecated. Beginning with ILOG JViews 5.5, use the method fireGraphModelEvent(java.lang.Object, int, boolean) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvGraphModel

public IlvGraphModel()
Creates a new IlvGraphModel.

Method Detail

dispose

public void dispose()
Disposes of this IlvGraphModel and releases any resources that it is using. An IlvGraphModel object cannot be used after the dispose method has been called. If there are any layouts still attached, they get automatically detached from the graph model. The method recursively disposes of this graph model and all its graph model children (if any).

See Also:
IlvGraphLayout.detach()

getOriginatingLayout

public final IlvGraphLayout getOriginatingLayout()
Returns the layout that created this model internally because an IlvGrapher got directly attached. It returns null if the model was not internally created but explicitly allocated by the user.

Since:
JViews 5.5
See Also:
IlvGraphLayout.attach(IlvGrapher)

setInternalGraphModelChecking

public final void setInternalGraphModelChecking(boolean flag)
Enables or disables the extended checking of internally created graph models, that is, the grapher adapter that is internally created inside IlvGraphLayout.attach(IlvGrapher). Internally created graph models are automatically disposed of when no longer needed. If the checking is enabled, exceptions are thrown in certain situations that are a potential misuse of the internally created graph model, since it may be disposed of too early. The option is enabled by default. Normally, you should not disable this option.

Parameters:
flag - Set to true to enable extended checking.
Since:
JViews 5.5
See Also:
isInternalGraphModelChecking(), IlvGraphLayout.attach(IlvGrapher)

isInternalGraphModelChecking

public final boolean isInternalGraphModelChecking()
Returns true if the extended checking of internally created graph models is enabled.

Since:
JViews 5.5
See Also:
setInternalGraphModelChecking(boolean)

getInstanceId

public final int getInstanceId()
A utility method that returns a unique integer value for each graph model instance inside the same Java program. This method can be used to obtain names for properties that are unique for each graph model instance.

Since:
JViews 5.0

getGrapher

public IlvGrapher getGrapher()
Returns the IlvGrapher that stores the nodes and links of the graph. It returns null if the nodes and links are not stored by the ILOG JViews grapher class (IlvGrapher).

The default implementation always returns null. The method is overridden in the class IlvGrapherAdapter.

Since:
JViews 3.5

getParentModel

public abstract IlvGraphModel getParentModel()
Returns the graph model that encapsulates the parent graph of the graph encapsulated by this graph model, or null.

Returns:
The parent graph model, or null.
Since:
JViews 5.0
See Also:
getGraphModel(java.lang.Object), getRootModel()

getRootModel

public IlvGraphModel getRootModel()
Returns the root graph model of this graph model, if any, or null otherwise.

If this method is called for a graph model encapsulating one of the subgraphs of a nested graph, it returns the graph model that encapsulates the topmost graph. It returns null when called on the graph model that encapsulates the topmost graph.

The returned root graph model is the one that created this graph model by createGraphModel(java.lang.Object).

Returns:
The root graph model, or null.
Since:
JViews 5.0
See Also:
getGraphModel(java.lang.Object), getParentModel()

getGraphModel

public IlvGraphModel getGraphModel(Object subgraph)
Returns a graph model instance for a subgraph of a nested graph. The current graph model must belong to the nested graph; for instance, it can be the root graph model that encapsulates the root graph, or it can be the graph model that encapsulates the parent graph of the subgraph.

The typical way to deal with nested graphs is the following:

Parameters:
subgraph - The subgraph object. This is an object for which the method isSubgraph(java.lang.Object), called on the parent graph model of the returned graph model, returns true. This must not be the root graph.
Returns:
The graph model that encapsulates subgraph.
Since:
JViews 5.0
See Also:
getRootModel()

createGraphModel

protected abstract IlvGraphModel createGraphModel(Object subgraph)
Creates a new graph model for a subgraph. The method is called on the root graph model that encapsulates the root graph of the nested graph containing the subgraph.

Subclasses must override this method in order to return a new instance of the appropriate subclass of IlvGraphModel, encapsulating subgraph.

Parameters:
subgraph - The subgraph object.
Since:
JViews 5.0

getLayouts

public Enumeration getLayouts(IlvLayoutProvider layoutProvider,
                              boolean preOrder)
Returns the instances of IlvGraphLayout for the nested graph encapsulated by this graph model. It returns the layout instance for this graph, and recursively for all subgraphs. The order of the enumeration can be pre-order (that is, the layout of parent graph comes before the layout of the subgraphs) or post-order (that is, the layout of the subgraphs comes before the layout of the parent graph).

Parameters:
layoutProvider - The object that provides a layout instance to be used for laying out each subgraph.
preOrder - If true, the layout instances are returned in pre-order, otherwise in post-order.
Returns:
The instances of IlvGraphLayout for the nested graph.
Since:
JViews 5.0
See Also:
performLayout(ilog.views.graphlayout.IlvLayoutProvider, boolean, boolean, boolean), IlvGraphLayout.getLayouts(boolean)

getLayout

public IlvGraphLayout getLayout(IlvLayoutProvider layoutProvider,
                                Object subgraph)
Returns the layout instance for a subgraph of the nested graph encapsulated by this graph model.

Parameters:
layoutProvider - The object that provides a layout instance to be used for laying out subgraph.
subgraph - The subgraph object. This must not be the root graph.
Returns:
The layout instance.
Since:
JViews 5.5
See Also:
IlvLayoutProvider.getGraphLayout(ilog.views.graphlayout.IlvGraphModel), performLayout(ilog.views.graphlayout.IlvLayoutProvider, boolean, boolean, boolean), getLayouts(ilog.views.graphlayout.IlvLayoutProvider, boolean), IlvGraphLayout.getLayout(java.lang.Object)

performLayout

public int performLayout(IlvLayoutProvider layoutProvider,
                         boolean force,
                         boolean redraw,
                         boolean traverse)
                  throws IlvGraphLayoutException
Applies layout instances recursively to this graph model.

The layout instance to be applied to each subgraph is obtained using the method IlvLayoutProvider.getGraphLayout(ilog.views.graphlayout.IlvGraphModel). If this method returns null for a given graph, no layout is applied to this graph.

If the argument traverse is false and the graph is nested, layout is applied only to the topmost graph. In this case, the return value is the result code stored in the layout report (see IlvGraphLayoutReport.getCode()). If the argument traverse is true, layout is applied recursively to the top-level graph and all subgraphs. In this case, the return value is the combined result code of all layout calls:

Note that, while this method is a simple way to lay out nested graphs, you can achieve the maximum flexibility for configuring the layout of nested graphs by using the facility classes IlvRecursiveLayout and IlvRecursiveMultipleLayout.

Also, note that, when laying out an IlvGrapher using this method, it is recommended to use links of type IlvPolylineLinkImage and link connectors of type IlvFreeLinkConnector. Differently than when using IlvRecursiveLayout or IlvRecursiveMultipleLayout, this method does not throw a chain of IlvInappropriateLinkException in case the links or link connectors are not appropriate. Therefore, if it is not possible to ensure in advance that the link and link connector types are appropriate, it is recommended to lay out the nested graphs using IlvRecursiveLayout or IlvRecursiveMultipleLayout, because using these facility it is possible to use IlvGraphLayoutUtil.EnsureAppropriateLinks(IlvInappropriateLinkException) to perform an automatic replacement of inappropriate links or link connectors for the entire nested graph.

Parameters:
layoutProvider - The object that provides a layout instance to be used for laying out each subgraph.
force - This parameter is passed to the method IlvGraphLayout.performLayout(boolean, boolean).
redraw - This parameter is passed to the method IlvGraphLayout.performLayout(boolean, boolean).
traverse - If false, the layout instance provided by layoutProvider is applied to this graph model. If true, the layout instances provided by the layoutProvider layout are applied to this graph model and recursively to all subgraph models of this graph model.
Returns:
The layout code (see IlvGraphLayoutReport.getCode()).
Throws:
IlvGraphLayoutException
Since:
JViews 5.0
See Also:
IlvGraphLayout.performLayout(boolean, boolean, boolean), IlvGraphLayout.PerformLayout(IlvGraphModel, IlvLayoutProvider, boolean, boolean, boolean)

performLayout

public int performLayout(IlvLayoutProvider layoutProvider,
                         IlvGraphLayout recursiveLayout,
                         boolean force,
                         boolean redraw,
                         boolean traverse)
                  throws IlvGraphLayoutException
Applies layout instances recursively to this graph model. For details, see performLayout(IlvLayoutProvider, boolean, boolean, boolean). This entry point for the layout of a nested graph is used by the IlvRecursiveLayout. You should not call this method directly.

Throws:
IlvGraphLayoutException
Since:
JViews 5.5

isLayoutNeeded

public boolean isLayoutNeeded(IlvGraphLayout layout)
Returns true if a given layout that has been already applied to this graph is still valid. The method returns true if at least one of the following holds: If none of the conditions above holds, the method returns false

Since:
JViews 5.0
See Also:
IlvGraphLayout.isLayoutNeeded(), IlvGraphLayout.isStructureUpToDate(), IlvGraphLayout.isGeometryUpToDate(), IlvGraphLayout.isParametersUpToDate()

beforeLayout

public void beforeLayout(IlvGraphLayout layout,
                         boolean redraw)
Notifies the graph model that a layout session has been started. This method is always called by IlvGraphLayout.performLayout() before the call to the method IlvGraphLayout.layout(boolean).

If necessary, you can override this method in order to perform preliminary operations before the layout. In this case, you must always call super.beforeLayout.

Parameters:
layout - The layout instance that is the origin of the notification.
redraw - If true, the layout algorithm will ask the graph model to redraw the graph when the method afterLayout is called (that is, it will pass true for its redraw argument).
See Also:
afterLayout(ilog.views.graphlayout.IlvGraphLayout, ilog.views.graphlayout.IlvGraphLayoutReport, boolean)

afterLayout

public void afterLayout(IlvGraphLayout layout,
                        IlvGraphLayoutReport layoutReport,
                        boolean redraw)
Notifies the graph model that a layout session has finished. This method is always called by IlvGraphLayout.performLayout() after the method IlvGraphLayout.layout(boolean) has finished, even if an exception is thrown during the layout process.

Note that you can detect whether the layout was performed successfully using the test layoutReport.getCode() == IlvGraphLayoutReport.LAYOUT_DONE.

If necessary, you can override this method in order to perform some operations after the layout. In this case, you must always call super.afterLayout. Note also that any overridden implementation of this method should redraw the graph if the argument redraw is true.

Parameters:
layout - The layout instance that is the origin of the notification.
layoutReport - The layout report, or null.
redraw - If true, the layout algorithm asks the graph model to redraw the graph.
See Also:
beforeLayout(ilog.views.graphlayout.IlvGraphLayout, boolean)

afterAttach

protected void afterAttach(IlvGraphLayout layout)
Notifies the graph model that it has been attached to a layout. This method is called by IlvGraphLayout.attach(IlvGraphModel).

The default implementation does nothing. If necessary, you can override this method in order to perform some operations.

Parameters:
layout - The layout instance to which the model has been attached.
Since:
JViews 5.5
See Also:
afterDetach(ilog.views.graphlayout.IlvGraphLayout), IlvGraphLayout.attach(IlvGraphModel)

afterDetach

protected void afterDetach(IlvGraphLayout layout)
Notifies the graph model that it has been detached from a layout. This method is called by IlvGraphLayout.detach().

The default implementation does nothing. If necessary, you can override this method in order to perform some operations.

Parameters:
layout - The layout instance from which the model has been detached.
Since:
JViews 5.5
See Also:
afterAttach(ilog.views.graphlayout.IlvGraphLayout), IlvGraphLayout.detach()

beforeAnimationStep

public void beforeAnimationStep()
Notifies the graph model that a layout animation step has been started. If appropriate, this method is called by the layout algorithms before each animation step.

The default implementation does nothing. If necessary, you can override this method in order to perform preliminary operations before the animation step.

See Also:
afterAnimationStep()

afterAnimationStep

public void afterAnimationStep()
Notifies the graph model that a layout animation step has finished. If appropriate, this method is called by the layout algorithms after each animation step, even if an exception is thrown during the layout process.

The default implementation does nothing. To support the animation mechanism, this method can be overridden by an adapter to redraw the graph after each step of the layout.

See Also:
beforeAnimationStep()

getNodesAndLinks

public Enumeration getNodesAndLinks()
Returns an enumeration of the nodes and links. The default implementation builds an enumeration of the nodes and links that uses the enumerations returned by the methods getNodes() and getLinks().

See Also:
getNodes(), getLinks(), getNodesCount(), getLinksCount()

getNodes

public abstract Enumeration getNodes()
Returns an enumeration of the nodes.

See Also:
isNode(java.lang.Object), getNodesCount(), getLinks(), getNodesAndLinks()

getNodesCount

public int getNodesCount()
Returns the number of nodes. The default implementation simply counts the number of nodes as returned by the method getNodes().

See Also:
getNodes()

getLinks

public abstract Enumeration getLinks()
Returns an enumeration of the links. This enumeration must not contain intergraph links, that is, links whose origin or destination node is not stored in this graph.

See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object), getLinksCount(), getNodes(), getNodesAndLinks()

getLinksCount

public int getLinksCount()
Returns the number of links. The default implementation simply counts the number of links as returned by the method getLinks().

See Also:
getLinks(), getLinksFromCount(java.lang.Object), getLinksToCount(java.lang.Object)

getSubgraphs

public abstract Enumeration getSubgraphs()
Returns an enumeration of the subgraphs of the graph encapsulated by this graph model. The enumeration must contain nodes of the graph, that is, objects for which the method isNode(java.lang.Object) returns true.

Since:
JViews 5.0
See Also:
isSubgraph(java.lang.Object), getSubgraphsCount(), getNodes(), getLinks()

getSubgraphsCount

public int getSubgraphsCount()
Returns the number of subgraphs. The default implementation simply counts the number of objects as returned by the method getSubgraphs().

Since:
JViews 5.0
See Also:
getSubgraphs()

getInterGraphLinks

public abstract Enumeration getInterGraphLinks()
Returns the intergraph links contained in this graph. An intergraph link is a link stored in a given graph that has an origin or destination not stored in this graph.

Since:
JViews 5.0
See Also:
isInterGraphLink(java.lang.Object), getInterGraphLinksCount()

getInterGraphLinksCount

public int getInterGraphLinksCount()
Returns the number of intergraph links contained in this graph. An intergraph link is a link stored in a given graph that has an origin or destination not stored in this graph.

The default implementation simply counts the number of objects as returned by the method getInterGraphLinks().

Since:
JViews 5.0
See Also:
getInterGraphLinks()

getLinksFrom

public abstract Enumeration getLinksFrom(Object node)
Returns an enumeration of all the links that have node as their origin. This enumeration must not contain intergraph links, that is, links whose origin or destination node is not stored in this graph.

Parameters:
node - The origin node.
See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object), getLinksTo(java.lang.Object), getLinks(java.lang.Object)

getLinksFromCount

public int getLinksFromCount(Object node)
Returns the number of links that have node as their origin. The default implementation simply counts the number of links returned by the method getLinksFrom.

Parameters:
node - The node.
See Also:
getLinksFrom(java.lang.Object)

getLinksTo

public abstract Enumeration getLinksTo(Object node)
Returns an enumeration of all the links that have node as their destination. This enumeration must not contain intergraph links, that is, links whose origin or destination node is not stored in this graph.

Parameters:
node - The destination node.
See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object), getLinksFrom(java.lang.Object), getLinks(java.lang.Object)

getLinksToCount

public int getLinksToCount(Object node)
Returns the number of links that have node as their destination. The default implementation simply counts the number of links returned by the method getLinksTo.

Parameters:
node - The node.
See Also:
getLinksTo(java.lang.Object)

getLinks

public Enumeration getLinks(Object node)
Returns an enumeration of all the links that have node as their origin or destination. This enumeration must not contain intergraph links, that is, links whose origin or destination node is not stored in this graph.

The default implementation uses the enumerations returned by the methods getLinksFrom(Object) and getLinksTo to build the enumeration of all the links.

Parameters:
node - The node.
See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object), getLinksCount(), getLinksFrom(java.lang.Object), getLinksTo(java.lang.Object)

getLinksCount

public int getLinksCount(Object node)
Returns the number of links adjacent to a node. The default implementation simply counts the number of links returned by the method getLinks(Object).

Parameters:
node - The node.

getNeighbors

public Enumeration getNeighbors(Object node)
Returns an enumeration of all the nodes that are the "neighbors" of node, that is, the nodes that have a common normal link with node. This method does not consider intergraph links.

The default implementation browses the links connected to node (the method getLinks(Object) is called) and returns an enumeration that gives you access to each of their opposite nodes (the method getOpposite(java.lang.Object, java.lang.Object) is called). An IllegalArgumentException is thrown if the argument is not a node of the graph.

In the case where a link that is incident to node is a self-link (that is, a link whose origin and destination are the same node), the enumeration does not contain node.

In the case of multiple links between node and one of its neighbors, the neighbor is contained in the enumeration the number of times equal to the number of links.

Parameters:
node - The node.
See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object)

getNodeDegree

public int getNodeDegree(Object node)
Returns the degree of a node, that is, the number of its neighbors.

The default implementation counts the number of elements in the enumeration returned by the method getNeighbors(java.lang.Object). However, if a node is contained in the enumeration returned by the method getNeighbors several times (for example, because node has more than one common link with a neighbor), this neighbor is counted just once.

Note that any overridden implementation must take care not to count the same neighbor several times.


getOpposite

public Object getOpposite(Object link,
                          Object node)
Returns the opposite node on a link. The default implementation determines the opposite node using calls of methods getFrom and getTo.

This method must work for intergraph links as well. Notice that for intergraph links, the input node and the returned node may not be nodes of this graph model (that is, isNode(java.lang.Object) may return false).

See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object)

getFrom

public abstract Object getFrom(Object link)
Returns the origin node of a link.

This method must work for normal links and for intergraph links. Notice that for intergraph links, the returned node may not be a node of this graph model (that is, isNode(java.lang.Object) may return false).

See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object)

getTo

public abstract Object getTo(Object link)
Returns the destination node of a link.

This method must work for normal links and for intergraph links. Notice that for intergraph links, the returned node may not be a node of this graph model (that is, isNode(java.lang.Object) may return false).

See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object)

isNode

public abstract boolean isNode(Object obj)
Returns true if an object is a valid node, and false otherwise.

Note that an object can be both a node and a graph; therefore, both this method and isSubgraph(java.lang.Object) can return true for the same object.

Parameters:
obj - The object to test.

isLink

public abstract boolean isLink(Object obj)
Returns true if the object is a valid normal link, and false otherwise.

The method must return false for intergraph links.

Parameters:
obj - The object to test.
See Also:
isInterGraphLink(java.lang.Object)

isInterGraphLink

public abstract boolean isInterGraphLink(Object obj)
Returns true if the object is a valid intergraph link, and false otherwise. An intergraph link is a link stored in a given graph that has an origin or destination not stored in this graph.

Parameters:
obj - The object to test.
Since:
JViews 5.0
See Also:
isLink(java.lang.Object), IlvGrapherAdapter.isInterGraphLink(java.lang.Object)

isSubgraph

public abstract boolean isSubgraph(Object obj)
Returns true if the object is a valid subgraph, and false otherwise. A subgraph is a node of this graph model (that is isNode(java.lang.Object) must return true) that represents a graph nested inside this graph. The method getGraphModel(java.lang.Object) is applied to subgraphs when performing a nested layout.

Parameters:
obj - The object to test.
Since:
JViews 5.0

isLinkBetween

public boolean isLinkBetween(Object node1,
                             Object node2)
Tests whether a normal link exists between two nodes. The default implementation browses the links that have node1 and node2 as their origin (the method getLinksFrom is called) and checks the other extremity for each link (the method getTo is called). The method does not check for intergraph links.

See Also:
isLink(java.lang.Object), isInterGraphLink(java.lang.Object)

setProperty

public void setProperty(Object nodeOrLink,
                        String key,
                        Object value)
Sets the value of a property for a node or a link. If value is null, the property is removed. Otherwise, the property value is set to value. The method must work for normal links and intergraph links.

The default implementation uses an internal data structure to store the binding between the node or link, the value of the property, and its key.

Parameters:
nodeOrLink - The node or link for which the property is to be set.
key - The key string for the property.
value - The new value of the property.
See Also:
getProperty(java.lang.Object, java.lang.String)

getProperty

public Object getProperty(Object nodeOrLink,
                          String key)
Returns the value of a property. The method returns null if the property does not exist. The method must work for normal links and intergraph links.

Parameters:
nodeOrLink - The node or link for which the property is to be retrieved.
key - The key string for the property.
See Also:
setProperty(java.lang.Object, java.lang.String, java.lang.Object)

setProperty

public void setProperty(String key,
                        Object value)
Sets the value of a property for the graph model. If value is null, the property is removed. Otherwise, the property value is set to value. The default implementation uses an internal data structure to store the binding between the node or link, the value of the property, and its key.

Parameters:
key - The key string for the property.
value - The new value of the property.
Since:
JViews 3.5
See Also:
getProperty(java.lang.Object, java.lang.String)

getProperty

public Object getProperty(String key)
Returns the value of a property of the graph model. The method returns null if the property does not exist.

Parameters:
key - The key string for the property.
Since:
JViews 3.5
See Also:
setProperty(java.lang.Object, java.lang.String, java.lang.Object)

addGraphModelListener

public void addGraphModelListener(GraphModelListener listener)
Adds a listener to listen for modifications of the graph models.

Parameters:
listener - The listener to add.
See Also:
removeGraphModelListener(ilog.views.graphlayout.GraphModelListener)

removeGraphModelListener

public void removeGraphModelListener(GraphModelListener listener)
Removes a listener added with addGraphModelListener.

Parameters:
listener - The listener to remove.
See Also:
addGraphModelListener(ilog.views.graphlayout.GraphModelListener)

structureChanged

public final void structureChanged(boolean adjusting)
Deprecated. Beginning with ILOG JViews 5.5, use the method fireGraphModelEvent(java.lang.Object, int, boolean) instead.

Notifies the GraphModelListener listeners that the topology of the graph has changed (nodes or links were added or removed).

It is the responsibility of the adapter classes to call this method any time the structure of the graph is changed (for example, when changes are due to user interaction).


geometryChanged

public final void geometryChanged(boolean adjusting)
Deprecated. Beginning with ILOG JViews 5.5, use the method fireGraphModelEvent(java.lang.Object, int, boolean) instead.

Notifies the graph model that the geometry of the graph has changed (nodes or links were moved or reshaped).


fireGraphModelEvent

public fi