Maps > Rogue Wave Views Maps Reader Framework > Renderers > Extending an Existing Renderer
 
Extending an Existing Renderer
Most of the time, you do not have to write a renderer from scratch. You can use one of the default renderers that are supplied in the package and tailor it to your needs.
This section shows how to extend an IlvDefaultPointRenderer to add text of the type IlvLabel next to the point of the feature being rendered.
The complete source code for the example in this section can be found in the following file:
<installdir>/samples/maps/userman/src/markerTextRenderer.cpp
The text is stored in an attribute whose name is provided for the class MarkerTextRenderer. When this text exists, it is returned with the marker generated by the superclass of the renderer; otherwise only the marker is returned.
IlvGraphic*
MarkerTextRenderer::makeGraphic( const IlvMapFeature& feature,
const IlvMapInfo& targetMapInfo,
IlvMapsError& status) const
{
IlvMarker *marker =
(IlvMarker *)IlvDefaultPointRenderer::makeGraphic(feature,
targetMapInfo,
status);
if(!marker)
return 0;
IlvLabel* label = 0;
 
const IlvFeatureAttributeProperty* attributeList =
feature.getAttributes();
 
const IlvFeatureAttribute* attribute =
attributeList->getAttribute(_attributeName);
if(attribute)
label = new IlvLabel (getDisplay(),
marker->getPoint(),
ToString(attribute));
if (!label)
return marker;
 
label->setForeground(marker->getForeground());
IlvGraphicSet* set = new IlvGraphicSet();
set->addObject(marker);
set->addObject(label);
return set;
}
 

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.