Exemple #1
0
  /** Moves the target control on top of the dummy control. */
  public void layout() {
    if (getTargetControl() == null) {
      return;
    }

    // Compute the unclipped bounds of the target in display coordinates
    Rectangle displayBounds = Geometry.toDisplay(control.getParent(), control.getBounds());

    // Clip the bounds of the target so that it doesn't go outside the dummy control's parent
    Rectangle clippingRegion = DragUtil.getDisplayBounds(control.getParent());
    displayBounds = displayBounds.intersection(clippingRegion);

    // Compute the bounds of the target, in the local coordinate system of its parent
    Rectangle targetBounds = Geometry.toControl(getTargetControl().getParent(), displayBounds);

    // Move the target
    getTargetControl().setBounds(targetBounds);
  }