ilog.tgo.graphic.graphlayout
Class IltLocalLinkLayout

java.lang.Object
  extended by ilog.views.graphlayout.IlvGraphLayout
      extended by ilog.tgo.graphic.graphlayout.IltLocalLinkLayout
All Implemented Interfaces:
GraphModelListener, Serializable, EventListener

public class IltLocalLinkLayout
extends IlvGraphLayout

This is a simple link layout algorithm: All links are straight lines between the nearest sides of two nodes. A simple form of local disentanglement is applied.

Since:
JTGO 2.6
See Also:
Serialized Form

Field Summary
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.
 
Fields inherited from class ilog.views.graphlayout.IlvGraphLayout
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
 
Constructor Summary
IltLocalLinkLayout()
          Creates a new instance of the Local Link Layout algorithm.
IltLocalLinkLayout(IltLocalLinkLayout source)
          Creates a new layout instance by copying an existing one.
 
Method Summary
 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.
 float getLinkDistance()
           
 float 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(float distance)
           
 void setNodeBorderWidth(float 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.
 
Methods inherited from class ilog.views.graphlayout.IlvGraphLayout
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLink, checkAppropriateLinks, cleanGraphModel, cleanLink, cleanNode, clipAllLinks, clipLink, 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, isLayoutTimeElapsed, isMemorySavings, isParametersUpToDate, isPreserveFixedLinks, isPreserveFixedNodes, isSplineRoutingEnabled, isStoppedImmediately, isStructureUpToDate, isUseDefaultParameters, isUseSeedValueForRandomGenerator, layoutStepPerformed, onParameterChanged, onParameterChanged, performAutoLayout, performLayout, performLayout, performLayout, PerformLayout, performSublayout, removeGraphLayoutEventListener, removeGraphLayoutParameterEventListener, setAllowedTime, setAnimate, setAutoLayout, setAutoLayoutHandler, setBalanceSplineCurveThreshold, setCoordinatesMode, setFixed, setGeometryUpToDate, setGrapher, setGraphModel, setInputCheckEnabled, setLayoutOfConnectedComponents, setLayoutOfConnectedComponentsEnabled, setLayoutRegion, setLayoutRegion, setLayoutRegion, setLayoutReport, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AvoidZigZag

public static boolean AvoidZigZag
When set to true, zig-zag shapes with two acute angles will be turned into 90 deg. angles.

Internal method or field: do not use!

AvoidAcuteAngles

public static boolean AvoidAcuteAngles
When set to true, acute angles will be avoided by inserting additional points.

Internal method or field: do not use!
Constructor Detail

IltLocalLinkLayout

public IltLocalLinkLayout()
Creates a new instance of the Local Link Layout algorithm.


IltLocalLinkLayout

public IltLocalLinkLayout(IltLocalLinkLayout source)
Creates a new layout instance by copying an existing one. This constructor is used by the 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).

See Also:
copy(), copyParameters(ilog.views.graphlayout.IlvGraphLayout)
Method Detail

copy

public IlvGraphLayout copy()
Copies the layout instance.

This method copies the layout instance by calling the copy constructor.

Specified by:
copy in class IlvGraphLayout
Returns:
A copy of the layout instance.

getNodeBorderWidth

public float getNodeBorderWidth()
Internal method or field: do not use!

setNodeBorderWidth

public void setNodeBorderWidth(float width)
Internal method or field: do not use!

borderedBoundingBox

public IlvRect borderedBoundingBox(IlvGraphModel model,
                                   Object obj)
Internal method or field: do not use!

getLinkDistance

public float getLinkDistance()
Internal method or field: do not use!

setLinkDistance

public void setLinkDistance(float distance)
Internal method or field: do not use!

copyParameters

public void copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.

Overrides:
copyParameters in class IlvGraphLayout
Parameters:
source - The layout instance from which the parameters are copied.
See Also:
copy()

init

protected void init()
Description copied from class: IlvGraphLayout
Initializes instance variables.

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.

Overrides:
init in class IlvGraphLayout

commitConnection

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.

Parameters:
link - a link
node - one of the two ends of the link
side - the node's side on which the link has to start
Internal method or field: do not use!

getConnectionSocket

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.

Internal method or field: do not use!

connectLink

protected void connectLink(IlvGraphModel model,
                           Object link)
Connects a link to its ends, by calling commitConnection() once for each of the two ends. Does nothing for selflinks.

Internal method or field: do not use!

sortLinks

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. Returns the sorted vector of sockets. The sockets are sorted according to increasing values of `tangentDelta/radialDelta', i.e. links starting with a turn right (or ending with a turn left) come first, links starting with a turn left come last.

Internal method or field: do not use!

sortLinks

protected void sortLinks(IlvGraphModel model,
                         Object node)
Sorts all connections ending on a given node. Stores the sorted sockets table into getNodeData(node).sortedSockets.

Internal method or field: do not use!

connectSelfLink

protected void connectSelfLink(IlvGraphModel model,
                               Object link)
Internal method or field: do not use!

placeLinks

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.

Internal method or field: do not use!

placeLinks

protected void placeLinks(IlvGraphModel model,
                          Object node)
Adjusts all connections ending on a given node.

Internal method or field: do not use!

chooseShape

protected IlpPolyline chooseShape(IlvGraphModel model,
                                  Object link)
Chooses and returns the desired shape for a link.

Internal method or field: do not use!

layout

protected void layout(boolean redraw)
               throws IlvGraphLayoutException
Description copied from class: IlvGraphLayout
Executes the layout.

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, float, float, 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.

Here is a sample implementation for a Random layout:

 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();
   float xMin = rect.x;
   float yMin = rect.y;
   float xMax = rect.x + rect.width;
   float 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
     float x = xMin + (xMax - xMin) * random.nextFloat();
     float y = yMin + (yMax - yMin) * random.nextFloat();

     // 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.

Specified by:
layout in class IlvGraphLayout
Parameters:
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, float, float, boolean) and IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean).
Throws:
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.
See Also:
IlvGraphLayout.performLayout(boolean, boolean, boolean), IlvGraphLayout.getLayoutReport(), IlvGraphLayout.layoutStepPerformed(), IlvGraphModel


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.