ilog.views
Class IlvManagerLayer

java.lang.Object
  extended by ilog.views.IlvIndexedSet
      extended by ilog.views.IlvManagerLayer
All Implemented Interfaces:
IlvPersistentObject, Serializable
Direct Known Subclasses:
IlvAbstractBaseGrid, IlvDelayedDecoration, IlvLegendRenderer.LegendLayer, IlvMapDefaultLabeler.LabelLayer, IlvMapLabelManager, IlvTiledLayer

public class IlvManagerLayer
extends IlvIndexedSet
implements IlvPersistentObject

IlvManagerLayer is a storage class for graphic objects; an IlvManager instance is composed of several layers.

Overview

Graphic objects contained in a manager are placed in multiple storage areas called layers. All graphic objects and all layers within a manager share the same coordinate system. The smallest rectangle encompassing all graphic objects in a layer is called the bounding box.

Objects stored in a higher screen layer are displayed in front of objects in lower layers, that is, a layer with the number N is placed in front of layers with numbers from N-1 to zero.

Each graphic object stored in a layer is unique to that layer and can be stored only in that layer. Each layer, as well as its graphic objects, is unique to a single manager and can only be controlled by this manager.

Note: manipulation of layers and the graphic objects they contain is normally done through IlvManager and IlvManagerView instances.

Layer Visibility and Selection

You control the visibility and selection for all objects contained in a layer by calling setVisible and setSelectable. Objects that cannot be selected cannot be modified.

A visible layer can be temporarily hidden depending on specific conditions such as the zoom factor. This is done using an IlvLayerVisibilityFilter instance that is called when the IlvManager containing this layer needs to redraw a layer. To be active, this filter must be registered by calling addVisibilityFilter.

Example

Layers are controlled by the manager or manager view that contains them. To add new layers to a manager, call addObject and specify the layer in which you want to place the graphic object. By default, a manager has one layer only, using addObject new layers are added automatically when a new graphic object is added to a layer that does not currently exist.

  IlvGraphic obj;
  IlvManager manager = new IlvManager();
  ...
  obj = new IlvRectangle(new IlvRect(70,40,50,50), false, true);
  // Add obj to layer six and redraw the manager.
  // New layers are added automatically.
  manager.addObject(obj, 6, true);
  IlvManagerView view = new IlvManagerView(manager);
  view.setBackground(Color.RED);
  JFrame frame = new JFrame("IlvManagerExample");
  frame.getContentPane().add(view);
  ...
 
The visibility of all objects in a manager layer for a specific view is controlled by calling IlvManager.setVisible.
 
   manager.setVisible(view,2,false,true);
 

Triple Buffering Layers

One use of layers is to display a static background on top of which "live" graphic objects are drawn and manipulated by the user. Using triple buffering, background layers are drawn in an additional off-screen image, this image is used instead of redrawing the background graphic objects to speed up your application. Triple buffering is activated by calling setTripleBufferedLayerCount(int).

See Also:
IlvManager, IlvManagerView, IlvLayerVisibilityFilter, IlvGraphic, Moving and Transforming Graphic Objects., Serialized Form

Constructor Summary
IlvManagerLayer()
          Creates a new layer.
IlvManagerLayer(IlvInputStream stream)
          Reads the layer from an IlvInputStream.
IlvManagerLayer(int maxInNode, int maxInList)
          Creates a new layer.
 
Method Summary
 void addVisibilityFilter(IlvLayerVisibilityFilter filter)
          Adds a visibility filter.
 IlvRect computeBBox(IlvTransformer t)
          Returns the bounding rectangle of the layer when it is drawn with the specified transformer.
protected  void draw(Graphics dst, IlvManagerView view)
          Draws the layer in a view of a manager.
protected  void drawImpl(Graphics dst, IlvManagerView view)
          Draws the layer in a view of a manager.
 float getAlpha()
          Returns the alpha value of this layer.
 int getIndex()
          Returns the index of the layer in the manager.
 IlvManager getManager()
          Returns the manager to which this layer belongs.
 String getName()
          Returns the name of the layer.
 IlvNamedProperty getNamedProperty(String name)
          Returns the named property associated with this layer having the specified name.
 Object getProperty(String key)
          Returns the value of a property.
 Enumeration getVisibilityFilters()
          Returns an enumeration of all installed visibility filters.
 boolean isSelectable()
          Returns true if the layer is selectable.
