protected void drag(final PInputEvent event) {
   super.drag(event);
   final PDimension aDelta = event.getDeltaRelativeTo(PSWTHandle.this);
   if (aDelta.getWidth() != 0 || aDelta.getHeight() != 0) {
     dragHandle(aDelta, event);
   }
 }
Exemple #2
0
  protected void dragStandardSelection(PInputEvent e) {

    Iterator<WorldObjectImpl> selectionEn = selectedObjects.iterator();

    if (selectionEn.hasNext()) {
      e.setHandled(true);
      PDimension d = e.getDeltaRelativeTo(selectableParent.getPiccolo());

      while (selectionEn.hasNext()) {
        WorldObjectImpl node = selectionEn.next();
        if (!node.isAnimating()) {
          PDimension gDist = new PDimension();
          gDist.setSize(d);

          node.localToParent(node.globalToLocal(gDist));

          node.dragOffset(gDist.getWidth(), gDist.getHeight());
        }
      }
    }
  }
  public void dragHandle(PDimension aLocalDimension, PInputEvent aEvent) {
    PBoundsLocator l = (PBoundsLocator) getLocator();

    PNode n = l.getNode();
    PBounds b = n.getBounds();

    PNode parent = getParent();
    if (parent != n && parent instanceof PCamera) {
      ((PCamera) parent).localToView(aLocalDimension);
    }

    localToGlobal(aLocalDimension);
    n.globalToLocal(aLocalDimension);

    double dx = aLocalDimension.getWidth();
    double dy = aLocalDimension.getHeight();

    switch (l.getSide()) {
      case SwingConstants.NORTH:
        b.setRect(b.x, b.y + dy, b.width, b.height - dy);
        break;

      case SwingConstants.SOUTH:
        b.setRect(b.x, b.y, b.width, b.height + dy);
        break;

      case SwingConstants.EAST:
        b.setRect(b.x, b.y, b.width + dx, b.height);
        break;

      case SwingConstants.WEST:
        b.setRect(b.x + dx, b.y, b.width - dx, b.height);
        break;

      case SwingConstants.NORTH_WEST:
        b.setRect(b.x + dx, b.y + dy, b.width - dx, b.height - dy);
        break;

      case SwingConstants.SOUTH_WEST:
        b.setRect(b.x + dx, b.y, b.width - dx, b.height + dy);
        break;

      case SwingConstants.NORTH_EAST:
        b.setRect(b.x, b.y + dy, b.width + dx, b.height - dy);
        break;

      case SwingConstants.SOUTH_EAST:
        b.setRect(b.x, b.y, b.width + dx, b.height + dy);
        break;
    }

    boolean flipX = false;
    boolean flipY = false;

    if (b.width < 0) {
      flipX = true;
      b.width = -b.width;
      b.x -= b.width;
    }

    if (b.height < 0) {
      flipY = true;
      b.height = -b.height;
      b.y -= b.height;
    }

    if (flipX || flipY) {
      flipSiblingBoundsHandles(flipX, flipY);
    }

    n.setBounds(b);
  }