Beispiel #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());
       }
     }
   }
 }
Beispiel #2
0
 @Override
 public void delete() {
   if (observedContainer != null) {
     observedContainer.deleteObserver(this);
   }
   super.delete();
 }
Beispiel #3
0
 private void updateLayout() {
   if (getContainerGraphicalRepresentation() != null
       && getContainerGraphicalRepresentation() instanceof PortmapRegisteryGR) {
     if (observedContainer != getContainerGraphicalRepresentation()) {
       if (observedContainer != null) {
         observedContainer.deleteObserver(this);
       }
       observedContainer = (PortmapRegisteryGR) getContainerGraphicalRepresentation();
       if (observedContainer != null) {
         observedContainer.addObserver(this);
       }
     }
     SimplifiedCardinalDirection orientation = observedContainer.getOrientation();
     if (orientation != layoutedAs) {
       layoutAs(orientation);
     }
   } else {
     logger.warning("Unexpected container: " + getContainerGraphicalRepresentation());
   }
 }
Beispiel #4
0
  private void layoutAs(SimplifiedCardinalDirection orientation) {
    if (observedContainer == null) {
      return;
    }
    if (isLayingout) {
      return;
    }
    isLayingout = true;
    try {
      int index = getPortmapIndex();

      setLocationConstraints(LocationConstraints.AREA_CONSTRAINED);
      if (orientation == SimplifiedCardinalDirection.NORTH) {
        setX(ProcessEditorConstants.PORTMAP_MARGIN + index * PORTMAP_SIZE);
        setY(0);
        setBorder(new ShapeGraphicalRepresentation.ShapeBorder(2, 18, 3, 3));
        setLocationConstrainedArea(FGELine.makeHorizontalLine(new FGEPoint(0.5, 0.5)));
      } else if (orientation == SimplifiedCardinalDirection.SOUTH) {
        setX(ProcessEditorConstants.PORTMAP_MARGIN + index * PORTMAP_SIZE);
        setY(observedContainer.getHeight() - ProcessEditorConstants.PORTMAP_REGISTERY_WIDTH);
        setBorder(new ShapeGraphicalRepresentation.ShapeBorder(18, 2, 3, 3));
        setLocationConstrainedArea(FGELine.makeHorizontalLine(new FGEPoint(0.5, 0.5)));
      } else if (orientation == SimplifiedCardinalDirection.WEST) {
        setX(0);
        setY(ProcessEditorConstants.PORTMAP_MARGIN + index * PORTMAP_SIZE);
        setBorder(new ShapeGraphicalRepresentation.ShapeBorder(3, 3, 2, 18));
        setLocationConstrainedArea(FGELine.makeVerticalLine(new FGEPoint(0.5, 0.5)));
      } else if (orientation == SimplifiedCardinalDirection.EAST) {
        setX(observedContainer.getWidth() - ProcessEditorConstants.PORTMAP_REGISTERY_WIDTH);
        setY(ProcessEditorConstants.PORTMAP_MARGIN + index * PORTMAP_SIZE);
        setBorder(new ShapeGraphicalRepresentation.ShapeBorder(3, 3, 18, 2));
        setLocationConstrainedArea(FGELine.makeVerticalLine(new FGEPoint(0.5, 0.5)));
      }
      // System.out.println("layout as "+orientation+" index="+index);
      layoutedAs = orientation;
    } finally {
      isLayingout = false;
    }
  }
Beispiel #5
0
  protected int getPortmapIndex() {
    if (observedContainer == null) {
      return 0;
    }
    Vector<FlexoPortMap> visiblePortmaps = new Vector<FlexoPortMap>();
    for (FlexoPortMap pm : observedContainer.getPortMapRegistery().getPortMaps()) {
      if (pm.getIsVisible()) {
        visiblePortmaps.add(pm);
      }
    }

    return visiblePortmaps.indexOf(getPortMap());
  }