ilog.views.maps.graphic.style
Interface IlvMapAttributeFilter

All Superinterfaces:
IlvPersistentObject
All Known Implementing Classes:
IlvColorAttributeFilter

public interface IlvMapAttributeFilter
extends IlvPersistentObject

The IlvMapAttributeFilter interface represents a filter used to dynamically change attribute values.

The following code example shows how to implement this interface:

  class ColorAttributeFilter implements IlvMapAttributeFilter {
 
    public ColorAttributeFilter() {
      // need a public constructor .
    }
 
    public ColorAttributeFilter(IlvInputStream stream) {
      // need a public constructor with IlvInputStream.
    }
 
    Color convertObjectToColor(Object o) {
      if(o == null)
        return Color.white;
      return new Color(o.hashCode());
    }
 
    Color computeColorFrom(IlvGraphic g) {
      IlvAttributeProperty p = (IlvAttributeProperty) g.getNamedProperty(IlvAttributeProperty.NAME);
      if(p == null)
        return null;
      Object o = p.getValue("VALUE");
      return convertObjectToColor(o);
    }
 
    public Object get(IlvGraphic g, String attributeName) {
      if(IlvPolylineStyle.FOREGROUND.equals(attributeName)) {
        Color ret = computeColorFrom(g);
        if(ret == null)
          return DEFAULT_VALUE;
        return ret;
      }
      return DEFAULT_VALUE;
    }
 
    public void write(IlvOutputStream stream) throws IOException {
      // implements IlvPersistentObject
    }
  }
  

The following code example shows how use your implementation to filter the color attributes in the IlvMapStyle for an IlvMapLayer.

  IlvMapLayer layer = getLayer();
  lvMapStyle style = layer.getStyle();
  style.setAttributeFilter(new ColorAttributeFilter());
 

Since:
JViews 8.1

Field Summary
static Object DEFAULT_VALUE
          The value returned by the get method if a different value has not been calculated.
 
Method Summary
 Object get(IlvGraphic g, String attributeName)
          This method is is invoked when the IlvMapStyle instance this object is attached to attempts to retrieve an attribute value.
 
Methods inherited from interface ilog.views.io.IlvPersistentObject
write
 

Field Detail

DEFAULT_VALUE

static final Object DEFAULT_VALUE
The value returned by the get method if a different value has not been calculated.

See Also:
A code example.
Method Detail

get

Object get(IlvGraphic g,
           String attributeName)
This method is is invoked when the IlvMapStyle instance this object is attached to attempts to retrieve an attribute value.

This method can return a value different from the one that is stored in the style. The value returned depends on the metadata found in the IlvAttributeProperty instance stored in g.

Parameters:
g - The current IlvGraphic.
attributeName - The name of the attribute to be retrieved.
Returns:
The computed value or this.DEFAULT_VALUE if no change is calculated.
See Also:
A code example.


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