| Programming with JViews Maps > Creating a Map Application Using the API > Using the GUI Beans > Annotations |
Annotations |
INDEX
PREVIOUS
NEXT
|
The Annotations Toolbar Bean is represented by the IlvMapAnnotationToolBar class. You can annotate maps using predefined annotations created by the Annotations Toolbar. The toolbar can be used interactively to add a point, polyline, or polygon annotation. An example of the Annotations Toolbar is shown in Figure 3.23.
An annotation is a drawing made on the top of a map to describe or provide additional information about a specific zone of a map. Annotations are labeled and are projected with respect to the coordinate system of the map, which is stored in the manager as an IlvCoordinateSystemProperty. In JViews Maps, annotations are dedicated IlvGraphic objects. Labels can be displayed to provide text information and are labeled using the JViews Maps labeling mechanism.
The Annotations Toolbar Bean is an extension of JToolBar.
IlvGraphics.
IlvMapAnnotationToolBar.MapMarker:
IlvPoint p = new IlvPoint(10, 50);
IlvMapAnnotationToolBar.MapMarker m = new
IlvMapAnnotationToolBar.MapMarker(p);
These graphic objects are stored in an IlvGraphicLayerDataSource. The IlvMapAnnotationModel class can provide such a data source.
IlvGraphicLayerDataSource data source:
IlvMapAnnotationModel model =
IlvMapAnnotationProperty.GetMapAnnotationModel(manager);
IlvGraphicLayerDataSource dataSource = model.getDataSource(manager,
"TEST");
String name = "TEST" + " Annotation";
dataSource.getInsertionLayer().setName(name);
dataSource.add(m,
IlvCoordinateSystemProperty.GetCoordinateSystem(manager));
label attribute so that the annotation is labeled accordingly:
if (dataSource.getInsertionLayer().getStyle() == null) {
IlvMapStyle style = new IlvPointStyle();
style.setAttributeInfo(IlvMapAnnotationModel.info);
style.setLabelAttribute(IlvMapAnnotationModel.info.getAttributeName(0));
dataSource.getInsertionLayer().setStyle(style);
}
IlvPointStyle ps =
(IlvPointStyle)dataSource.getInsertionLayer().getStyle();
m.setStyle(ps);
ps.setSize(5);
ps.setType(IlvMarker.IlvMarkerFilledDiamond);
ps.setForeground(Color.pink);
feature attribute property; the string A Label will be displayed as the annotation label:
String s = "A Label";
IlvFeatureAttributeProperty properties = new
IlvFeatureAttributeProperty(IlvMapAnnotationModel.info,
new IlvFeatureAttribute[] { new IlvStringAttribute(s)});
m.setNamedProperty(properties);
try {
manager.setInsertionLayer(dataSource.getInsertionLayer().getManagerLayer().
getIndex());
dataSource.start();
} catch (Exception e) {
e.printStackTrace();
}
IlvMapLabeler labeler = IlvMapLabelerProperty.GetMapLabeler(manager);
labeler.setView(view);
labeler.addLayer(dataSource.getInsertionLayer());
labeler.performLabeling();
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |