public class IltStraightLinkLayout extends IlvGraphLayout
Note: With this graph layout, self links will not be displayed satisfactorily. Also, multiple links with the same "from" and "to" ends will be displayed on top of each other.
Modifier and Type | Field and Description |
---|---|
static int |
CENTERED_PINS
Centered connector pin option.
|
static int |
CLIPPED_PINS
Clipped connector pin option.
|
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
Constructor and Description |
---|
IltStraightLinkLayout()
Creates a new instance of the Straight Link Layout algorithm.
|
IltStraightLinkLayout(IltStraightLinkLayout source)
Creates a new layout instance by copying an existing one.
|
Modifier and Type | Method and Description |
---|---|
IlvGraphLayout |
copy()
Copies the layout instance.
|
void |
copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.
|
int |
getConnectorStyle()
Returns the current option for the style of the connectors.
|
protected void |
init()
Initializes instance variables.
|
protected void |
layout(boolean redraw)
Executes the layout.
|
protected void |
layoutOneLink(IlvGraphModel graphModel,
Object link,
IlvRect frombbox,
IlvRect tobbox,
int connectorStyle,
boolean redraw) |
void |
setConnectorStyle(int style)
Sets the option for the style of connectors.
|
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 final int CENTERED_PINS
setConnectorStyle(int)
, the connector pins of links are placed
at the center of the node the link is attached to.public static final int CLIPPED_PINS
setConnectorStyle(int)
, the connector pins of links are placed
such that the link pointing toward the node center is clipped at the node
border.public IltStraightLinkLayout()
public IltStraightLinkLayout(IltStraightLinkLayout 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 int getConnectorStyle()
setConnectorStyle(int)
public void setConnectorStyle(int style)
CENTERED_PINS
- the link connector pins are placed
in the center of the node the link is attached to.
CLIPPED_PINS
- each link pointing to the center of
the node is clipped at the node border.
The default value is CLIPPED_PINS
.
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 layoutOneLink(IlvGraphModel graphModel, Object link, IlvRect frombbox, IlvRect tobbox, int connectorStyle, boolean redraw) throws IlvGraphLayoutException
IlvGraphLayoutException
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 Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.