ilog.views.sdm.renderer.graphlayout
Class IlvSwimLanesRenderer

java.lang.Object
  extended by ilog.views.sdm.renderer.IlvSDMRenderer
      extended by ilog.views.sdm.renderer.IlvFilterSDMRenderer
          extended by ilog.views.sdm.renderer.graphlayout.IlvSwimLanesRenderer
All Implemented Interfaces:
Serializable

public class IlvSwimLanesRenderer
extends IlvFilterSDMRenderer

The SwimLanes renderer is responsible for displaying "swim lanes."

Swim lanes are contiguous vertical or horizontal rectangular areas that usually span the whole view. Swim lanes are most often used in conjunction with a hierarchical graph layout algorithm. This algorithm has the ability to place the nodes of the graph automatically according to swim lanes. See IlvHierarchicalLayout and IlvSwimLaneConstraint for a detailed discussion of the hierarchical layout algorithm and swim lanes.

The swim lane renderer is not responsible for configuring the graph layout algorithm so that it creates swim lanes. This is done by using a GraphLayout renderer (see IlvGraphLayoutRenderer configured to use a hierarchical algorithm, and setting the SwimLaneConstraint property in the style sheet for appropriate groups of nodes.

The swim lane renderer is merely responsible for displaying the swim lanes. For this, it reads the SwimLaneConstraint property of each node of the graph from the style sheet to determine which nodes belong to the same swim lane. The swim lanes are then displayed as colored rectangles in the background of the view, with a label on top of each swim lane.

Since the SwimLaneConstraint property is also used to configure the hierarchical layout algorithm so that it places the nodes automatically in swim lanes, performing a hierarchical layout on the graph will also place the activities correctly according to their swim lanes. Note, however, that the IlvSwimLanesRenderer can be used without performing a node layout. Conversely, you can perform a node layout using swim lanes without actually displaying the swim lanes (to do this, just set the SwimLanes property to false).

In other words, you can use the IlvSwimLanesRenderer to only display swim lanes, but then the swim lanes may overlap. Performing a node layout will also make sure that the swim lanes do not overlap, and that the nodes are arranged as hierarchical graphs inside each swim lane.

Example

Suppose all the activities of a workflow process have a participant property identifying the workflow participant that performs the activity. Swim lanes are often used to represent the participant. Each swim lane represents a participant, and the activities are placed in the swim lane of their participant. This can be implemented very simply using the following rules:

 SDM {
     SwimLanes : "true";
 }
 node.activity {
     SwimLaneConstraint : "@participant";
 }
 

The first rule tells the SDM engine to display the swim lanes using an IlvSwimLanesRenderer. The second rule says that a swim lane must be displayed around all the activities that have the same participant property.

Rendering Properties

The look of the swim lanes can be customized with the following properties:

Note: IlvLaneRenderer is a simpler implementation of this feature.

Since:
JViews 5.5
See Also:
Serialized Form

Nested Class Summary
static class IlvSwimLanesRenderer.DefaultSwimLaneGraphic
          This class is used by the IlvSwimLanesRenderer to display swim lanes.
 
Field Summary
 
Fields inherited from class ilog.views.sdm.renderer.IlvFilterSDMRenderer
_renderer
 
Constructor Summary
IlvSwimLanesRenderer()
          Creates a new swim lanes renderer with a null filtered renderer.
IlvSwimLanesRenderer(IlvSDMRenderer renderer)
          Creates a new swim lanes renderer for a specified filtered renderer.
 
Method Summary
protected  void addViewListeners(IlvManagerView view)
          Adds the listeners that adjust the swim lanes when the view is resized or transformed.
 void adjustSpacing(float delta)
          Moves the swim lanes apart so that the spacing between swim lanes is augmented or decreased by delta.
 IlvRect computeBBox(IlvSDMEngine engine, IlvManagerView view, IlvTransformer t)
          Computes the rectangle that contains all the graphic objects of the manager for a given view.
 void createSwimLane(Object activity, String newLabel)
          Creates a new swim lane by adding the specified activity and setting its swim lane property to the specified value.
 void customize(IlvSDMEngine engine, Object object, IlvGraphic g, String[] pseudoClasses)
          Updates the swim lane of the node.
 float getAlpha()
          Returns the alpha channel of the colors allocated by this renderer.
 float getBrightness()
          Returns the brightness of the colors allocated by this renderer.
 String getDefaultSwimLanes()
          Returns the string that defines the default swim lanes.
 float getHue()
          Gets the "base" hue.
 int getLayer()
          Returns the manager layer to which the swim lane graphics will be added.
 int getMargin()
          Returns the width of the margin remaining around the objects of a swim lane.
 float getSaturation()
          Returns the saturation of the colors.
 int getScrollDelay()
          Returns the delay after which the swim lanes reappear when the view has been scrolled.
 Color getSwimLaneColor(int i)
          Returns the color of a swim lane.
 int getSwimLaneCount()
          Returns the number of swim lanes.
 String getSwimLaneLabel(int i)
          Returns the label of the specified swim lane.
 float getSwimLaneWidth(int index)
          Returns the width of a swim lane.
 boolean isAdjustingToView()
          Returns true if the swim lanes are dynamically adjusted according to the size of the view or not.
 boolean isAutoColor(int i)
          Returns true if the color of the specified swim lane has been set explicitly through setSwimLaneColor(int, java.awt.Color), or false if the color of the swim lane has been allocated automatically.
 boolean isDraggingEnabled()
          Returns true if the user is allowed to drag objects from one swim lane to another.
 boolean isEnabled()
          Returns true if swim lanes are enabled, or false if swim lanes are disabled.
 boolean isExtendingToSides()
          Returns true if the swim lanes extend to the sides of the view.
 boolean isHorizontal()
          Returns true if the swim lanes are horizontal, or false if they are vertical.
 boolean isOverlapsAllowed()
          Returns true if the swim lanes are allowed to overlap, or false otherwise.
 void moveSwimLane(IlvSDMEngine engine, int index, boolean rightOrDown)
          Shifts the position of a swim lane to the left, right, bottom or up.
protected  boolean needsViewListeners()
          Returns true, because this renderer needs to install listeners on all the views.
 void nodeGraphicAdded(IlvSDMEngine engine, Object object, IlvGraphic graphic, boolean redraw)
          Adds an object to its swim lane.
 void nodeGraphicBBoxChanged(IlvSDMEngine engine, Object node, IlvGraphic graphic, IlvRect oldBBox, IlvRect newBBox, String[] pseudoClasses)
          Moves the object from one swim lane to another, if dragging is enabled.
 void prepareRendering(IlvSDMEngine engine)
          Initializes the swim lane data structures.
 void propertyChanged(IlvSDMEngine engine, Object object, String propertyName, Object oldValue, Object newValue, IlvGraphic graphic)
          Updates the swim lane of the node.
 void removeAll(IlvSDMEngine engine)
          Cleans up the swim lanes.
 void removeNodeGraphic(IlvSDMEngine engine, Object node, IlvGraphic graphic, boolean redraw)
          Removes the object from its swim lane.
protected  void removeViewListeners(IlvManagerView view)
          Removes the listeners that adjust the swim lanes when the view is resized or transformed.
 void renderingDone(IlvSDMEngine engine)
          Draws the swim lanes.
 void setAdjustingToView(boolean adjusting)
          Specifies whether the swim lanes are dynamically adjusted according to the size of the view or not.
 void setAlpha(float alpha)
          Sets the alpha channel of the colors allocated by this renderer.
 void setBrightness(float brightness)
          Sets the brightness of the colors allocated by this renderer.
 void setDefaultSwimLanes(String lanes)
          Defines the default swim lanes to display.
 void setDraggingEnabled(boolean enabled)
          Allows the user to drag objects from one swim lane to another.
 void setEnabled(boolean enabled)
          Enables or disables swim lanes.
 void setExtendingToSides(boolean extending)
          Specifies whether the swim lanes extend to the sides of the view or not.
 void setHue(float hue)
          Sets the "base" hue.
 void setLayer(int layer)
          Sets the manager layer in which the swim lane graphics will be added.
 void setMargin(int margin)
          Sets the width of the margin remaining around the objects of a swim lane.
 void setOverlapsAllowed(boolean allowed)
          Allows or forbids the swim lanes to overlap.
 void setSaturation(float saturation)
          Sets the saturation of the colors allocated by this renderer.
 void setScrollDelay(int delay)
          Sets the delay after which the swim lanes reappear when the view has been scrolled.
 void setSwimLaneColor(int i, Color color)
          Changes the color of a swim lane.
 void setSwimLaneLabel(int i, String label)
          Sets the label of the specified swim lane.
 void setSwimLaneWidth(int index, float newWidth)
          Changes the width of a swim lane.
 
Methods inherited from class ilog.views.sdm.renderer.IlvFilterSDMRenderer
addLinkGraphic, addNodeGraphic, createLinkGraphic, createNodeGraphic, getEncapsulatedGraphic, getFilteredRenderer, getGraphicProperty, getLinkConnectionRectangle, linkGraphicAdded, moveResizeNodeGraphic, processServerAction, removeLinkGraphic, setFilteredRenderer, updateObjectProperties
 
Methods inherited from class ilog.views.sdm.renderer.IlvSDMRenderer
callMoveResizeNodeGraphic, convert, convert, getAlias, getAuxiliaryBean, getAuxiliaryBeans, getEngine, getLocation, getParameter, setAlias, setEngine, setLayerName, setParameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvSwimLanesRenderer

public IlvSwimLanesRenderer(IlvSDMRenderer renderer)
Creates a new swim lanes renderer for a specified filtered renderer.

Parameters:
renderer - The filtered renderer.

IlvSwimLanesRenderer

public IlvSwimLanesRenderer()
Creates a new swim lanes renderer with a null filtered renderer.

Method Detail

setLayer

public void setLayer(int layer)
Sets the manager layer in which the swim lane graphics will be added. By default, the swim lane graphics are added to layer 0.

Parameters:
layer - The index of the layer.

getLayer

public int getLayer()
Returns the manager layer to which the swim lane graphics will be added.


setDraggingEnabled

public void setDraggingEnabled(boolean enabled)
Allows the user to drag objects from one swim lane to another.

By default, dragging is enabled.

Parameters:
enabled - If true, when an object is dragged from one swim lane to another, the renderer will attempt to set the property that determines the object's swim lane.

For example, if the style sheet contains a rule such as:

 node.activity {
     SwimLaneConstraint : "@participant";
 }
 
then the renderer will set the participant property to the value corresponding to the swim lane in which the object was dropped.

If the parameter is false, dragging an object simply changes the swim lane's bounding box.


isDraggingEnabled

public boolean isDraggingEnabled()
Returns true if the user is allowed to drag objects from one swim lane to another.

See Also:
setDraggingEnabled(boolean)

setExtendingToSides

public void setExtendingToSides(boolean extending)
Specifies whether the swim lanes extend to the sides of the view or not.

By default, swim lanes do not extend to the sides of the view.

Parameters:
extending - If true, and if the layout direction is vertical, the leftmost swim lane will extend to the left side of the view, and the rightmost swim lane will extend to the right side of the view, so that the swim lanes cover the view entirely. For a horizontal layout, the swim lanes extend to the top and bottom of the view. If false, all swim lanes just surround the objects that belong to them, without extending to the sides of the view. Note that this parameter controls only the extension of swim lanes in the direction orthogonal to the layout direction; regardless of this parameter, the swim lanes always extend to the sides of the view in the direction of the layout, that is, to the top and bottom for a vertical layout and to to the left and right for a horizontal layout.

isExtendingToSides

public boolean isExtendingToSides()
Returns true if the swim lanes extend to the sides of the view.

See Also:
setExtendingToSides(boolean)

setAdjustingToView

public void setAdjustingToView(boolean adjusting)
Specifies whether the swim lanes are dynamically adjusted according to the size of the view or not.

Parameters:
adjusting - If true, the size of the swim lane graphics is always adjusted to the size of the view. This means, in particular, that the swim lane labels are always visible, even when you scroll the view. In this mode, the swim lanes cannot be displayed in the overview. If false, the swim lanes cover the whole bounding rectangle of the manager, and the labels are always at the very top (or left) of the manager, so they are not visible when you scroll. In this mode, the swim lanes are visible in the overview.

isAdjustingToView

public boolean isAdjustingToView()
Returns true if the swim lanes are dynamically adjusted according to the size of the view or not.


setOverlapsAllowed

public void setOverlapsAllowed(boolean allowed)
Allows or forbids the swim lanes to overlap.

Parameters:
allowed - If true, the bounding rectangle of a swim lane always contains entirely all the objects of the swim lane, even if this causes the swim lanes to overlap graphically. If false, the swim lanes will not overlap graphically, but the objects of a swim lane will sometimes be drawn partly outside the swim lane.

isOverlapsAllowed

public boolean isOverlapsAllowed()
Returns true if the swim lanes are allowed to overlap, or false otherwise.


setMargin

public void setMargin(int margin)
Sets the width of the margin remaining around the objects of a swim lane. The default margin is 10.

Parameters:
margin - The margin, in manager coordinates.

getMargin

public int getMargin()
Returns the width of the margin remaining around the objects of a swim lane.


setHue

public void setHue(float hue)
Sets the "base" hue. This value can be changed to modify the automatic color allocation algorithm.

Parameters:
hue - A value between 0 and 1.

getHue

public float getHue()
Gets the "base" hue. This value can be changed to modify the automatic color allocation algorithm.


setSaturation

public void setSaturation(float saturation)
Sets the saturation of the colors allocated by this renderer.

Parameters:
saturation - A value between 0 and 1.

getSaturation

public float getSaturation()
Returns the saturation of the colors.


setBrightness

public void setBrightness(float brightness)
Sets the brightness of the colors allocated by this renderer.

Parameters:
brightness - A value between 0 and 1.

getBrightness

public float getBrightness()
Returns the brightness of the colors allocated by this renderer.


setAlpha

public void setAlpha(float alpha)
Sets the alpha channel of the colors allocated by this renderer.

Parameters:
alpha - A value between 0 and 1.

getAlpha

public float getAlpha()
Returns the alpha channel of the colors allocated by this renderer.


setDefaultSwimLanes

public void setDefaultSwimLanes(String lanes)
Defines the default swim lanes to display. Default swim lanes are displayed even when there are no objects in them.

Parameters:
lanes - A String containing the names of the default swim lanes, separated by commas. For example: "Lane 1,Lane 2".

getDefaultSwimLanes

public String getDefaultSwimLanes()
Returns the string that defines the default swim lanes.

See Also:
setDefaultSwimLanes(java.lang.String)

setScrollDelay

public void setScrollDelay(int delay)
Sets the delay after which the swim lanes reappear when the view has been scrolled.

Swim lanes are normally hidden during scrolling interactions. You can use this method if you notice that swim lanes reappear in the middle of a scrolling interaction. The default delay is 200 milliseconds; specify a longer delay to get a smoother scroll.

Parameters:
delay - The amount of delay, in milliseconds.
Since:
JViews 5.5

getScrollDelay

public int getScrollDelay()
Returns the delay after which the swim lanes reappear when the view has been scrolled.

Since:
JViews 5.5
See Also:
setScrollDelay(int)

isEnabled

public boolean isEnabled()
Returns true if swim lanes are enabled, or false if swim lanes are disabled.

Since:
JViews 6.0
See Also:
setEnabled(boolean)

setEnabled

public void setEnabled(boolean enabled)
Enables or disables swim lanes.

By default, swim lanes are enabled.

Parameters:
enabled - If true, swim lanes are enabled: according to the SwimLaneConstraint rendering property, nodes will be dispatched to swim lanes, and swim lanes will be displayed graphically. When a node layout is performed, the layout algorithm will place nodes according to their swim lanes. If false, swim lanes are disabled: they are not displayed graphically, and the node layout algorithm will not take swim lanes into account.
Since:
JViews 6.0
See Also:
isEnabled()

prepareRendering

public void prepareRendering(IlvSDMEngine engine)
Initializes the swim lane data structures.

Overrides:
prepareRendering in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine.

nodeGraphicAdded

public void nodeGraphicAdded(IlvSDMEngine engine,
                             Object object,
                             IlvGraphic graphic,
                             boolean redraw)
Adds an object to its swim lane.

Overrides:
nodeGraphicAdded in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine associated with the grapher to which the graphic object has been added.
object - The object that is being translated into an IlvGraphic.
graphic - The graphic object that has just been added to the grapher.
redraw - If true, the region covered by the new graphic object must be redrawn.
See Also:
IlvSDMRenderer.addNodeGraphic(ilog.views.sdm.IlvSDMEngine, java.lang.Object, ilog.views.IlvGraphic, boolean)

removeNodeGraphic

public void removeNodeGraphic(IlvSDMEngine engine,
                              Object node,
                              IlvGraphic graphic,
                              boolean redraw)
Removes the object from its swim lane.

Overrides:
removeNodeGraphic in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine associated with the grapher from which the graphic object will be removed.
node - The node that has been removed from, or modified in, the data model.
graphic - The graphic object that must be removed from the grapher.
redraw - If true, the region covered by the graphic object must be redrawn.

propertyChanged

public void propertyChanged(IlvSDMEngine engine,
                            Object object,
                            String propertyName,
                            Object oldValue,
                            Object newValue,
                            IlvGraphic graphic)
Updates the swim lane of the node.

Overrides:
propertyChanged in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine associated with the grapher in which the graphic object is displayed.
object - The data object whose property has changed.
propertyName - The name of the property that has been modified.
oldValue - The old value of the property.
newValue - The new value of the property.
graphic - The graphic object associated with object.

customize

public void customize(IlvSDMEngine engine,
                      Object object,
                      IlvGraphic g,
                      String[] pseudoClasses)
Updates the swim lane of the node.

Overrides:
customize in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine associated with the grapher in which the graphic object is displayed.
object - The data object whose property has changed.
g - The graphic object associated with object.
pseudoClasses - The CSS pseudo-classes.
Since:
JViews 6.5

renderingDone

public void renderingDone(IlvSDMEngine engine)
Draws the swim lanes.

Overrides:
renderingDone in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine.

removeAll

public void removeAll(IlvSDMEngine engine)
Cleans up the swim lanes.

Overrides:
removeAll in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine.

needsViewListeners

protected boolean needsViewListeners()
Returns true, because this renderer needs to install listeners on all the views.

Overrides:
needsViewListeners in class IlvSDMRenderer
See Also:
IlvSDMRenderer.addViewListeners(ilog.views.IlvManagerView), IlvSDMRenderer.removeViewListeners(ilog.views.IlvManagerView)

addViewListeners

protected void addViewListeners(IlvManagerView view)
Adds the listeners that adjust the swim lanes when the view is resized or transformed.

Overrides:
addViewListeners in class IlvSDMRenderer
Parameters:
view - The manager view.
See Also:
IlvSDMRenderer.needsViewListeners()

removeViewListeners

protected void removeViewListeners(IlvManagerView view)
Removes the listeners that adjust the swim lanes when the view is resized or transformed.

Overrides:
removeViewListeners in class IlvSDMRenderer
Parameters:
view - The manager view.
See Also:
IlvSDMRenderer.needsViewListeners()

nodeGraphicBBoxChanged

public void nodeGraphicBBoxChanged(IlvSDMEngine engine,
                                   Object node,
                                   IlvGraphic graphic,
                                   IlvRect oldBBox,
                                   IlvRect newBBox,
                                   String[] pseudoClasses)
Moves the object from one swim lane to another, if dragging is enabled.

Overrides:
nodeGraphicBBoxChanged in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine.
node - The data node that the graphic object represents.
graphic - The graphic object that has been moved and/or resized.
oldBBox - The bounding box of the graphic object before the change.
newBBox - The bounding box of the graphic object after the change.
pseudoClasses - The pseudo-classes of the object. This parameter can be null.
See Also:
setDraggingEnabled(boolean)

computeBBox

public IlvRect computeBBox(IlvSDMEngine engine,
                           IlvManagerView view,
                           IlvTransformer t)
Computes the rectangle that contains all the graphic objects of the manager for a given view.

This method is overridden to leave some space above or on the left of the graph for the swim lane labels.

Overrides:
computeBBox in class IlvFilterSDMRenderer
Parameters:
engine - The SDM engine.
view - The manager view for which the bounding rectangle is computed.
t - The transformer used to compute the bounding box.
Returns:
The resulting rectangle.
Since:
JViews 5.5

isHorizontal

public boolean isHorizontal()
Returns true if the swim lanes are horizontal, or false if they are vertical. The direction of the swim lanes is determined by the direction of the graph layout algorithm.

Since:
JViews 6.0

getSwimLaneCount

public int getSwimLaneCount()
Returns the number of swim lanes.

Since:
JViews 6.0

getSwimLaneLabel

public String getSwimLaneLabel(int i)
Returns the label of the specified swim lane.

Parameters:
i - The index of the swim lane.
Since:
JViews 6.0

setSwimLaneLabel

public void setSwimLaneLabel(int i,
                             String label)
Sets the label of the specified swim lane.

Parameters:
i - The index of the swim lane.
label - The new label.
Since:
JViews 6.0

getSwimLaneColor

public Color getSwimLaneColor(int i)
Returns the color of a swim lane.

Parameters:
i - The index of the swim lane.
Since:
JViews 6.0

setSwimLaneColor

public void setSwimLaneColor(int i,
                             Color color)
Changes the color of a swim lane.

Parameters:
i - The index of the swim lane.
color - The new color.
Since:
JViews 6.0

isAutoColor

public boolean isAutoColor(int i)
Returns true if the color of the specified swim lane has been set explicitly through setSwimLaneColor(int, java.awt.Color), or false if the color of the swim lane has been allocated automatically.

Parameters:
i - The index of the swim lane.
Since:
JViews 6.0

moveSwimLane

public void moveSwimLane(IlvSDMEngine engine,
                         int index,
                         boolean rightOrDown)
Shifts the position of a swim lane to the left, right, bottom or up. The specified swim lane is swapped with the preceding or following swim lane.

Parameters:
engine - The SDM engine.
index - The index of the swim lane.
rightOrDown - If true, the swim lane is shifted to the right (if swim lanes are vertical) or to the bottom (if they are horizontal). If false, the swim lane is shifted to the left (if swim lanes are vertical) or to the top (if they are horizontal).
Since:
JViews 6.0

getSwimLaneWidth

public float getSwimLaneWidth(int index)
Returns the width of a swim lane.

Parameters:
index - The index of the swim lane.
Since:
JViews 6.0

setSwimLaneWidth

public void setSwimLaneWidth(int index,
                             float newWidth)
Changes the width of a swim lane. Note that the other swim lanes may also be resized and/or translated.

Parameters:
index - The index of the swim lane.
newWidth - The new width.
Since:
JViews 6.0

createSwimLane

public void createSwimLane(Object activity,
                           String newLabel)
Creates a new swim lane by adding the specified activity and setting its swim lane property to the specified value.

Parameters:
activity -
newLabel -
Since:
JViews 6.0

adjustSpacing

public void adjustSpacing(float delta)
Moves the swim lanes apart so that the spacing between swim lanes is augmented or decreased by delta.

Parameters:
delta - The amount by which the spacing between swim lanes is changed.
Since:
JViews 6.0


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