public void mousePressed(MouseEvent e) {
    this.mousePoint = e.getPoint();

    Object topObject = null;
    PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition();
    if (pickedObjects != null) topObject = pickedObjects.getTopObject();

    if (topObject instanceof ControlPointMarker) {
      this.activeControlPoint = (ControlPointMarker) topObject;
      this.activeAction = this.activeControlPoint.getType();

      setShowAnnotation(true);
      updateAnnotation(this.activeControlPoint.getPosition());

      // update controlPointIndex;
      int i = 0;
      for (Marker controlPoint : this.controlPoints) {
        if (controlPoint.equals(topObject)) break;
        i++;
      }
      this.activeControlPointIndex = i;
      e.consume();
    } else if (topObject == this.getPolygon()) {
      this.activeAction = MOVE_POLYGON_ACTION;

      // set the shape to be the "active control point"
      this.activeControlPointIndex = -1;

      setShowAnnotation(true);
      updateAnnotation(this.polygon.getReferencePosition());
      e.consume();
    }
  }
  private static void adjustForCollisions(Canvas canvas, List<Marker> collection) {
    updated.clear();
    for (Marker marker1 : collection) {
      if (updated.contains(marker1) || !marker1.isInView()) continue;

      int collisions = 1;
      for (Marker marker2 : collection) {
        if (marker1.equals(marker2) || updated.contains(marker2) || !marker2.isInView()) continue;

        if (marker1.isMarkerOnMarker(marker2)) {
          marker2.getLocation().get(locationArray);
          float y = locationArray[1];
          float h = collisions * COLLISION_ADJUSTMENT;
          locationArray[1] = y + h;
          marker2.getLocation().set(locationArray);
          marker2.update(canvas, 0, 0);
          collisions++;
          updated.add(marker2);
        }
      }
      updated.add(marker1);
    }
  }