ilog.views.graphlayout.labellayout
Class IlvDefaultLabelingModel

java.lang.Object
  extended by ilog.views.graphlayout.labellayout.IlvLabelingModel
      extended by ilog.views.graphlayout.labellayout.IlvDefaultLabelingModel
All Implemented Interfaces:
IlvLabelingModelWithRotation

public class IlvDefaultLabelingModel
extends IlvLabelingModel
implements IlvLabelingModelWithRotation

An IlvDefaultLabelingModel provides a default labeling model for an IlvManager and provides a bridge between the API of the IlvManager and the API of the IlvLabelingModel.

IlvDefaultLabelingModel is a concrete subclass of IlvLabelingModel that allows IlvGraphic objects of an IlvManager to be labels or obstacles. It handles objects of the following types as labels:

It handles all other objects as obstacles. It provides an implementation for all the abstract methods of IlvLabelingModel.

The default labeling model is optimized to handle polyline graphics and polyline links efficiently. It can be used to place labels at links of type IlvPolylineLinkImage. However, it currently does not handle splines very precisely, because this would be very costly. It uses a rough approximation for splines.

If labels of any other subclass of IlvGraphic should be positioned, it is sufficient to override the method isDefaultLabelClass(java.lang.Object). If only a subset of IlvGraphic objects should be obstacles, it is sufficient to override the method isDefaultObstacleClass(java.lang.Object).

As an alternative to subclassing, the user can call the methods setLabel(java.lang.Object, boolean) and setObstacle(java.lang.Object, boolean) to redefine for individual objects whether they are labels or obstacles.

