@Override
 public boolean isContainedInSelection(Rectangle drawingViewSelection, double scale) {
   FGERectangle drawingViewBounds =
       new FGERectangle(
           drawingViewSelection.getX(),
           drawingViewSelection.getY(),
           drawingViewSelection.getWidth(),
           drawingViewSelection.getHeight(),
           Filling.FILLED);
   boolean isFullyContained = true;
   for (ControlArea<?> ca : getConnector().getControlAreas()) {
     if (ca instanceof ControlPoint) {
       ControlPoint cp = (ControlPoint) ca;
       Point cpInContainerView =
           convertLocalNormalizedPointToRemoteViewCoordinates(
               cp.getPoint(), getDrawingGraphicalRepresentation(), scale);
       FGEPoint preciseCPInContainerView = new FGEPoint(cpInContainerView.x, cpInContainerView.y);
       if (!drawingViewBounds.containsPoint(preciseCPInContainerView)) {
         // System.out.println("Going outside: point="+preciseCPInContainerView+"
         // bounds="+containerViewBounds);
         isFullyContained = false;
       }
     }
   }
   return isFullyContained;
 }
 private void checkViewBounds() {
   FGERectangle r = getConnector().getConnectorUsedBounds();
   if (FGEUtils.checkDoubleIsAValue(r.getMinX())
       && FGEUtils.checkDoubleIsAValue(r.getMinY())
       && FGEUtils.checkDoubleIsAValue(r.getMaxX())
       && FGEUtils.checkDoubleIsAValue(r.getMaxY())) {
     minX = Math.min(r.getMinX(), 0.0);
     minY = Math.min(r.getMinY(), 0.0);
     maxX = Math.max(r.getMaxX(), 1.0);
     maxY = Math.max(r.getMaxY(), 1.0);
   }
 }
Beispiel #3
0
  boolean isDnDPattern(Point newLocationInDrawingView, MouseEvent event) {
    if (movedObjects.size() != 1) {
      return false;
    }

    FGEPoint startMovingPoint = movedObjects.get(movedObject);

    FGEPoint desiredLocation =
        new FGEPoint(
            startMovingPoint.x
                + (newLocationInDrawingView.x - startMovingLocationInDrawingView.x)
                    / view.getScale(),
            startMovingPoint.y
                + (newLocationInDrawingView.y - startMovingLocationInDrawingView.y)
                    / view.getScale());

    if (movedObject.getContainerGraphicalRepresentation() instanceof ShapeGraphicalRepresentation) {
      ShapeGraphicalRepresentation container =
          (ShapeGraphicalRepresentation<?>) movedObject.getContainerGraphicalRepresentation();
      FGERectangle bounds =
          new FGERectangle(
              0,
              0,
              container.getWidth() - movedObject.getWidth(),
              container.getHeight() - movedObject.getHeight(),
              Filling.FILLED);
      FGEPoint nearestPoint = bounds.getNearestPoint(desiredLocation);
      Point p1 =
          GraphicalRepresentation.convertPointFromDrawableToDrawing(
              movedObject.getContainerGraphicalRepresentation(),
              desiredLocation.toPoint(),
              view.getScale());
      Point p2 =
          GraphicalRepresentation.convertPointFromDrawableToDrawing(
              movedObject.getContainerGraphicalRepresentation(),
              nearestPoint.toPoint(),
              view.getScale());
      if (Point2D.distance(p1.x, p1.y, p2.x, p2.y) > FGEConstants.DND_DISTANCE) {
        return true;
      }
    }

    return false;
  }