/**
  * @see
  *     net.refractions.udig.project.ui.tool.AbstractTool#mouseDragged(net.refractions.udig.project.render.displayAdapter.MapMouseEvent)
  */
 public void mouseDragged(MapMouseEvent e) {
   // update the glasspane if dragging
   if (dragging && activeGlassPane != null && draggingPlaceMarker != null) {
     Point point = null;
     if (draggingPlaceMarker.isBasemapMarker() && draggingPlaceMarker.getCoord() != null) {
       point = getContext().worldToPixel(draggingPlaceMarker.getCoord());
     } else {
       point = draggingPlaceMarker.getPoint();
     }
     int x = point.x + (e.x - mouseStart.x);
     int y = point.y + (e.y - mouseStart.y);
     // make sure any image markers stay within the bounds of the image
     Point validatedPoint = new Point(x, y);
     if (!draggingPlaceMarker.isBasemapMarker() && draggingPlaceMarker.getImage() != null) {
       GeoReferenceImage image = draggingPlaceMarker.getImage();
       validatedPoint = validateImagePoint(image, x, y);
     }
     activeGlassPane.setDragTranslation(validatedPoint.x, validatedPoint.y);
     context.getViewportPane().repaint();
   }
 }
  /**
   * @see
   *     net.refractions.udig.project.ui.tool.AbstractTool#mouseReleased(net.refractions.udig.project.render.displayAdapter.MapMouseEvent)
   */
  public void mouseReleased(MapMouseEvent e) {
    // turn dragging off
    if (dragging) {
      if (activeGlassPane != null) {
        Point point = null;
        if (draggingPlaceMarker.isBasemapMarker() && draggingPlaceMarker.getCoord() != null) {
          point = getContext().worldToPixel(draggingPlaceMarker.getCoord());
        } else {
          point = draggingPlaceMarker.getPoint();
        }
        int x = point.x + (e.x - mouseStart.x);
        int y = point.y + (e.y - mouseStart.y);
        // make sure any image markers stay within the bounds of the image
        Point validatedPoint = new Point(x, y);
        if (!draggingPlaceMarker.isBasemapMarker() && draggingPlaceMarker.getImage() != null) {
          GeoReferenceImage image = draggingPlaceMarker.getImage();
          validatedPoint = validateImagePoint(image, x, y);
        }
        activeGlassPane.endDraggingMarker(validatedPoint.x, validatedPoint.y);
      }

      // clear any events before we try to pan. This dramatically reduces the number
      // of images drawn to the screen in the wrong spot
      ((ViewportPane) getContext().getMapDisplay()).update();

      dragging = false;
      if (draggingPlaceMarker != null) {
        draggingPlaceMarker.setDragging(false);
      }
    }

    // refresh the layer
    if (activeMapGraphic != null) {
      activeMapGraphic.getLayer(getContext().getMap()).refresh(null); // refresh to ensure the
      // dragged placemarker
      // reappears
    }
  }