public class IltLocalLinkLayout extends IlvGraphLayout
Modifier and Type | Field and Description |
---|---|
static boolean |
AvoidAcuteAngles
When set to true, acute angles will be avoided by inserting additional
points.
|
static boolean |
AvoidZigZag
When set to true, zig-zag shapes with two acute angles will be turned
into 90 deg. angles.
|
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
Constructor and Description |
---|
IltLocalLinkLayout()
Creates a new instance of the Local Link Layout algorithm.
|
IltLocalLinkLayout(IltLocalLinkLayout source)
Creates a new layout instance by copying an existing one.
|
Modifier and Type | Method and Description |
---|---|
IlvRect |
borderedBoundingBox(IlvGraphModel model,
Object obj) |
protected IlpPolyline |
chooseShape(IlvGraphModel model,
Object link)
Chooses and returns the desired shape for a link.
|
protected void |
commitConnection(IlvGraphModel model,
Object link,
Object node,
ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.NodeSide side)
Registers that a given link to a given node is to be connected at a
given side of this node.
|
protected void |
connectLink(IlvGraphModel model,
Object link)
Connects a link to its ends, by calling commitConnection() once for
each of the two ends.
|
protected void |
connectSelfLink(IlvGraphModel model,
Object link) |
IlvGraphLayout |
copy()
Copies the layout instance.
|
void |
copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.
|
protected ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.Socket |
getConnectionSocket(IlvGraphModel model,
Object link,
Object node)
Once commitConnection has been called with a link and a node as arguments,
returns the socket where the link starts.
|
double |
getLinkDistance() |
double |
getNodeBorderWidth() |
protected void |
init()
Initializes instance variables.
|
protected void |
layout(boolean redraw)
Executes the layout.
|
protected void |
placeLinks(IlvGraphModel model,
Object node)
Adjusts all connections ending on a given node.
|
protected void |
placeLinks(IlvGraphModel model,
Object node,
ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.NodeSide side)
Adjusts all connections ending on a given node, at a given side.
|
void |
setLinkDistance(double distance) |
void |
setNodeBorderWidth(double width) |
protected void |
sortLinks(IlvGraphModel model,
Object node)
Sorts all connections ending on a given node.
|
protected Vector |
sortLinks(IlvGraphModel model,
Object node,
ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.NodeSide side)
Sorts the links ending on a given node, at a given side, so as
to avoid unnecessary crossings.
|
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLink, checkAppropriateLinks, cleanGraphModel, cleanLink, cleanNode, clipAllLinks, clipLink, connectAllLinksToCenter, connectLinkToCenter, contentsChanged, 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, 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 static boolean AvoidZigZag
public static boolean AvoidAcuteAngles
public IltLocalLinkLayout()
public IltLocalLinkLayout(IltLocalLinkLayout source)
copy()
method.
Any subclass should provide a copy constructor.
The parameters of the source
layout are copied using
the method copyParameters(ilog.views.graphlayout.IlvGraphLayout)
.
public IlvGraphLayout copy()
This method copies the layout instance by calling the copy constructor.
copy
in class IlvGraphLayout
public double getNodeBorderWidth()
public void setNodeBorderWidth(double width)
public IlvRect borderedBoundingBox(IlvGraphModel model, Object obj)
public double getLinkDistance()
public void setLinkDistance(double distance)
public void copyParameters(IlvGraphLayout source)
copyParameters
in class IlvGraphLayout
source
- The layout instance from which the parameters are copied.copy()
protected void init()
IlvGraphLayout
You should not call this method directly. The method is called internally by the constructor without arguments and by the copy constructor.
The method must be overridden by subclasses that need to initialize additional instance variables. The initialization of all the instance variables of the subclasses must be done in this method.
init
in class IlvGraphLayout
protected void commitConnection(IlvGraphModel model, Object link, Object node, ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.NodeSide side)
link
- a linknode
- one of the two ends of the linkside
- the node's side on which the link has to startprotected ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.Socket getConnectionSocket(IlvGraphModel model, Object link, Object node)
protected void connectLink(IlvGraphModel model, Object link)
protected Vector sortLinks(IlvGraphModel model, Object node, ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.NodeSide side)
protected void sortLinks(IlvGraphModel model, Object node)
protected void connectSelfLink(IlvGraphModel model, Object link)
protected void placeLinks(IlvGraphModel model, Object node, ilog.tgo.graphic.graphlayout.IltLocalLinkLayout.NodeSide side)
protected void placeLinks(IlvGraphModel model, Object node)
protected IlpPolyline chooseShape(IlvGraphModel model, Object link)
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.