If an application uses the class IlvManager, the manager can be attached directly to the layout instance, without explicitly using a labeling model (see the method IlvLabelLayout.attach(IlvManager). In this case, an IlvDefaultLabelingModel will be internally created. This default model can be retrieved using the method IlvLabelLayout.getLabelingModel(), which will return an instance of IlvDefaultLabelingModel.

Note that you must call the method dispose() after detaching the label layouts when you no longer need the labeling model instance; otherwise, some objects may not be garbage collected. This is necessary only if the labeling model instance is directly created by your code. Calling dispose() is not necessary if the labeling model instance is created internally by the ILOG JViews Graph Layout library, for instance when attaching directly an IlvManager to a layout instance using IlvLabelLayout.attach(IlvManager).

Since:
JViews 5.0

Constructor Summary
IlvDefaultLabelingModel(IlvManager manager)
          Creates a new labeling model for a given IlvManager.
 
Method Summary
 void addLayer(IlvManagerLayer layer)
          Adds a manager layer to the list of layers to be used during the label layout.
 void afterLayout(IlvLabelLayout layout, IlvLabelLayoutReport layoutReport, boolean redraw)
          Notifies the labeling model that a layout session has finished.
 void beforeLayout(IlvLabelLayout layout, boolean redraw)
          Notifies the labeling model that a layout session has been started.
 IlvRect boundingBox(Object labelOrObstacle)
          Returns the bounding rectangle of a label or obstacle.
 IlvLabelingModel createLabelingModel(Object subgraph)
          Creates a new IlvDefaultLabelingModel for a subgraph.
 void dispose()
          Disposes of this IlvDefaultLabelingModel and releases any resources that it is using.
 int getCoordinatesMode()
          Returns the current coordinates mode.
 double getLabelOverlap(Object label1, IlvRect rect1, double angle1, Object label2, IlvRect rect2, double angle2, float minDist)
          Returns the overlap between two labels, if the labels would be at the given positions specified by the passed rectangles and the rotation angle.
 double getLabelOverlap(Object label1, IlvRect bbox1, Object label2, IlvRect bbox2, float minDist)
          Returns the overlap between two labels, if the labels would be at the given positions specified by the passed bounding boxes.
 Enumeration getLabels()
          Returns the enumeration of all labels.
 Enumeration getLayers()
          Returns an enumeration of the manager layers to be taken into account during the label layout.
 int getLayersCount()
          Returns the number of manager layers to be taken into account during the label layout.
 IlvManager getManager()
          Returns the IlvManager that stores the labels and the obstacles.
 double getObstacleOverlap(Object label, IlvRect labelRect, double angle, Object obstacle, IlvRect obstacleBBox, float minDist)
          Returns the overlap between the label and the obstacle, if the label would be at the given position specified by the passed rectangle and the rotation angle.
 double getObstacleOverlap(Object label, IlvRect labelBBox, Object obstacle, IlvRect obstacleBBox, float minDist)
          Returns the overlap between the label and the obstacle, if the label would be at the given position specified by the passed bounding box.
 Enumeration getObstacles()
          Returns the enumeration of all obstacles.
 double getPolylineObstacleOverlap(Object label, IlvRect labelRect, double angle, Object polylineObstacle, IlvPoint[] pts, float lineWidth, float minDist)
          Returns the overlap between the label and the polyline obstacle, if the label would be at the given position specified by the passed rectangle and the rotation angle.
 double getPolylineObstacleOverlap(Object label, IlvRect labelBBox, Object polylineObstacle, IlvPoint[] pts, float lineWidth, float minDist)
          Returns the overlap between the label and the polyline obstacle, if the label would be at the given position specified by the passed bounding box.
 IlvPoint[] getPolylinePoints(Object polylineObstacle)
          Returns the points that define the shape of a polyline obstacle.
 float getPolylineWidth(Object polylineObstacle)
          Returns the line width of a polyline obstacle.
 Object getProperty(Object labelOrObstacle, String key)
          Returns the value of a property.
 Object getProperty(String key)
          Returns the value of a property of the labeling model.
 IlvTransformer getReferenceTransformer()
          Returns the transformer to be taken into account.
 IlvManagerView getReferenceView()
          Returns the specified reference view (if any) and null otherwise.
 double getRotation(Object label, IlvRect rect)
          Returns the rotation of the label if it were placed at the position given by the input rectangle rect.
 boolean isBoundingBoxDependent()
          Returns true if two objects overlap only if their bounding boxes overlap.
protected  boolean isDefaultLabelClass(Object obj)
          Returns true if the class of the object is the default labeling class.
protected  boolean isDefaultObstacleClass(Object obj)
          Returns true if the class of the object is the default obstacle class.
 boolean isFullLayerNotification()
          Returns true if adding or removing a layer sends a separate event for each object contained in the layer.
 boolean isLabel(Object obj)
          Returns true if an object is a valid label and false otherwise.
 boolean isLayerAdded(IlvManagerLayer layer)
          Returns true if the manager layer is one of the layers to be taken into account during the layout.
 boolean isLayoutNeeded(IlvLabelLayout layout)
          Returns true if a given layout that has been already applied to this manager is still valid.
 boolean isObstacle(Object obj)
          Returns true if an object is a valid obstacle and false otherwise.
 boolean isPolylineObstacle(Object obj)
          Returns true if an object is a valid polyline obstacle and false otherwise.
 boolean loadParametersFromNamedProperties(IlvLabelLayout layout)
          Transfers the layout parameter settings from the named properties of the manager back to the layout instance.
 boolean loadParametersFromNamedProperties(IlvLabelLayout layout, String propertyPrefix)
          Transfers the layout parameter settings from the named properties of the manager back to the layout instance.
 IlvLabelLayout loadParametersFromNamedProperties(String propertyPrefix)
          Transfers the layout parameter settings from the named properties of the manager back to a new layout instance.
 void moveLabel(Object label, float x, float y, boolean redraw)
          Changes the position of the specified label.
 boolean removeAllLayers()
          Removes all manager layers from the list of layers to be used during the label layout.
 boolean removeLayer(IlvManagerLayer layer)
          Removes a manager layer from the list of layers to be used during the label layout.
 void removeParametersFromNamedProperties()
          Removes all named properties that were used to store the label layout parameter settings from the manager.
 void removeParametersFromNamedProperties(Class layoutClass)
          Removes the named properties that were used to store the label layout parameter settings from the manager.
 void removeParametersFromNamedProperties(String propertyPrefix)
          Removes the named properties that were used to store the label layout parameter settings from the manager.
 String saveParametersToNamedProperties(IlvLabelLayout layout, boolean withDefaults)
          Transfers the layout parameter settings to named properties of the manager.
 String saveParametersToNamedProperties(IlvLabelLayout layout, String propertyPrefix, boolean withDefaults)
          Transfers the layout parameter settings to named properties of the manager.
 void setCoordinatesMode(int mode)
          Sets the coordinates mode to be used outside the layout.
 void setFullLayerNotification(boolean flag)
          Sets whether adding or removing a layer fires just one or many labeling model events.
 void setLabel(Object obj, boolean isLabel)
          Sets whether an object is a valid label.
 void setObstacle(Object obj, boolean isObstacle)
          Sets whether an object is a valid obstacle.
 void setProperty(Object labelOrObstacle, String key, Object value)
          Sets the value of a property for a label or an obstacle.
 void setProperty(String key, Object value)
          Sets the value of a property for the labeling model.
 void setReferenceTransformer(IlvTransformer transformer)
          Allows you to specify the reference transformer.
 void setReferenceView(IlvManagerView view)
          Allows you to specify the reference manager view.
 void setRotation(Object label, double angle)
          Rotates the label around the center of its bounding box.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class ilog.views.graphlayout.labellayout.IlvLabelingModel
addLabelingModelListener, adjustmentEnd, fireLabelingModelEvent, fireLabelingModelEvent, geometryChanged, getInstanceId, getLabelsCount, getObstaclesCount, removeLabelingModelListener, structureChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvDefaultLabelingModel

public IlvDefaultLabelingModel(IlvManager manager)
Creates a new labeling model for a given IlvManager.

Parameters:
manager - The manager.
Method Detail

dispose

public void dispose()
Disposes of this IlvDefaultLabelingModel and releases any resources that it is using. An IlvDefaultLabelingModel object cannot be used after the dispose method has been called.

This method performs cleaning operations on the manager (for example, properties added to the manager are removed).

Note that the finalization process of the garbage collector also calls this method.

Overrides:
dispose in class IlvLabelingModel
See Also:
Object.finalize()

createLabelingModel

public IlvLabelingModel createLabelingModel(Object subgraph)
Creates a new IlvDefaultLabelingModel for a subgraph. The method is used when performing a layout of nested graphs that contain labels. It is called on the labeling model of a top-level graph that contains the subgraph.

Overrides:
createLabelingModel in class IlvLabelingModel
Parameters:
subgraph - The subgraph object. It must be an instance of IlvManager.
Returns:
Always null
Since:
JViews 5.5

getLabels

public Enumeration getLabels()
Returns the enumeration of all labels.

Specified by:
getLabels in class IlvLabelingModel
See Also:
IlvLabelingModel.getLabelsCount()

isDefaultLabelClass

protected boolean isDefaultLabelClass(Object obj)
Returns true if the class of the object is the default labeling class. This implementation returns true if the object is an IlvLabel, an IlvZoomableLabel or an IlvText.

You can override this method if you want to change the default behavior.

Parameters:
obj - The object to test.
Returns:
true if the class of the object is the default labeling class.
Since:
JViews 5.5

isLabel

public boolean isLabel(Object obj)
Returns true if an object is a valid label and false otherwise. It returns true if the object was specified as a label via setLabel(java.lang.Object, boolean), and false if the object was explicitly specified not to be a label. If nothing was specified via setLabel(java.lang.Object, boolean), this method also returns true if the object is an IlvLabel, an IlvZoomableLabel or an IlvText.

If layers were selected for layout (see addLayer(ilog.views.IlvManagerLayer)), then it returns false if the object is in a layer that is currently not selected for layout, independent of its type.

If you want to change the default behavior to consider different classes as labels, you should not override this method but rather override isDefaultLabelClass(java.lang.Object).

Specified by:
isLabel in class IlvLabelingModel
Parameters:
obj - The object to test.
Returns:
true if an object is a valid label.

setLabel

public void setLabel(Object obj,
                     boolean isLabel)
Sets whether an object is a valid label. By default, all objects of subclasses of IlvLabel, IlvZoomableLabel, and IlvText are considered to be labels. You can change this default behavior by specifying explicitly with this method whether the input object is a label or not.

Note that an object cannot be a label and an obstacle at the same time.

Parameters:
obj - The object.
isLabel - true if the object should be considered as label.

moveLabel

public void moveLabel(Object label,
                      float x,
                      float y,
                      boolean redraw)
Changes the position of the specified label. The x and y coordinates correspond to the top-left corner of the rectangle that defines the label (see also the method boundingBox(Object)). The coordinates are given with respect to the current coordinates mode.

Specified by:
moveLabel in class IlvLabelingModel
Parameters:
label - The label.
x - The new x-position of the label.
y - The new y-position of the label.
redraw - If true, the label is redrawn.
See Also:
setCoordinatesMode(int)

getLabelOverlap

public double getLabelOverlap(Object label1,
                              IlvRect bbox1,
                              Object label2,
                              IlvRect bbox2,
                              float minDist)
Returns the overlap between two labels, if the labels would be at the given positions specified by the passed bounding boxes.

The default implementation compares the bounding boxes of both labels.

Specified by:
getLabelOverlap in class IlvLabelingModel
Parameters:
label1 - The first label.
bbox1 - The bounding box of the first label, translated to the speculative position of the label.
label2 - The second label.
bbox2 - The bounding box of the second label, translated to the speculative position of the label.
minDist - The desired minimal distance between labels.
Returns:
A value that describes the amount of overlap.

getObstacles

public Enumeration getObstacles()
Returns the enumeration of all obstacles.

Specified by:
getObstacles in class IlvLabelingModel
See Also:
IlvLabelingModel.getObstaclesCount()

isDefaultObstacleClass

protected boolean isDefaultObstacleClass(Object obj)
Returns true if the class of the object is the default obstacle class. This implementation returns true if the object is an IlvGraphic but neither an IlvLabel nor an IlvZoomableLabel nor an IlvText.

You can override this method if you want to change the default behavior.

Parameters:
obj - The object to test.
Returns:
true if the class of the object is the default obstacle class.
Since:
JViews 5.5

isObstacle

public boolean isObstacle(Object obj)
Returns true if an object is a valid obstacle and false otherwise. It returns true if the object was specified as obstacle via setObstacle(java.lang.Object, boolean), and false if the object was explicitly specified to not be an obstacle. If nothing was specified via setObstacle(java.lang.Object, boolean), this method also returns true if the object is not an IlvLabel or an IlvZoomableLabel or an IlvText.

If layers were selected for layout (see addLayer(ilog.views.IlvManagerLayer)), then it returns false if the object is in a layer that is currently not selected for layout, independent of its type.

If you want to change the default behavior to consider different classes as obstacles, you should not override this method but rather override isDefaultObstacleClass(java.lang.Object).

Specified by:
isObstacle in class IlvLabelingModel
Parameters:
obj - The object to test.
Returns:
true if an object is a valid obstacle.
See Also:
IlvLabelingModel.isPolylineObstacle(java.lang.Object)

setObstacle

public void setObstacle(Object obj,
                        boolean isObstacle)
Sets whether an object is a valid obstacle. By default, all objects of subclasses of IlvLabel, IlvZoomableLabel, and IlvText are considered to be labels, and all other objects are considered to be obstacles. You can change this default behavior by specifying explicitly with this method whether the input object is an obstacle or not.

Note that an object cannot be a label and an obstacle at the same time.

Parameters:
obj - The object.
isObstacle - true if the object should be considered as an obstacle.

getObstacleOverlap

public double getObstacleOverlap(Object label,
                                 IlvRect labelBBox,
                                 Object obstacle,
                                 IlvRect obstacleBBox,
                                 float minDist)
Returns the overlap between the label and the obstacle, if the label would be at the given position specified by the passed bounding box.

The default implementation compares the bounding boxes of the label with the bounding box of the obstacle.

Specified by:
getObstacleOverlap in class IlvLabelingModel
Parameters:
label - The label.
labelBBox - The bounding box of the label, translated to the speculative position of the label.
obstacle - The obstacle.
obstacleBBox - The bounding box of the obstacle.
minDist - The desired minimal distance between label and obstacle.
Returns:
A value that describes the amount of overlap.

isPolylineObstacle

public boolean isPolylineObstacle(Object obj)
Returns true if an object is a valid polyline obstacle and false otherwise.

The default implementation returns true if the object is an obstacle of one of these types:

If layers were selected for layout (see addLayer(ilog.views.IlvManagerLayer)), then it returns false if the object is in a layer that is currently not selected for layout, independent of its type.

Overrides:
isPolylineObstacle in class IlvLabelingModel
Parameters:
obj - The object to test.
Returns:
true if the object is a polyline obstacle.
See Also:
isObstacle(java.lang.Object)

getPolylineWidth

public float getPolylineWidth(Object polylineObstacle)
Returns the line width of a polyline obstacle. The returned width depends on the current coordinates mode:

Overrides:
getPolylineWidth in class IlvLabelingModel
Parameters:
polylineObstacle - The polyline obstacle.
Returns:
The line width, a positive value.
See Also:
isPolylineObstacle(java.lang.Object), IlvGraphic.zoomable()

getPolylinePoints

public IlvPoint[] getPolylinePoints(Object polylineObstacle)
Returns the points that define the shape of a polyline obstacle. The returned points depends on the current coordinates mode:

Overrides:
getPolylinePoints in class IlvLabelingModel
Parameters:
polylineObstacle - The polyline obstacle.
Returns:
The points of the polyline, including the start and end points, or null if the points cannot be determined.
See Also:
isPolylineObstacle(java.lang.Object), IlvGraphic.zoomable()

getPolylineObstacleOverlap

public double getPolylineObstacleOverlap(Object label,
                                         IlvRect labelBBox,
                                         Object polylineObstacle,
                                         IlvPoint[] pts,
                                         float lineWidth,
                                         float minDist)
Returns the overlap between the label and the polyline obstacle, if the label would be at the given position specified by the passed bounding box.

The default implementation compares the bounding box of the label with the polypoint shape of the link.

Overrides:
getPolylineObstacleOverlap in class IlvLabelingModel
Parameters:
label - The label.
labelBBox - The bounding box of the label, translated to the speculative position of the label.
polylineObstacle - The polyline obstacle.
pts - The points that define the shape of the polyline obstacle.
lineWidth - The line width of the polyline obstacle.
minDist - The desired minimal distance between label and obstacle.
Returns:
A value that describes the amount of overlap.
See Also:
isPolylineObstacle(java.lang.Object)

getManager

public IlvManager getManager()
Returns the IlvManager that stores the labels and the obstacles.

Overrides:
getManager in class IlvLabelingModel

boundingBox

public IlvRect boundingBox(Object labelOrObstacle)
Returns the bounding rectangle of a label or obstacle. The returned rectangle depends on the current coordinates mode:

Specified by:
boundingBox in class IlvLabelingModel
Parameters:
labelOrObstacle - The label or obstacle.
Returns:
The bounding rectangle of the input object.

isBoundingBoxDependent

public boolean isBoundingBoxDependent()
Returns true if two objects overlap only if their bounding boxes overlap.

If you override the method getLabelOverlap or getObstacleOverlap, you may need to override this method as well.

If the method getLabelOverlap or getOsbatcleOverlap always returns 0 if the bounding boxes of the objects do not overlap, then this method may return true. If the method getLabelOverlap or getObstacleOverlap may return a nonzero value even though the bounding boxes of the objects do not overlap, then this method must return false.

Overrides:
isBoundingBoxDependent in class IlvLabelingModel
Returns:
Always true.

isLayoutNeeded

public boolean isLayoutNeeded(IlvLabelLayout layout)
Returns true if a given layout that has been already applied to this manager is still valid. The method returns true if at least one of the following holds: If none of the conditions above holds, the method returns false.

Overrides:
isLayoutNeeded in class IlvLabelingModel
Parameters:
layout - The layout.
See Also:
IlvLabelLayout.isLayoutNeeded(), IlvLabelLayout.isStructureUpToDate(), IlvLabelLayout.isGeometryUpToDate(), IlvLabelLayout.isParametersUpToDate()

beforeLayout

public void beforeLayout(IlvLabelLayout layout,
                         boolean redraw)
Notifies the labeling model that a layout session has been started. This method is always called by IlvLabelLayout.performLayout() before the call to the method IlvLabelLayout.layout(boolean).

It calls IlvManager.setContentsAdjusting to indicate the start of a sequence of label movements. If the redraw flag is true, it additionally calls IlvManager.initReDraws to indicate the start of a sequence of redraw operations.

You should not call this method directly.

Overrides:
beforeLayout in class IlvLabelingModel
Parameters:
layout - The layout instance that is the origin of the notification.
redraw - If true, the layout algorithm will ask the labeling model to redraw the objects when the method afterLayout is called (that is, it will pass true for its redraw argument).
See Also:
afterLayout(ilog.views.graphlayout.labellayout.IlvLabelLayout, ilog.views.graphlayout.labellayout.IlvLabelLayoutReport, boolean)

afterLayout

public void afterLayout(IlvLabelLayout layout,
                        IlvLabelLayoutReport layoutReport,
                        boolean redraw)
Notifies the labeling model that a layout session has finished. This method is always called by IlvLabelLayout.performLayout() after the method IlvLabelLayout.layout(boolean) has finished, even if an exception is thrown during the layout process.

Note that you can detect whether the layout was performed successfully using the test layoutReport.getCode() == IlvLabelLayoutReport.LAYOUT_DONE.

This method calls IlvManager.setContentsAdjusting to indicate the end of a sequence of label movements. If the redraw flag is true, it additionally calls IlvManager.reDrawViews to indicate the end of a sequence of redraw operations. This will redraw the views.

You should not call this method directly.

Overrides:
afterLayout in class IlvLabelingModel
Parameters:
layout - The layout instance that is the origin of the notification.
layoutReport - The layout report.
redraw - If true, the layout algorithm asks the labeling model to redraw the graph.
See Also:
beforeLayout(ilog.views.graphlayout.labellayout.IlvLabelLayout, boolean)

setProperty

public void setProperty(Object labelOrObstacle,
                        String key,
                        Object value)
Sets the value of a property for a label or an obstacle. If value is null, the property is removed. Otherwise, the property value is set to value.

Overrides:
setProperty in class IlvLabelingModel
Parameters:
labelOrObstacle - The label or obstacle for which the property is to be set.
key - The key string for the property.
value - The new value of the property.
See Also:
getProperty(java.lang.Object, java.lang.String)

getProperty

public Object getProperty(Object labelOrObstacle,
                          String key)
Returns the value of a property. The method returns null if the property does not exist.

Overrides:
getProperty in class IlvLabelingModel
Parameters:
labelOrObstacle - The label or obstacle for which the property is to be retrieved.
key - The key string for the property.
Returns:
The value of the property.
See Also:
setProperty(java.lang.Object, java.lang.String, java.lang.Object)

setProperty

public void setProperty(String key,
                        Object value)
Sets the value of a property for the labeling model. If value is null, the property is removed. Otherwise, the property value is set to value.

Overrides:
setProperty in class IlvLabelingModel
Parameters:
key - The key string for the property.
value - The new value of the property.
See Also:
getProperty(java.lang.Object, java.lang.String)

getProperty

public Object getProperty(String key)
Returns the value of a property of the labeling model. The method returns null if the property does not exist.

Overrides:
getProperty in class IlvLabelingModel
Parameters:
key - The key string for the property.
Returns:
The value of the property.
See Also:
setProperty(java.lang.Object, java.lang.String, java.lang.Object)

setCoordinatesMode

public void setCoordinatesMode(int mode)
Sets the coordinates mode to be used outside the layout. Valid values are:

The default value is IlvLabelLayout.INVERSE_VIEW_COORDINATES.

Note: This coordinates mode is used only when the layout is not running. While the layout is running, the coordinates mode of the layout instance is used (see IlvLabelLayout.setCoordinatesMode(int)).

Parameters:
mode - The mode.
See Also:
getCoordinatesMode(), IlvLabelLayout.setCoordinatesMode(int), setReferenceTransformer(ilog.views.IlvTransformer), setReferenceView(ilog.views.IlvManagerView)

getCoordinatesMode

public int getCoordinatesMode()
Returns the current coordinates mode.

See Also:
setCoordinatesMode(int), IlvLabelLayout.getCoordinatesMode()

setReferenceTransformer

public void setReferenceTransformer(IlvTransformer transformer)
Allows you to specify the reference transformer. To obtain an optimal layout, the reference transformer should be the transformer used to display the result of the layout. If the reference transformer was never specified, the transformer of the reference view is taken as reference transformer. If no reference view was specified, the transformer of the first manager view is taken as reference transformer.

The reference transformer is the transformer (see the class IlvTransformer) that is taken into account by the IlvDefaultLabelingModel when computing the geometry of the manager if the coordinates mode is either IlvLabelLayout.VIEW_COORDINATES or IlvLabelLayout.INVERSE_VIEW_COORDINATES.

If the coordinates mode is IlvLabelLayout.MANAGER_COORDINATES, the reference transformer is not taken into account. In this mode, the layout computes the geometry of the manager on the basis of the manager coordinates of objects, without any transformation. If the encapsulated manager contains only zoomable graphics (see IlvGraphic.zoomable()), the geometry will stay valid and optimal for any transformer.

If the encapsulated manager contains at least one nonzoomable object (such as IlvLabel), or objects that do not strictly obey the transformer (such as a link with maximal line width), the geometry becomes dependent on the transformer that is used to draw the manager. Changing the transformer makes the layout invalid so that a re-layout is necessary to again obtain the optimal layout with respect to the new transformer. Calculating the layout in manager coordinates may yield a nonoptimal result in a zoomed view. In this case the layout must take the reference transformer into account to obtain an optimal result.

If the coordinates mode is IlvLabelLayout.VIEW_COORDINATES, all coordinates are calculated and delivered to the layout algorithm with respect to the reference transformer. In this mode, all dimensional layout parameters must be specified in view coordinates with respect to the reference transformer.

If the coordinates mode is IlvLabelLayout.INVERSE_VIEW_COORDINATES, all coordinates are calculated with respect to the reference transformer, but they are delivered to the layout algorithm by transforming them back into manager coordinates. This has the advantage that all dimensional layout parameters can be specified in manager coordinates. If the encapsulated manager contains only zoomable graphics, the result is the same as when using manager coordinates. The layout is nearly independent of the view. In a few rare cases, a slight shifting of the coordinates may occur due to the coordinate optimization. If the encapsulated manager contains nonzoomable objects, the calculation with inverse view coordinates still produces an optimal result with respect to the reference transformer. However, the layout is no longer independent of the view, that is, it becomes nonoptimal when the view transformer is changed.

In most cases it is not necessary to call this method because the transformer to be taken into account is chosen using a set of default rules (see getReferenceTransformer()). If it is called, the transformer specified using this method is returned by the method getReferenceTransformer(), overriding the default rules for choosing the transformer.

If the IlvManager contains nonzoomable objects, you may need to call this method in the following cases:

In both cases, because of the nonzoomable objects, the layout cannot be correctly computed independently of the transformer used for drawing the manager. Also, the default rule for choosing the current transformer of the first manager view as the reference transformer cannot be applied.

If a manager containing nonzoomable objects is displayed simultaneously in several views, you can use the method setReferenceView(ilog.views.IlvManagerView) to indicate the view for which you want the layout to correspond exactly to the geometry of the manager.

If you specified a transformer but want to reset this setting and go back to the default behavior, call the method with a null argument.

Note that if this method is overridden, you must call super.setReferenceTransformer(transformer) to notify the manager adapter that the reference transformer has changed.

Note also that a call to the method setReferenceView(ilog.views.IlvManagerView) overrides the effect of a call to the method setReferenceTransformer(ilog.views.IlvTransformer). Similarly, a call to the method setReferenceTransformer(ilog.views.IlvTransformer) overrides the effect of a call to the method setReferenceView(ilog.views.IlvManagerView).

Parameters:
transformer - The reference transformer.
See Also:
getReferenceTransformer(), setReferenceView(ilog.views.IlvManagerView), setCoordinatesMode(int)

getReferenceTransformer

public IlvTransformer getReferenceTransformer()
Returns the transformer to be taken into account.

This method returns the transformer specified using setReferenceTransformer(ilog.views.IlvTransformer) if this transformer is not null. If no reference transformer is set, it returns the current transformer of the manager view specified using setReferenceView(ilog.views.IlvManagerView) (if any). If no reference view is set, it returns the current transformer of the first manager view attached to the manager (as returned by the method IlvManager.getViews()). If the manager is a subgrapher, that is, if it is used as a graphic object contained in another IlvGrapher, and the subgrapher has no view directly attached, the first view of the closest parent graph is used.

Otherwise, this method returns an identity transformer.

Note that you should not modify the transformer returned by this method.

See Also:
setReferenceTransformer(ilog.views.IlvTransformer), getReferenceView(), setCoordinatesMode(int)

setReferenceView

public void setReferenceView(IlvManagerView view)
Allows you to specify the reference manager view.

The reference view is the manager view (see the class IlvManagerView) whose current transformer (see the method IlvManagerView.getTransformer()) is used as a reference transformer (see method getReferenceTransformer().

Usually, the view argument is the manager view that is used for displaying the manager, but this is not mandatory.

Call this method with a null argument to reset the setting.

Note that a call to the method setReferenceTransformer(ilog.views.IlvTransformer) overrides the effect of a call to the method setReferenceView(ilog.views.IlvManagerView). Similarly, a call to the method setReferenceView(ilog.views.IlvManagerView) overrides the effect of a call to the method setReferenceTransformer(ilog.views.IlvTransformer).

See Also:
getReferenceView(), setReferenceTransformer(ilog.views.IlvTransformer)

getReferenceView

public IlvManagerView getReferenceView()
Returns the specified reference view (if any) and null otherwise.

See Also:
setReferenceView(ilog.views.IlvManagerView), setReferenceTransformer(ilog.views.IlvTransformer)

addLayer

public final void addLayer(IlvManagerLayer layer)
Adds a manager layer to the list of layers to be used during the label layout. If you do not call this method, all the layers of the manager are taken into account. Note that, in this case, getLayers() returns null.

An IllegalArgumentException is thrown if the layer does not belong to the encapsulated manager.

See Also:
removeLayer(ilog.views.IlvManagerLayer), removeAllLayers(), getLayers(), isLayerAdded(ilog.views.IlvManagerLayer)

removeLayer

public final boolean removeLayer(IlvManagerLayer layer)
Removes a manager layer from the list of layers to be used during the label layout. If this was the last layer, then the model switches back to the default mode, that is, to take all layers into account during label layout.

An IllegalArgumentException is thrown if the layer does not belong to the encapsulated manager.

Returns:
true if the layer is in the list of layers to be used; false if the layer is not in the list of layers or if the list of layers is void.
See Also:
addLayer(ilog.views.IlvManagerLayer), removeAllLayers(), getLayers()

removeAllLayers

public final boolean removeAllLayers()
Removes all manager layers from the list of layers to be used during the label layout. This switches back to the default mode, that is, to take all layers into account during label layout.

Returns:
false if there are no layers to be removed and true otherwise.
See Also:
addLayer(ilog.views.IlvManagerLayer), removeLayer(ilog.views.IlvManagerLayer), getLayers()

getLayers

public final Enumeration getLayers()
Returns an enumeration of the manager layers to be taken into account during the label layout. If you do not specify any layers using the method addLayer(IlvManagerLayer), all layers in the encapsulated IlvManager are used. In this case, this method returns null.

Returns:
An enumeration of the manager layers (IlvManagerLayer instances) to be taken into account during the layout. Returns null if the list of layers to be used is empty.
See Also:
getLayersCount(), addLayer(ilog.views.IlvManagerLayer), removeLayer(ilog.views.IlvManagerLayer), removeAllLayers(), isLayerAdded(ilog.views.IlvManagerLayer)

getLayersCount

public final int getLayersCount()
Returns the number of manager layers to be taken into account during the label layout. If you do not specify any layers using the method addLayer(IlvManagerLayer), all layers in the encapsulated IlvManager are used. In this case, this method returns 0.

Returns:
The number of manager layers (IlvManagerLayer instances) to be taken into account during the layout. Returns 0 if the list of layers to be used is empty.
Since:
JViews 5.5
See Also:
addLayer(ilog.views.IlvManagerLayer), getLayers(), isLayerAdded(ilog.views.IlvManagerLayer)

isLayerAdded

public final boolean isLayerAdded(IlvManagerLayer layer)
Returns true if the manager layer is one of the layers to be taken into account during the layout. Otherwise, the method returns false. If you do not specify any layers using the method addLayer(IlvManagerLayer), the method returns false for any argument.

Parameters:
layer - The layer to test.
Returns:
true if the layer must be taken into account during the layout.
Since:
JViews 5.5
See Also:
addLayer(ilog.views.IlvManagerLayer), getLayers()

setFullLayerNotification

public void setFullLayerNotification(boolean flag)
Sets whether adding or removing a layer fires just one or many labeling model events. If true is passed, adding or removing a layer posts a separate event for each object contained in the layer. If false is passed, adding or removing a layer posts only one event. This is more efficient. However some layout classes listen to the events to cleanup memory, so if you disable full layer notification, you are responsible to call IlvLabelLayout.cleanLabel(ilog.views.graphlayout.labellayout.IlvLabelingModel, java.lang.Object) and IlvLabelLayout.cleanObstacle(ilog.views.graphlayout.labellayout.IlvLabelingModel, java.lang.Object) yourself to cleanup the memory.

Full layer notification is enabled by default.

Parameters:
flag - Set to true for full layer notification