|
MapContent#addLayers seems to be an optimization (rather than calling MapContent#addLayer multiple times) so that only one MapLayerListListener event is fired instead of multiple (e.g. reduce paint events?). However the implementation has an issue because listeners like the MapLayerTable expect the MapLayerListEvent to include the layer which reference, but rather a null value is passed (presumably because the event is for 1 or more layers). See MapContent#addAllAbsent (line 1041): fireLayerAdded(null, start, size() - 1);
Steps to reproduce: 1. Use the following sample code
JMapFrame mapFrame = new JMapFrame(map); mapFrame.enableLayerTable(true); ArrayList<Layer> layers = new ArrayList(); // TODO Add your layers // Layer l = ... // layers.add(l); mapFrame.getMapContent.addLayers(layers);
Actual results:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.geotools.swing.MapLayerTableCellRenderer.getListCellRendererComponent(MapLayerTableCellRenderer.java:257) at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1361) at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1311) at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:264) at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:240)
|