ilog.tgo.graphic.graphlayout
Class IltStraightLinkLayout

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

public class IltStraightLinkLayout
extends IlvGraphLayout

This is a very simple link layout algorithm: All links are straight lines connecting the midpoints of their end points.

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.

See Also:
Serialized Form

Field Summary
static int CENTERED_PINS
          Centered connector pin option.
static int CLIPPED_PINS
          Clipped connector pin option.
 
Fields inherited from class ilog.views.graphlayout.IlvGraphLayout
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
 
Constructor Summary
IltStraightLinkLayout()
          Creates a new instance of the Straight Link Layout algorithm.
IltStraightLinkLayout(IltStraightLinkLayout source)
          Creates a new layout instance by copying an existing one.
 
Method Summary
 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.
 
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

CENTERED_PINS

public static final int CENTERED_PINS
Centered connector pin option. When used as the argument of the method setConnectorStyle(int), the connector pins of links are placed at the center of the node the link is attached to.

See Also:
Constant Field Values

CLIPPED_PINS

public static final int CLIPPED_PINS
Clipped connector pin option. When used as the argument of the method setConnectorStyle(int), the connector pins of links are placed such that the link pointing toward the node center is clipped at the node border.

See Also:
Constant Field Values
Constructor Detail

IltStraightLinkLayout

public IltStraightLinkLayout()
Creates a new instance of the Straight Link Layout algorithm.


IltStraightLinkLayout

public IltStraightLinkLayout(IltStraightLinkLayout 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.

getConnectorStyle

public int getConnectorStyle()
Returns the current option for the style of the connectors.

See Also:
setConnectorStyle(int)

setConnectorStyle

public void setConnectorStyle(int style)
Sets the option for the style of connectors. Valid values are:

The default value is CLIPPED_PINS.


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

layoutOneLink

protected void layoutOneLink(IlvGraphModel graphModel,
                             Object link,
                             IlvRect frombbox,
                             IlvRect tobbox,
                             int connectorStyle,
                             boolean redraw)
                      throws IlvGraphLayoutException
Throws:
IlvGraphLayoutException
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.