Overview of renderers

A renderer is an object that is used to transform a map feature into a graphic object of the class IlvGraphic or one of its subclasses.
A renderer must implement the IlvFeatureRenderer interface, which is supplied in the ilog.views.maps package. To transform a given map feature into a graphic object, you use its makeGraphic method:
IlvGraphic makeGraphic(IlvMapFeature feature,
                       IlvCoordinateTransformation tr);
The second argument, tr , allows you to specify a coordinate transformation. A typical way of constructing such a transformation is to call IlvCoordinateTransformation.CreateTransformation with feature.getCoordinateSystem as its first parameter (the Source coordinate system) and the coordinate system set on the Manager (through IlvCoordinateSystemProperty) as second parameter (the Target coordinate system). For information about coordinate systems and coordinate transformations, see Converting coordinates between coordinate systems.
JViews Maps includes a set of default renderers for each one of the geometry types available in the library. These renderers can be found in the package ilog.views.maps.rendering. The IlvMapPointRenderer, for example, transforms a map feature whose geometry is a point into an object of the type IlvMapMarker. The library also provides a global default renderer of the type IlvDefaultFeatureRenderer, which you can use to translate any map feature whose geometry is one of the predefined geometries. This renderer is in the ilog.views.maps package.
The following code example shows how to transform a map feature whose geometry is of the type IlvMapLineString into green polylines with a thickness of four pixels if the scale is greater than 1/1,000,000. These polylines could be, for example, the segments of a country’s border.
IlvMapLineRenderingStyle style = new IlvMapLineRenderingStyle(); style.setForeground(Color.green); 
style.setLineWidth(4); 
style.setScale(1f/1000000f); 

IlvDefaultCurveRenderer renderer = new IlvDefaultCurveRenderer(); renderer.setLineRenderingStyle(style); 

try {
  // Identity transformation.
  IlvCoordinateTransformation identity = IlvCoordinateTransformation.CreateTransformation(null, null);
  IlvGraphic graphic = renderer.makeGraphic(feature, identity);

  // Adding the graphic object into a manager.
  manager.addObject(graphic, layerIndex, true);
} catch (IlvMapRenderException e) {
  // Might occur if the geometry is not a curve.
  System.out.println("This renderer can’t translate the map feature");
  System.out.println(e.getMessage());
} catch (IlvCoordinateTransformationException te) { 
  // Might occur if the coordinate transformation could not be
  // performed.
  System.out.println("This renderer could not transform the geometry");
  System.out.println(te.getMessage()); 
}
The complete source code of this example can be found in the following file: