Hello,I am developing an application which should allow users to edit the form and position of features as well as their attribute values. One of these operations for itself works fine and without any trouble. But when I try to use both operations at the same time an exception is thrown and the application doesn't work anymore. I noticed this in one case: The 'Edit Vertices' tool in the JEditToolsPicker toolbar must be activated, next I choose a feature in the map which should be edited (the features are contained by editable feature layer). I use a HitTestOverlay to edit attribute values of features (adopted from Esri sample code). When a feature in the map is clicked, a dialog to modify the attribute values opens. After a value is edited and confirmed (so the dialog closes), the mentioned exception is thrown:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.esri.client.toolkit.overlays.FeatureEditOverlay.handleFakeVertex(FeatureEditOverlay.java:844)
at com.esri.client.toolkit.overlays.FeatureEditOverlay.onMouseMoved(FeatureEditOverlay.java:539)
at com.esri.map.MapOverlay$b.mouseMoved(Unknown Source)
at java.awt.Component.processMouseMotionEvent(Unknown Source)
at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at com.esri.map.MapOverlay.a(Unknown Source)
at com.esri.map.MapOverlay.onMouseMoved(Unknown Source)
at com.esri.map.MapOverlay$b.mouseMoved(Unknown Source)
at java.awt.Component.processMouseMotionEvent(Unknown Source)
at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
This is the code which provides the HitTestOverlay:
private void addHitTestOverlay(JMap jMap, final ArcGISFeatureLayer featureLayer)
{
final HitTestOverlay hitTestOverlay = new HitTestOverlay(featureLayer);
hitTestOverlay.addHitTestListener(new HitTestListener()
{
@Override
public void graphicHit(HitTestEvent arg0) {
// show the attributes of the selected graphic in an editable form.
List<Graphic> hitGraphics = hitTestOverlay.getHitGraphics();
FeatureDataForm featureDataForm =
new FeatureDataForm(featureLayer, hitGraphics.get(0));
// show the form on the bottom-right of the application.
featureDataForm.getDialog().setLocation(
(int) window.getContentPane().getLocationOnScreen().getX() +
window.getContentPane().getWidth() - featureDataForm.getDialog().getWidth() - 10,
(int) window.getContentPane().getLocationOnScreen().getY() +
window.getContentPane().getHeight() - featureDataForm.getDialog().getHeight() - 10);
featureDataForm.show();
}
});
jMap.addMapOverlay(hitTestOverlay);
}
This is were the map overlay is added to the map:
LocalFeatureService service = new LocalFeatureService(dir+"\\data\\myPackage.mpk");
//details of all feature layer in the feature service
final List<LayerDetails> details = service.getFeatureLayers();
service.addLocalServiceStartCompleteListener(new LocalServiceStartCompleteListener()
{
@Override
public void localServiceStartComplete(LocalServiceStartCompleteEvent arg0)
{
for(int i = 0; i<details.size();i++)
{
//create new feature layer
featureLayer = new ArcGISFeatureLayer(details.get(i).getUrl());
//add feature to the map
map.getLayers().add(featureLayer);
//add HitTestOverlay
addHitTestDialog(map,featureLayer);
}
}
});
service.startAsync();
This exception only occurs in the described case. When another tool is chosen, the editing of attribute values works without trouble. I also haven't done any modifications in the provided classes.Any idea why this happens in exactly this case ? I hope that this could be understood.Any help would be appreciated.ThanksJ.