protected  boolean isTemporarilyHidden(IlvManagerView view)
           
 boolean isVisible()
          Returns true if the layer is visible in the manager.
 boolean isVisible(IlvManagerView view)
          Returns true if the layer is visible in the specified view.
 void print(Graphics dst, IlvRect area, IlvTransformer t)
          Prints the layer with a specified transformer.
 void removeNamedProperty(String name)
          Removes the named property associated with this layer having the specified name.
 void removeVisibilityFilter(IlvLayerVisibilityFilter filter)
          Removes an installed visibility filter.
 void setAlpha(float alpha)
          Changes the alpha value of this layer.
protected  void setManager(IlvManager manager)
          Sets the manager to which this layer will belong.
 void setName(String name)
          Sets the name of the layer.
 IlvNamedProperty setNamedProperty(IlvNamedProperty property)
          Associates a named property with the layer.
 void setProperty(String key, Object value)
          Sets the value of a property.
 void write(IlvOutputStream stream)
          Writes the layer to an output stream.
 void writeIt(IlvOutputStream stream)
          Stores the content of the manager layer to an IlvOutputStream.
 
Methods inherited from class ilog.views.IlvIndexedSet
addObject, afterUpdate, beforeUpdate, collectObjects, deleteAll, getCardinal, getElements, getIndex, getManagers, getManagersCount, getObject, getObject, getSubsequentRemoveThreshold, isQuadtreeEnabled, map, mapInside, mapInside, mapIntersects, mapIntersects, removeObject, setIndex, setQuadtreeEnabled, setSubsequentRemoveThreshold
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvManagerLayer

public IlvManagerLayer()
Creates a new layer. Once a layer is created, you can use the IlvManager.addLayer method to add it in the manager.

See Also:
IlvManager.addLayer(ilog.views.IlvManagerLayer, int)

IlvManagerLayer

public IlvManagerLayer(int maxInNode,
                       int maxInList)
Creates a new layer. Once a layer is created, you can use the IlvManager.addLayer method to add it in the manager.

Parameters:
maxInNode - The maximum number of objects in a quadtree node before the quadtree node divides itself into 4 quadrants.
maxInList - The maximum number of objects in the layer before the layer starts using a quadtree for the storage of objects.
See Also:
IlvManager.addLayer(ilog.views.IlvManagerLayer, int)

IlvManagerLayer

public IlvManagerLayer(IlvInputStream stream)
                throws IlvReadFileException
Reads the layer from an IlvInputStream. You should use this constructor only when defining a new class of layer. The default implementation does nothing.

Parameters:
stream - The input stream.
Throws:
IlvReadFileException - if the format is not correct.
Method Detail

getManager

public final IlvManager getManager()
Returns the manager to which this layer belongs.

Returns:
The manager to which this layer belongs, or null if this layer has not been added to a manager.

setManager

protected void setManager(IlvManager manager)
Sets the manager to which this layer will belong. This method is called when the layer is inserted into a manager.

Parameters:
manager - The manager to which this layer will belong.
Since:
JViews 3.0

getIndex

public final int getIndex()
Returns the index of the layer in the manager.


isSelectable

public final boolean isSelectable()
Returns true if the layer is selectable. The graphic objects contained in a non-selectable layer:

See Also:
IlvManager.isSelectable(IlvGraphic), IlvManager.isSelectable(int)

setAlpha

public void setAlpha(float alpha)
Changes the alpha value of this layer. The alpha composition value is used to render the layer in a transparent way. The value must be in the range of [0.0, 1.0], the value of 1 meaning that the layer is not transparent.

Parameters:
alpha - The new transparency level in the range [0.0, 1.0].
See Also:
getAlpha()

getAlpha

public float getAlpha()
Returns the alpha value of this layer. The alpha composition value is used to render the layer in a transparent way. The value is in the range of [0.0, 1.0], the value of 1 meaning that the layer is not transparent.

See Also:
setAlpha(float)

addVisibilityFilter

public final void addVisibilityFilter(IlvLayerVisibilityFilter filter)
Adds a visibility filter. When such a filter is installed, the visibility of the layer is controlled by the filter.

