示例#1
0
    @Override
    public void setSecond(Double second) {
      Point2D oldPosition = super.copy();
      Point2D newPosition = super.copy();
      newPosition.setSecond(second);

      onChange(oldPosition, newPosition);
    }
示例#2
0
    @Override
    public void setFirst(Double first) {
      Point2D oldPosition = super.copy();
      Point2D newPosition = super.copy();
      newPosition.setFirst(first);

      onChange(oldPosition, newPosition);
    }
示例#3
0
    @Nonnull
    private Point2D onChange(@Nonnull Point2D oldPosition, @Nonnull Point2D newPosition) {
      if (positionListenerEntries != null) {
        for (PositionListenerEntry positionListenerEntry : positionListenerEntries) {
          if (!positionListenerEntry.listener.beforeChangePosition(
              oldPosition.copy(), newPosition)) {
            return this;
          }
        }
      }

      super.setFirst(newPosition.getFirst());
      super.setSecond(newPosition.getSecond());

      if (positionListenerEntries != null) {
        for (PositionListenerEntry positionListenerEntry : positionListenerEntries) {
          positionListenerEntry.listener.afterChangePosition(
              oldPosition.copy(), newPosition.copy());
        }
      }

      return this;
    }
示例#4
0
  public void setPosition(Point2D position) {
    Point2D oldPosition = this.position.copy();
    Point2D newPosition = position.copy();

    if (positionListenerEntries != null) {
      for (PositionListenerEntry positionListenerEntry : positionListenerEntries) {
        if (!positionListenerEntry.listener.beforeChangePosition(oldPosition.copy(), newPosition)) {
          return;
        }
      }
    }

    this.position = this.new ListeningPoint2D(newPosition);

    if (positionListenerEntries != null) {
      for (PositionListenerEntry positionListenerEntry : positionListenerEntries) {
        positionListenerEntry.listener.afterChangePosition(oldPosition.copy(), newPosition.copy());
      }
    }
  }