ilog.views
Class IlvLayerVisibilityFilter

java.lang.Object
  extended by ilog.views.IlvLayerVisibilityFilter
All Implemented Interfaces:
IlvPersistentObject, Serializable
Direct Known Subclasses:
IlvZoomFactorVisibilityFilter

public abstract class IlvLayerVisibilityFilter
extends Object
implements IlvPersistentObject, Serializable

This class is used to control dynamically the visibility of a layer. You can add such a filter on a layer using the IlvManagerLayer.addVisibilityFilter(ilog.views.IlvLayerVisibilityFilter) method. Once the filter is installed, the method isVisible of the filter is called each time the layer of the manager needs to be redrawn. If this method returns true then the contents of the layer will be drawn. If the method returns false then nothing will be drawn. Note that the method will not be called when the layer has been set as invisible for all or for one view.
A visibility filter can be stored in the IVL file. To implement the persistence, the method isPersistent in the subclass must return true. In this case, the subclass must be public, because classes from the ilog.views package must be able to write and read the filter.

The subclass must provide a constructor with an IlvInputStream argument and must override the write method if some specific data is to be stored.

Here is a small example that shows how to control that a layer will be visible only when the zoom level is less than 400%:

 layer.addVisibilityFilter(
    new IlvLayerVisibilityFilter() {
     public boolean isVisible(IlvManagerLayer l, IlvManagerView v) {    
       return v.getTransformer().getx11() < 4;
     }
     public boolean isPersistent() { return false; }
 });

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

Constructor Summary
IlvLayerVisibilityFilter()
          Creates a new IlvLayerVisibilityFilter.
IlvLayerVisibilityFilter(IlvInputStream stream)
          Creates a new IlvLayerVisibilityFilter from an IlvInputStream.
 
Method Summary
abstract  boolean isPersistent()
          Tells if the filter must be saved to an IVL file.
abstract  boolean isVisible(IlvManagerLayer layer, IlvManagerView view)
          Checks the visibility of a layer.
 void write(IlvOutputStream stream)
          Writes the filter to an IlvOutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvLayerVisibilityFilter

public IlvLayerVisibilityFilter()
Creates a new IlvLayerVisibilityFilter.


IlvLayerVisibilityFilter

public IlvLayerVisibilityFilter(IlvInputStream stream)
                         throws IlvReadFileException
Creates a new IlvLayerVisibilityFilter from an IlvInputStream. Note that you must provide an overridden version of this method in your subclass if some specific data is to be read from the input stream.

Parameters:
stream - the input stream from which the filter must be read.
Throws:
IlvReadFileException - if an error occurs while reading.
Method Detail

isVisible

public abstract boolean isVisible(IlvManagerLayer layer,
                                  IlvManagerView view)
Checks the visibility of a layer. Once the filter is installed on a layer, this method will be called each time the layer or part of the layer is redrawn. If the method returns true then the contents of the layer will be drawn. If the method returns false then nothing will be drawn. Note that the method will not be called when the layer has been set as invisible for all or for one view.


isPersistent

public abstract boolean isPersistent()
Tells if the filter must be saved to an IVL file. If this method returns true, the filter is saved; otherwise it is not saved.


write

public void write(IlvOutputStream stream)
           throws IOException
Writes the filter to an IlvOutputStream.

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - the output stream. You must override this method if specific data is to be stored. Note that the first instruction in your implementation of the method must be super.write(stream).
Throws:
IOException - standard IO error.


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