Esempio n. 1
0
 @Override
 public void notifyObjectHasMoved() {
   if (isLayingout) {
     return;
   }
   super.notifyObjectHasMoved();
   FlexoPortMap afterPortmap = null;
   if (observedContainer != null) {
     for (GraphicalRepresentation<?> gr :
         observedContainer.getContainedGraphicalRepresentations()) {
       if (gr instanceof PortmapGR && gr != this && gr.getIsVisible()) {
         PortmapGR portmapGR = (PortmapGR) gr;
         if (getOrientation().isVertical()) {
           if (portmapGR.getX() < getX()) {
             afterPortmap = portmapGR.getPortMap();
           }
         }
         if (getOrientation().isHorizontal()) {
           if (portmapGR.getY() < getY()) {
             afterPortmap = portmapGR.getPortMap();
           }
         }
       }
     }
     observedContainer.getPortMapRegistery().reorderPortmaps(getPortMap(), afterPortmap);
     for (GraphicalRepresentation<?> gr :
         observedContainer.getContainedGraphicalRepresentations()) {
       if (gr instanceof PortmapGR) {
         ((PortmapGR) gr).layoutAs(getOrientation());
       }
     }
   }
 }
Esempio n. 2
0
 /**
  * Return distance between a point (normalized) and represented area, asserting that we are
  * working on a view (not normalized), and at a given scale
  *
  * @param aPoint view point relative to current GraphicalRepresentation, at correct scale
  * @param scale
  * @return
  */
 public double getDistanceToArea(Point aPoint, double scale) {
   FGEPoint normalizedPoint =
       graphicalRepresentation.convertViewCoordinatesToNormalizedPoint(aPoint, scale);
   FGEPoint nearestPoint = getArea().getNearestPoint(normalizedPoint);
   Point pt1 =
       graphicalRepresentation.convertNormalizedPointToViewCoordinates(nearestPoint, scale);
   return Point2D.distance(pt1.x, pt1.y, aPoint.x, aPoint.y);
 }
Esempio n. 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;
  }
Esempio n. 4
0
  MoveInfo(ShapeGraphicalRepresentation graphicalRepresentation, DrawingController<?> controller) {
    view = controller.getDrawingView();

    startMovingLocationInDrawingView =
        GraphicalRepresentation.convertPointFromDrawableToDrawing(
            graphicalRepresentation.getParentGraphicalRepresentation(),
            new Point(
                graphicalRepresentation.getViewX(controller.getScale()),
                graphicalRepresentation.getViewY(controller.getScale())),
            controller.getScale());
    currentLocationInDrawingView = new Point(startMovingLocationInDrawingView);

    movedObject = graphicalRepresentation;

    if (!controller.getSelectedObjects().contains(movedObject)) {
      controller.setSelectedObject(movedObject);
    }

    movedObjects = new Hashtable<ShapeGraphicalRepresentation, FGEPoint>();
    movedObjects.put(movedObject, movedObject.getLocation());

    // Now see objects coming with
    for (GraphicalRepresentation d : controller.getSelectedObjects()) {
      if (d != graphicalRepresentation
          && d instanceof ShapeGraphicalRepresentation
          && ((ShapeGraphicalRepresentation) d).getContainer()
              == graphicalRepresentation.getContainer()
          && !d.getIsReadOnly()
          && ((ShapeGraphicalRepresentation) d).getLocationConstraints()
              != LocationConstraints.UNMOVABLE) {
        // OK, d comes with me
        movedObjects.put(
            ((ShapeGraphicalRepresentation) d), ((ShapeGraphicalRepresentation) d).getLocation());
      }
    }
  }