See Also:
removeVisibilityFilter(ilog.views.IlvLayerVisibilityFilter), getVisibilityFilters()

removeVisibilityFilter

public final void removeVisibilityFilter(IlvLayerVisibilityFilter filter)
Removes an installed visibility filter.

See Also:
addVisibilityFilter(ilog.views.IlvLayerVisibilityFilter), getVisibilityFilters()

getVisibilityFilters

public final Enumeration getVisibilityFilters()
Returns an enumeration of all installed visibility filters.

See Also:
addVisibilityFilter(ilog.views.IlvLayerVisibilityFilter), removeVisibilityFilter(ilog.views.IlvLayerVisibilityFilter)

isVisible

public final boolean isVisible()
Returns true if the layer is visible in the manager. Note that even if this method returns true, the layer may not appear in a view. The layer can be set invisible for a particular view.

See Also:
isVisible(ilog.views.IlvManagerView)

isVisible

public boolean isVisible(IlvManagerView view)
Returns true if the layer is visible in the specified view. This method checks the visibility of the layer itself, the visibility of the layer for the specified view, and then calls the visibility filters.

Parameters:
view - The view of the manager.
Since:
JViews 2.1

setProperty

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

Parameters:
key - The key string for this property.
value - The new value of this property.

getProperty

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


print

public void print(Graphics dst,
                  IlvRect area,
                  IlvTransformer t)
Prints the layer with a specified transformer.

Parameters:
dst - The graphics.
area - The rectangle of the layer to print in the manager coordinate system.
t - The transformer used to print the content.

isTemporarilyHidden

protected final boolean isTemporarilyHidden(IlvManagerView view)
Internal method or field: do not use!

draw

protected void draw(Graphics dst,
                    IlvManagerView view)
Draws the layer in a view of a manager. If the layer is cached and the cache is valid, the cache will be used to refresh the view. If the layer is cached and the cache is invalid, the cache will be updated before being used for drawing.

The actual method that draws the layer content is drawImpl(Graphics, IlvManagerView). Subclasses can override this method to implement a specialized drawing for the layer.

Parameters:
dst - The Graphics to draw.
view - The view of the manager.
See Also:
IlvManagerView.setLayerCached(int, boolean)

drawImpl

protected void drawImpl(Graphics dst,
                        IlvManagerView view)
Draws the layer in a view of a manager. This method is called by draw(Graphics, IlvManagerView). Subclasses can override this method to implement a specialized drawing for the layer.

Parameters:
dst - The destination with or without the clip being set.
view - The manager view.
Since:
JViews 8.1
See Also:
draw(Graphics, IlvManagerView)

computeBBox

public IlvRect computeBBox(IlvTransformer t)
Returns the bounding rectangle of the layer when it is drawn with the specified transformer. If the layer is not visible (see isVisible()), the method returns an empty rectangle (x, y, width, and height equal to 0).

Overrides:
computeBBox in class IlvIndexedSet
Parameters:
t - The transformer.

setName

public void setName(String name)
Sets the name of the layer. The layer name is not set if there is already a layer with the same name in the manager.

Parameters:
name - The name of the layer.
See Also:
getName()

getName

public String getName()
Returns the name of the layer.

See Also:
setName(java.lang.String)

setNamedProperty

public final IlvNamedProperty setNamedProperty(IlvNamedProperty property)
Associates a named property with the layer.

Parameters:
property - The named property to associate.
Returns:
The named property with the same name that was previously associated with the object, if any; null otherwise.

getNamedProperty

public final IlvNamedProperty getNamedProperty(String name)
Returns the named property associated with this layer having the specified name. Returns null if no such property exists.

Parameters:
name - The name of property.

removeNamedProperty

public final void removeNamedProperty(String name)
Removes the named property associated with this layer having the specified name.

Parameters:
name - The name of the property.

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the layer to an output stream. You should not call this method directly, but you may need to override it in a subclass of IlvManagerLayer to store your own information. If you override the method, you may call super.write(stream) after your own saving instructions. Calling the superclass method will dump the graphic objects stored in the layer.

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - the output stream
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

writeIt

public final void writeIt(IlvOutputStream stream)
                   throws IOException
Stores the content of the manager layer to an IlvOutputStream. You should not call this method directly. This method is public for implementation purposes.

Throws:
IOException


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