Maps > Rogue Wave Views リーダー・フレームワーク > レンダラー > 既存レンダラーの拡張
 
既存レンダラーの拡張
ほとんどの場合、レンダラーを最初から書く必要はありません。パッケージで提供されているいずれかのデフォルトのレンダラーを使って、必要に応じて変更できます。
このセクションでは、IlvDefaultPointRenderer を拡張して、レンダリングする機能ポイントの横に、タイプ IlvLabel のテキストを追加する方法について説明します。
このセクションに示す例のソース・コード一式は、以下のファイルにあります。
<installdir>/samples/maps/userman/src/markerTextRenderer.cpp
テキストは、クラス MarkerTextRenderer に提供された名前のあるアトリビュートに格納されます。このテキストがある場合、テキストはレンダラーのスーパークラスで作成するマーカーと一緒に返されるか、またはマーカーのみが返されます。
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 6.0
Copyright © 2015, Rogue Wave Software, Inc. All Rights Reserved.