The following code creates an
IlvShapeDataSource and sets an
IlvMapAreaRenderer
to
render the feature read by the data source. The fill color is set
to red. A button is created whose action sets the color of the map
to blue simply by changing the
Paint
attribute
of the layer.
IlvShapeDataSource ds = new IlvShapeDataSource(shapeFile);
ds.setManager(view.getManager());
IlvMapAreaRenderer renderer = new IlvMapAreaRenderer(false, false);
IlvGraphicPathStyle style = new IlvGraphicPathStyle();
ds.getInsertionLayer().setStyle(style);
style.setFilling(true);
style.setPaint(Color.red);
ds.setFeatureRenderer(renderer);
JButton b = new JButton();
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
IlvGraphicPathStyle style = ( (IlvGraphicPathStyle)ds.getInsertionLayer().getStyle();
style.setPaint(Color.blue);
view.repaint();
}
});