JToolBar
.IlvMapAnnotationToolBar annotations =new IlvMapAnnotationToolBar(); annotations.setView(view);
// Set the size of the buttons. annotations.setButtonSize(new Dimension(25, 25)); // Prevent the toolbar being dragged elsewhere. annotations.setFloatable(false);
annotations.setGrapherMode(true);
IlvPoint p = new IlvPoint(10, 50); IlvMapAnnotationToolBar.MapMarker m = new IlvMapAnnotationToolBar.MapMarker(p);
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();