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()); } } }
@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; }