private void draw(Geometry geometry) {
    org.geomajas.gwt.client.spatial.geometry.Geometry transformed =
        mapWidget
            .getMapModel()
            .getMapView()
            .getWorldViewTransformer()
            .worldToPan(GeometryConverter.toGwt(geometry));

    GraphicsContext graphics = mapWidget.getVectorContext();
    graphics.drawGroup(mapWidget.getGroup(RenderGroup.VECTOR), geometry);

    if (transformed instanceof MultiPolygon) {
      draw(geometry, null, (MultiPolygon) transformed, graphics);
    } else if (transformed instanceof MultiPoint) {
      draw(geometry, null, (MultiPoint) transformed, graphics);
    } else if (transformed instanceof MultiLineString) {
      draw(geometry, null, (MultiLineString) transformed, graphics);
    } else if (transformed instanceof Polygon) {
      draw(geometry, null, (Polygon) transformed, graphics);
    } else if (transformed instanceof LineString) {
      draw(geometry, null, (LineString) transformed, graphics);
    } else if (transformed instanceof Point) {
      draw(geometry, null, (Point) transformed, graphics);
    }
  }
  // TODO make use of the findGeometryStyle method.
  private void updateGeometry(Geometry geometry, GeometryIndex index, boolean bringToFront)
      throws GeometryIndexNotFoundException {
    // Some initialization:
    String identifier = baseName + "." + editingService.getIndexService().format(index);
    boolean marked = editingService.getIndexStateService().isMarkedForDeletion(index);

    // Find current and previous parent groups:
    Composite parentGroup =
        groups.get(identifier.substring(0, identifier.lastIndexOf('.')) + ".geometries");

    // Find the correct style:
    ShapeStyle style = new ShapeStyle();
    if (marked) {
      style = styleService.getBackgroundMarkedForDeletionStyle();
    }

    // Draw the inner ring:
    org.geomajas.gwt.client.spatial.geometry.Geometry transformed =
        mapWidget
            .getMapModel()
            .getMapView()
            .getWorldViewTransformer()
            .worldToPan(
                GeometryConverter.toGwt(
                    editingService.getIndexService().getGeometry(geometry, index)));
    if (transformed instanceof LinearRing) {
      Polygon polygon =
          mapWidget
              .getMapModel()
              .getGeometryFactory()
              .createPolygon((LinearRing) transformed, null);
      mapWidget
          .getVectorContext()
          .drawPolygon(parentGroup, identifier + ".background", polygon, style);
    }
  }
  public void onGeometryEditMove(GeometryEditMoveEvent event) {

    // Find the elements that need updating:
    Map<GeometryIndex, Boolean> indicesToUpdate = new HashMap<GeometryIndex, Boolean>();
    for (GeometryIndex index : event.getIndices()) {
      if (!indicesToUpdate.containsKey(index)) {
        indicesToUpdate.put(index, false);
        if (!Geometry.POINT.equals(editingService.getGeometry().getGeometryType())
            && !Geometry.MULTI_POINT.equals(editingService.getGeometry().getGeometryType())) {
          try {
            List<GeometryIndex> neighbors = null;
            switch (editingService.getIndexService().getType(index)) {
              case TYPE_VERTEX:
                // Move current vertex to the back. This helps the delete operation.
                indicesToUpdate.put(index, true);
                neighbors =
                    editingService.getIndexService().getAdjacentEdges(event.getGeometry(), index);
                if (neighbors != null) {
                  for (GeometryIndex neighborIndex : neighbors) {
                    if (!indicesToUpdate.containsKey(neighborIndex)) {
                      indicesToUpdate.put(neighborIndex, false);
                    }
                  }
                }

                neighbors =
                    editingService
                        .getIndexService()
                        .getAdjacentVertices(event.getGeometry(), index);
                if (neighbors != null) {
                  for (GeometryIndex neighborIndex : neighbors) {
                    if (!indicesToUpdate.containsKey(neighborIndex)) {
                      indicesToUpdate.put(neighborIndex, false);
                    }
                  }
                }
                break;
              case TYPE_EDGE:
                neighbors =
                    editingService
                        .getIndexService()
                        .getAdjacentVertices(event.getGeometry(), index);
                if (neighbors != null) {
                  for (GeometryIndex neighborIndex : neighbors) {
                    if (!indicesToUpdate.containsKey(neighborIndex)) {
                      indicesToUpdate.put(neighborIndex, false);
                    }
                  }
                }
                break;
              default:
            }
          } catch (GeometryIndexNotFoundException e) {
            throw new IllegalStateException(e);
          }
        }
      }
    }

    // Check if we need to draw the background (nice, but slows down):
    if (styleService.getBackgroundStyle() != null
        && styleService.getBackgroundStyle().getFillOpacity() > 0) {
      if (event.getGeometry().getGeometryType().equals(Geometry.POLYGON)) {
        org.geomajas.gwt.client.spatial.geometry.Geometry transformed =
            mapWidget
                .getMapModel()
                .getMapView()
                .getWorldViewTransformer()
                .worldToPan(GeometryConverter.toGwt(event.getGeometry()));
        mapWidget
            .getVectorContext()
            .drawPolygon(
                groups.get(baseName + ".background"),
                "background",
                (Polygon) transformed,
                styleService.getBackgroundStyle());
      } else if (event.getGeometry().getGeometryType().equals(Geometry.MULTI_POLYGON)
          && event.getGeometry().getGeometries() != null) {
        for (int i = 0; i < event.getGeometry().getGeometries().length; i++) {
          Geometry polygon = event.getGeometry().getGeometries()[i];

          org.geomajas.gwt.client.spatial.geometry.Geometry transformed =
              mapWidget
                  .getMapModel()
                  .getMapView()
                  .getWorldViewTransformer()
                  .worldToPan(GeometryConverter.toGwt(polygon));
          mapWidget
              .getVectorContext()
              .drawPolygon(
                  groups.get(baseName + ".geometry" + i + ".background"),
                  "background",
                  (Polygon) transformed,
                  styleService.getBackgroundStyle());
        }
      }
    }

    // Next, redraw the list:
    for (GeometryIndex index : indicesToUpdate.keySet()) {
      update(event.getGeometry(), index, indicesToUpdate.get(index));
    }
  }