public class IlpSubnetworkPositionLayout extends IlvGraphLayout
The algorithm will identify expanded subnetworks and adjust their center point to coincide with the center point of the collapsed representation.
It is particularly useful when a subnetwork has a graph layout but the main view does not. In this scenario, the graph layout of the subnetwork will adjust the position of the subnodes freely, forcing the collapsed representation to move. In order to ensure that the collapsed representation does not move, this layout should be set it the main view as follows:
Using the API:
// Set graph layout for a given subnetwork IlvGraphLayout subnetworkLayout = ... IlpRepresentationObject ro = networkComponent.getAdapter().getRepresentationObject("subnetID"); networkComponent.getView().setGraphLayouts(ro, new IlvGraphLayout[] { subnetworkLayout }); // Set graph layout for the main view IlvGraphLayout viewLayout = new IlpSubnetworkPositionLayout(); networkComponent.getView().setGraphLayouts(new IlvGraphLayout[] { viewLayout }); // Perform layout networkComponent.getView().performAttachedLayout(0); // Remove layouts networkComponent.getView().setGraphLayouts(ro, new IlvGraphLayout[] { }); networkComponent.getView().setGraphLayouts(new IlvGraphLayout[] { });
Using CSS:
GraphLayout { layouts[0]: @+subnetPositionLayout; autoLayoutIndex: -1; } Subobject#subnetPositionLayout { class: 'ilog.cpl.graph.graphlayout.IlpSubnetworkPositionLayout'; } #subnetID:graphLayoutRenderer { layouts[0]: @+someLayout; autoLayoutIndex: -1; } Subobject#someLayout { class: 'some.layout.Class'; }
Note: Like any other layout, this layout impacts performance when active. It is recommended to remove any active layout when interacting with the main view, to minimize the layout processing impacting the UI responsiveness of your application.
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
Modifier | Constructor and Description |
---|---|
|
IlpSubnetworkPositionLayout()
Constructor.
|
protected |
IlpSubnetworkPositionLayout(IlpSubnetworkPositionLayout layout)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
IlvGraphLayout |
copy()
Copies the layout instance.
|
protected void |
layout(boolean redraw)
Executes the layout.
|
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLink, checkAppropriateLinks, cleanGraphModel, cleanLink, cleanNode, clipAllLinks, clipLink, connectAllLinksToCenter, connectLinkToCenter, contentsChanged, copyParameters, createLayoutGrapherProperty, createLayoutLinkProperty, createLayoutNodeProperty, createLayoutReport, detach, getAllowedTime, getAutoLayoutHandler, getBalanceSplineCurveThreshold, getCalcLayoutRegion, getCoordinatesMode, getGrapher, getGraphModel, getInstanceId, getLayout, getLayoutOfConnectedComponents, getLayoutOfConnectedComponentsReport, getLayoutRegion, getLayoutReport, getLayouts, getLinkClipInterface, getLinkConnectionBoxInterface, getMaxSplineCurveSize, getMinBusyTime, getMinSplineCurveSize, getMovingNodes, getParentLayout, getProperty, getProperty, getRecursiveLayout, getRemainingAllowedTime, getSeedValueForRandomGenerator, getSpecLayoutRegion, getSplineLinkFilter, increasePercentageComplete, init, isAnimate, isAutoLayout, isFitToView, isFixed, isGeometryUpToDate, isInputCheckEnabled, isLayoutNeeded, isLayoutOfConnectedComponentsEnabled, isLayoutOfConnectedComponentsEnabledByDefault, isLayoutRunning, isLayoutRunning, isLayoutTimeElapsed, isLocalRecursiveLayoutNeeded, isMemorySavings, isParametersUpToDate, isPreserveFixedLinks, isPreserveFixedNodes, isSplineRoutingEnabled, isStoppedImmediately, isStructureUpToDate, isUseDefaultParameters, isUseSeedValueForRandomGenerator, layoutStepPerformed, onParameterChanged, onParameterChanged, performAutoLayout, performLayout, performLayout, performLayout, PerformLayout, performSublayout, removeGraphLayoutEventListener, removeGraphLayoutParameterEventListener, setAllowedTime, setAnimate, setAutoCheckAppropriateLinksEnabled, setAutoLayout, setAutoLayoutHandler, setBalanceSplineCurveThreshold, setCoordinatesMode, setFixed, setGeometryUpToDate, setGrapher, setGraphModel, setInputCheckEnabled, setLayoutOfConnectedComponents, setLayoutOfConnectedComponentsEnabled, setLayoutRegion, setLayoutRegion, setLayoutRegion, setLayoutReport, setLayoutRunning, setLinkClipInterface, setLinkConnectionBoxInterface, setMaxSplineCurveSize, setMemorySavings, setMinBusyTime, setMinSplineCurveSize, setParametersUpToDate, setParentLayout, setPreserveFixedLinks, setPreserveFixedNodes, setProperty, setProperty, setSeedValueForRandomGenerator, setSplineLinkFilter, setSplineRoutingEnabled, setStructureUpToDate, setUseDefaultParameters, setUseSeedValueForRandomGenerator, stopImmediately, supportsAllowedTime, supportsAnimation, supportsLayoutOfConnectedComponents, supportsLayoutRegion, supportsLinkClipping, supportsLinkConnectionBox, supportsMemorySavings, supportsPercentageComplete, supportsPreserveFixedLinks, supportsPreserveFixedNodes, supportsRandomGenerator, supportsSaveParametersToNamedProperties, supportsSplineRouting, supportsStopImmediately, unfixAllLinks, unfixAllNodes, useAnimateRedraw
public IlpSubnetworkPositionLayout()
Instantiates the layout.
protected IlpSubnetworkPositionLayout(IlpSubnetworkPositionLayout layout)
Instantiates a copy of the given layout.
layout
- The layout to copy.public IlvGraphLayout copy()
IlvGraphLayout
This method must return a copy of this layout instance by calling a constructor defined as follows:
public <CLASSNAME>(<CLASSNAME> source)
.
When performing a recursive layout on a nested graph, this method is
used by IlvLayoutProvider
to "clone" the layout instance of a
parent graph.
Note that the parameters which are specific to a node or a link are
not copied. The other parameters, including the layout region
specification and the link clip and link connection box interfaces,
are also copied. If the method IlvGraphLayout.supportsLayoutOfConnectedComponents()
returns true
, a
copy of the layout instance used for laying out the connected
components is set on the new instance.
If a method of the type supportsXXX
is associated with a
parameter, the parameter is copied only if the corresponding method
returns true
.
copy
in class IlvGraphLayout
protected void layout(boolean redraw) throws IlvGraphLayoutException
IlvGraphLayout
This method must be implemented by each layout algorithm (subclasses
of IlvGraphLayout
). This method computes the coordinates
of the nodes in the attached graph model and moves the nodes to the
new positions using the method IlvGraphModel.moveNode(java.lang.Object, double, double, boolean)
.
The method can also perform reshape operations on the links using the
method IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean)
. Any implementation of this
method must pass, for the redraw
argument of these two
methods, the same value as the one it receives.
When using a subclass of IlvGraphLayout
, refer to the
documentation of the subclass to know when this method throws an
exception.
When writing the implementation of this method, you can obtain an
instance of the layout report using IlvGraphLayout.getLayoutReport()
and
store particular information about the behavior of the layout
algorithm in the layout report. You can also notify the layout event
listeners using the method IlvGraphLayout.layoutStepPerformed()
.
When the layout algorithm is finished and if the layout is performed
successfully, you must call the method IlvGraphLayoutReport.setCode(int)
with the argument IlvGraphLayoutReport.LAYOUT_DONE
on the layout report instance.
protected void layout(boolean redraw) throws IlvGraphLayoutException { // obtain the graph model IlvGraphModel graphModel = getGraphModel(); // obtain the layout report IlvGraphLayoutReport layoutReport = getLayoutReport(); boolean atLeastOneNodeMoved = false; // obtain the layout region IlvRect rect = getCalcLayoutRegion(); double xMin = rect.x; double yMin = rect.y; double xMax = rect.x + rect.width; double yMax = rect.y + rect.height; // initialize the random generator Random random = (isUseSeedValueForRandomGenerator()) ? new Random(getSeedValueForRandomGenerator()) : new Random(); // get an enumeration of the nodes Enumeration nodes = graphModel.getNodes(); // browse the nodes while (nodes.hasMoreElements()) { Object node = nodes.nextElement(); // skip fixed nodes if (isPreserveFixedNodes() && isFixed(node)) continue; // compute coordinates double x = xMin + (xMax - xMin) * random.nextDouble(); double y = yMin + (yMax - yMin) * random.nextDouble(); // move the node to the computed position graphModel.moveNode(node, x, y, redraw); atLeastOneNodeMoved = true; // notify listeners on layout events layoutStepPerformed(); } if (atLeastOneNodeMoved) layoutReport.setCode(IlvGraphLayoutReport.LAYOUT_DONE); else layoutReport.setCode(IlvGraphLayoutReport.NO_MOVEABLE_NODE); }
Note that, beginning with JViews 3.5, the signature of the old method
protected abstract void layout()
has changed. When
writing a new layout algorithm, the method IlvGraphLayout.layout(boolean)
must be implemented instead.
layout
in class IlvGraphLayout
redraw
- If true
, the attached graph model will be
asked to redraw the graph after layout. When the layout algorithm
moves the nodes and reshapes the links, it is required to pass the
value of the redraw
argument to the methods IlvGraphModel.moveNode(java.lang.Object, double, double, boolean)
and IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean)
.IlvGraphLayoutException
- If an unusual situation occurs.
WARNING: this method can throw one of the subclasses of IlvGraphLayoutException
. Specifically, it can throw an IlvInappropriateGraphException
. It can also throw an IlvInappropriateLinkException
when inappropriate types of links
and/or link connectors are used in an IlvGrapher
. For
details, refer to the documentation of these exception classes.IlvGraphLayout.performLayout(boolean, boolean, boolean)
,
IlvGraphLayout.getLayoutReport()
,
IlvGraphLayout.layoutStepPerformed()
,
IlvGraphModel
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.