@Override
 public void updateOverlay(final BezierFigure figure, final OverlayView view) {
   super.updateOverlay(figure, view);
   final PolygonOverlay poverlay = downcastOverlay(view.getData());
   final PolygonRegionOfInterest roi = poverlay.getRegionOfInterest();
   final int nodeCount = figure.getNodeCount();
   while (roi.getVertexCount() > nodeCount) {
     roi.removeVertex(nodeCount);
     if (log != null) log.debug("Removed node from overlay.");
   }
   for (int i = 0; i < nodeCount; i++) {
     final Node node = figure.getNode(i);
     final double[] position = new double[] {node.x[0], node.y[0]};
     if (roi.getVertexCount() == i) {
       roi.addVertex(i, new RealPoint(position));
       if (log != null) log.debug("Added node to overlay");
     } else {
       if ((position[0] != roi.getVertex(i).getDoublePosition(0))
           || (position[1] != roi.getVertex(i).getDoublePosition(1))) {
         if (log != null) {
           log.debug(String.format("Vertex # %d moved to %f,%f", i + 1, position[0], position[1]));
         }
       }
       roi.setVertexPosition(i, position);
     }
   }
   poverlay.update();
 }
 @Override
 public void updateFigure(final OverlayView view, final BezierFigure figure) {
   super.updateFigure(view, figure);
   final PolygonOverlay polygonOverlay = downcastOverlay(view.getData());
   final PolygonRegionOfInterest roi = polygonOverlay.getRegionOfInterest();
   final int vertexCount = roi.getVertexCount();
   while (figure.getNodeCount() > vertexCount) {
     figure.removeNode(vertexCount);
   }
   for (int i = 0; i < vertexCount; i++) {
     final RealLocalizable vertex = roi.getVertex(i);
     final double x = vertex.getDoublePosition(0);
     final double y = vertex.getDoublePosition(1);
     if (figure.getNodeCount() == i) {
       figure.addNode(new Node(x, y));
     } else {
       final Node node = figure.getNode(i);
       node.mask = 0;
       Arrays.fill(node.x, x);
       Arrays.fill(node.y, y);
     }
   }
 }