I am seeing the same behavior after approximately 400 vertices added to graphic where things start to lag. At around 600-700 vertices the application freezes. This is running the following code within an Asynchronous Timer class. Any ideas on workarounds? From the ESRI samples it seems like you need to add in an entirely new graphic on each refresh and then remove the old one. Is there no way to just draw the new portion of the graphic to save memory? If not wondering if there is a workaround to "flush the graphic every so many vertices?
private void addGeometry(Point point) {
FeatureInformation pFeatureInformation = FeatureInformation.getInstance();
if (pFeatureInformation.getEditMode() != FeatureInformation.EditMode.NONE) {
pFeatureInformation.mPoints.add(point);
Integer oldGraphic = graphicID;
//workingLayer.removeAll();
if (pFeatureInformation.getEditMode() == FeatureInformation.EditMode.POINT) {
Graphic graphic = new Graphic(point, pointSymbol);
graphicID = workingLayer.addGraphic(graphic);
activeGeometry = point;
} else if (pFeatureInformation.getEditMode() == FeatureInformation.EditMode.POLYLINE) {
// **for vertex recognition
Graphic pointGraphic = new Graphic(pFeatureInformation.mPoints.get(0), pointSymbol);
graphicID = workingLayer.addGraphic(pointGraphic);
//
MultiPath multipath = new Polyline();
multipath.startPath(pFeatureInformation.mPoints.get(0));
for (int i = 1; i < pFeatureInformation.mPoints.size(); i++) {
multipath.lineTo(pFeatureInformation.mPoints.get(i));
// for vertex recognition
Graphic pointGraphic2 = new Graphic(pFeatureInformation.mPoints.get(i), pointSymbol);
graphicID = workingLayer.addGraphic(pointGraphic2);
}
Graphic graphic = new Graphic(multipath, lineSymbol);
graphicID = workingLayer.addGraphic(graphic);
activeGeometry = multipath;
} else if (pFeatureInformation.getEditMode() == FeatureInformation.EditMode.POLYGON) {
// **for vertex recognition
Graphic pointGraphic = new Graphic(
pFeatureInformation.mPoints.get(0), pointSymbol);
graphicID = workingLayer.addGraphic(pointGraphic);
//
MultiPath multipath = new Polygon();
multipath.startPath(pFeatureInformation.mPoints.get(0));
for (int i = 1; i < pFeatureInformation.mPoints.size(); i++) {
multipath.lineTo(pFeatureInformation.mPoints.get(i));
// for vertex recognition
Graphic pointGraphic2 = new Graphic(pFeatureInformation.mPoints.get(i), pointSymbol);
graphicID = workingLayer.addGraphic(pointGraphic2);
}
Graphic graphic = new Graphic(multipath, polygonSymbol);
graphicID = workingLayer.addGraphic(graphic);
activeGeometry = multipath;
}
try {
workingLayer.removeGraphic(oldGraphic);
} catch (Exception e) {
// TODO: handle exception
}
}
}