public class IlvLayoutGraphicFilter extends Object implements IlvGraphicFilter
IlvGrapher
). The accept(ilog.views.IlvGraphic, ilog.views.graphlayout.IlvGrapherAdapter)
method of the filter is called by
the IlvGrapherAdapter
to know for any node and link whether
the node or link must be taken into account or if it must be
completely ignored.
To install a filter on an IlvGrapherAdapter
instance, use
the method IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
.
Note that all overridden implementations of the method accept(ilog.views.IlvGraphic, ilog.views.graphlayout.IlvGrapherAdapter)
must respect the following rules:
IlvGraphLayout.performLayout()
is running, the filter
must always return the same value for the same node or link. In other
words, the structure of the graph must not change while the layout is
running.IlvLayoutGraphicFilter
:
IlvGraphModel model = getGrapherAdapter(); int type = GraphModelEvent.STRUCTURE_CHANGED; // Version #1: there is a single node (or link) that the filter now // accepts while previously it rejected it type |= GraphModelEvent.NODE_ADDED; // or LINK_ADDED model.fireGraphModelEvent(nodeOrLink, type, false); // Version #2: there is a single node (or link) that the filter now // rejects while previously it accepted it type |= GraphModelEvent.NODE_REMOVED; // or LINK_REMOVED model.fireGraphModelEvent(nodeOrLink, type, false); // Version #3: there are several nodes and links that were previously // rejected and now are accepted and vice-versa // You can either fire a global STRUCTURE_CHANGED event: type |= GraphModelEvent.STRUCTURE_CHANGED; model.fireGraphModelEvent(null, type, false); // or browse each of these nodes or links and throw an individual event // (use the value true for the adjusting flag, and call // model.adjustmentEnd() at the end). grapherAdapter.fireGraphModelEvent(null, GraphModelEvent.STRUCTURE_CHANGED, false);
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
Constructor and Description |
---|
IlvLayoutGraphicFilter()
Creates a new
IlvLayoutGraphicFilter . |
IlvLayoutGraphicFilter(IlvGraphLayout layout)
Deprecated.
Beginning with JViews 3.0, you should use the constructor
without any arguments and specify the filter using the method
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter) . |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(IlvGraphic nodeOrLink)
Returns
true if the graphic object
nodeOrLink is a node or a link that must be taken into
account during the layout. |
boolean |
accept(IlvGraphic nodeOrLink,
IlvGrapherAdapter adapter)
Returns
true if the graphic object
nodeOrLink is a node or a link that must be taken into
account during the layout. |
IlvGrapherAdapter |
getGrapherAdapter()
Returns the
IlvGrapherAdapter with which the filter is
associated. |
IlvGraphLayout |
getLayout()
Deprecated.
Beginning with JViews 3.0, the filter is no longer
associated with a layout instance
|
public IlvLayoutGraphicFilter()
IlvLayoutGraphicFilter
. To install a filter
on an IlvGrapherAdapter
instance, use the method
IlvGrapherAdapter.setFilter
.IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
public IlvLayoutGraphicFilter(IlvGraphLayout layout)
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
.IlvLayoutGraphicFilter
This creates a
filter for the layout instance layout
. To install a
filter on an IlvGrapherAdapter
instance, use the method
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
.IlvLayoutGraphicFilter()
public IlvGrapherAdapter getGrapherAdapter()
IlvGrapherAdapter
with which the filter is
associated. This can only be used inside the accept(IlvGraphic)
method.public IlvGraphLayout getLayout()
public boolean accept(IlvGraphic nodeOrLink, IlvGrapherAdapter adapter)
true
if the graphic object
nodeOrLink
is a node or a link that must be taken into
account during the layout. Call this method to test whether the node
or link is accepted. This method stores the grapher adapter and then
calls the method accept(IlvGraphic)
, which can be
overridden.getGrapherAdapter()
public boolean accept(IlvGraphic nodeOrLink)
true
if the graphic object
nodeOrLink
is a node or a link that must be taken into
account during the layout. You can override this method in
subclasses, but you should not call this method. Call accept(IlvGraphic, IlvGrapherAdapter)
instead.
If no layers are specified using the method IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer)
on the adapter instance on which the
filter is installed, or if all the layers of the IlvGrapher
are specified, the method returns true
for node or link
contained in the grapher encapsulated by the adapter. Otherwise, it
returns true
only for objects on the specified layers.
This method can be overridden in order to specify other conditions for filtering the nodes and the links. The overridden implementation should first check if the node or link is accepted in the superclass:
if (!super.accept(nodeOrLink)) return false;Only after that other specific filtering rules should be applied.
Note that any overridden implementation of this method must respect the following rules:
IlvLayoutGraphicFilter
):
IlvGraphModel model = getGrapherAdapter(); int type = GraphModelEvent.STRUCTURE_CHANGED; // Version #1: there is a single node (or link) that the filter now // accepts while previously it rejected it type |= GraphModelEvent.NODE_ADDED; // or LINK_ADDED model.fireGraphModelEvent(nodeOrLink, type, false); // Version #2: there is a single node (or link) that the filter now // rejects while previously it accepted it type |= GraphModelEvent.NODE_REMOVED; // or LINK_REMOVED model.fireGraphModelEvent(nodeOrLink, type, false); // Version #3: there are several nodes and links that were previously // rejected and now are accepted and vice-versa // You can either fire a global STRUCTURE_CHANGED event: type |= GraphModelEvent.STRUCTURE_CHANGED; model.fireGraphModelEvent(null, type, false); // or browse each of these nodes or links and throw an individual event // (use the value true for the adjusting flag, and call // model.adjustmentEnd() at the end).
The method throws a RuntimeException
if the layout
instance has no attached grapher.
accept
in interface IlvGraphicFilter
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.