Search in sources :

Example 1 with MoveClipRequest

use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.

the class ClipInsertCommand method moveBackClipsBehind.

private TimelinePosition moveBackClipsBehind(TimelinePosition positionToInsertTo, List<Integer> channelIndices, TimelinePosition distanceToMove, boolean moveBackward, TimelineInterval combinedInterval) {
    TreeSet<TimelineClip> clipsToMoveBack = new TreeSet<>();
    if (timelineEditMode.equals(TimelineEditMode.SINGLE_CHANNEL_RIPPLE)) {
        clipsToMoveBack = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(positionToInsertTo, channelIndices, List.of());
    } else if (timelineEditMode.equals(TimelineEditMode.ALL_CHANNEL_RIPPLE)) {
        clipsToMoveBack = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(positionToInsertTo, timelineManager.getAllChannelIndices(), List.of());
    } else {
        if (moveBackward) {
            TreeSet<TimelineClip> clipsRightOf = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(positionToInsertTo, channelIndices, clipIdsToInsert);
            TreeSet<TimelineClip> clipsLeftOf = timelineManager.findClipLeftOfPositionIncludingPartialOnChannels(combinedInterval.getStartPosition(), channelIndices, clipIdsToInsert);
            clipsRightOf.retainAll(clipsLeftOf);
            clipsToMoveBack = clipsRightOf;
        } else {
            TreeSet<TimelineClip> clipsRightOf = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(combinedInterval.getEndPosition(), channelIndices, clipIdsToInsert);
            TreeSet<TimelineClip> clipsLeftOf = timelineManager.findClipLeftOfPositionOnChannels(positionToInsertTo.add(insertInPlace.getInterval().getLength()), channelIndices, clipIdsToInsert);
            clipsRightOf.retainAll(clipsLeftOf);
            clipsToMoveBack = clipsRightOf;
        }
    }
    if (clipsToMoveBack.size() > 0) {
        TimelineClip firstClipToMove = clipsToMoveBack.stream().findFirst().get();
        MoveClipRequest moveClipRequest = MoveClipRequest.builder().withAdditionalClipIds(clipsToMoveBack.stream().map(a -> a.getId()).collect(Collectors.toList())).withAdditionalSpecialPositions(List.of()).withClipId(firstClipToMove.getId()).withEnableJumpingToSpecialPosition(false).withMoreMoveExpected(false).withNewChannelId(timelineManager.findChannelForClipId(firstClipToMove.getId()).get().getId()).withNewPosition(firstClipToMove.getInterval().getStartPosition().add(distanceToMove)).build();
        timelineManager.moveClip(moveClipRequest);
    }
    if (moveBackward || clipsToMoveBack.size() == 0) {
        return positionToInsertTo;
    } else {
        return findCombinedInterval(new ArrayList<>(clipsToMoveBack)).getEndPosition();
    }
}
Also used : TimelineEditMode(com.helospark.tactview.ui.javafx.repository.timelineeditmode.TimelineEditMode) MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Collectors(java.util.stream.Collectors) MessagingService(com.helospark.tactview.core.util.messaging.MessagingService) TreeSet(java.util.TreeSet) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) ArrayList(java.util.ArrayList) List(java.util.List) ClipChannelIdPair(com.helospark.tactview.core.timeline.ClipChannelIdPair) UiCommand(com.helospark.tactview.ui.javafx.commands.UiCommand) TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) NotificationMessage(com.helospark.tactview.core.timeline.message.NotificationMessage) Collections(java.util.Collections) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip)

Example 2 with MoveClipRequest

use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.

the class RippleRemoveClipCommand method revert.

@Override
public void revert() {
    if (!rippleDeletePerformed) {
        return;
    }
    MoveClipRequest moveClipRequest = MoveClipRequest.builder().withAdditionalClipIds(movedClips.stream().map(a -> a.getId()).collect(Collectors.toList())).withAdditionalSpecialPositions(List.of()).withClipId(movedClips.get(0).getId()).withEnableJumpingToSpecialPosition(false).withMoreMoveExpected(false).withNewChannelId(timelineManager.findChannelForClipId(movedClips.get(0).getId()).get().getId()).withNewPosition(movedClips.get(0).getInterval().getStartPosition().add(moveDistance)).build();
    timelineManager.moveClip(moveClipRequest);
    for (var entry : removedClips.entries()) {
        timelineManager.addClip(entry.getKey(), entry.getValue());
    }
}
Also used : TimelineEditMode(com.helospark.tactview.ui.javafx.repository.timelineeditmode.TimelineEditMode) MultiValuedMap(org.apache.commons.collections4.MultiValuedMap) MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Set(java.util.Set) Collectors(java.util.stream.Collectors) TimelineLength(com.helospark.tactview.core.timeline.TimelineLength) MessagingService(com.helospark.tactview.core.util.messaging.MessagingService) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) List(java.util.List) CloneRequestMetadata(com.helospark.tactview.core.clone.CloneRequestMetadata) UiCommand(com.helospark.tactview.ui.javafx.commands.UiCommand) TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) NotificationMessage(com.helospark.tactview.core.timeline.message.NotificationMessage) Level(com.helospark.tactview.core.timeline.message.NotificationMessage.Level) MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest)

Example 3 with MoveClipRequest

use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.

the class ClipMovedCommand method execute.

@Override
public void execute() {
    MoveClipRequest request = MoveClipRequest.builder().withClipId(clipId).withAdditionalClipIds(additionalClipIds).withNewPosition(newPosition).withNewChannelId(newChannelId).withMaximumJump(maximumJumpLength).withMoreMoveExpected(moreMoveExpected).withEnableJumpingToSpecialPosition(enableJumpingToSpecialPosition).withAdditionalSpecialPositions(additionalPositions).build();
    TimelineInterval newInterval = timelineManager.findClipById(clipId).get().getInterval();
    wasOperationSuccessful = timelineManager.moveClip(request);
    hasIntervalChanged = !previousPosition.equals(newInterval.getStartPosition());
}
Also used : TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest)

Example 4 with MoveClipRequest

use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.

the class ClipMovedCommand method revert.

@Override
public void revert() {
    MoveClipRequest request = MoveClipRequest.builder().withClipId(clipId).withAdditionalClipIds(additionalClipIds).withNewPosition(previousPosition).withNewChannelId(originalChannelId).withEnableJumpingToSpecialPosition(false).build();
    timelineManager.moveClip(request);
}
Also used : MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest)

Example 5 with MoveClipRequest

use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.

the class ClipResizedCommand method revert.

@Override
public void revert() {
    boolean isAnyRippleModeEnabled = !timelineEditMode.equals(TimelineEditMode.NORMAL);
    TimelinePosition lengthToJumpToUse = lengthToJump;
    for (var clipId : clipIds) {
        TimelineClip clip = timelineManager.findClipById(clipId).orElseThrow(() -> new IllegalArgumentException("No clip found"));
        TimelinePosition previousPosition = originalPosition;
        boolean wasLeftRipple = left && isAnyRippleModeEnabled;
        TimelinePosition positionToUse = previousPosition;
        if (wasLeftRipple) {
            TimelineLength intervalSizeDiff = clip.getGlobalInterval().getLength().subtract(originalInterval.getLength());
            positionToUse = positionToUse.add(intervalSizeDiff.toPosition());
            lengthToJumpToUse = intervalSizeDiff.toPosition().negate();
        } else {
            lengthToJumpToUse = originalInterval.getEndPosition().subtract(clip.getInterval().getEndPosition());
        }
        ResizeClipRequest request = ResizeClipRequest.builder().withClip(clip).withLeft(left).withUseSpecialPoints(false).withPosition(positionToUse).withKeepLeftSideOfClipAtSamePlace(wasLeftRipple).withIgnoreIntersection(clipsToMove.stream().map(a -> a.clip).collect(Collectors.toList())).build();
        timelineManager.resizeClip(request);
    }
    if (clipsToMove.size() > 0) {
        TimelineClip firstClipToMove = clipsToMove.stream().findFirst().get().clip;
        MoveClipRequest moveClipRequest = MoveClipRequest.builder().withAdditionalClipIds(clipsToMove.stream().map(a -> a.clip.getId()).collect(Collectors.toList())).withAdditionalSpecialPositions(List.of()).withClipId(firstClipToMove.getId()).withEnableJumpingToSpecialPosition(false).withMoreMoveExpected(false).withNewChannelId(timelineManager.findChannelForClipId(firstClipToMove.getId()).get().getId()).withNewPosition(firstClipToMove.getInterval().getStartPosition().add(lengthToJumpToUse)).build();
        timelineManager.moveClip(moveClipRequest);
    }
}
Also used : TimelineEditMode(com.helospark.tactview.ui.javafx.repository.timelineeditmode.TimelineEditMode) MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Set(java.util.Set) Collectors(java.util.stream.Collectors) TimelineLength(com.helospark.tactview.core.timeline.TimelineLength) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) ArrayList(java.util.ArrayList) List(java.util.List) Generated(javax.annotation.Generated) ClipChannelIdPair(com.helospark.tactview.core.timeline.ClipChannelIdPair) UiCommand(com.helospark.tactview.ui.javafx.commands.UiCommand) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) ResizeClipRequest(com.helospark.tactview.core.timeline.ResizeClipRequest) ResizeClipRequest(com.helospark.tactview.core.timeline.ResizeClipRequest) MoveClipRequest(com.helospark.tactview.core.timeline.MoveClipRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) TimelineLength(com.helospark.tactview.core.timeline.TimelineLength)

Aggregations

MoveClipRequest (com.helospark.tactview.core.timeline.MoveClipRequest)14 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)9 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)9 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)9 UiCommand (com.helospark.tactview.ui.javafx.commands.UiCommand)9 List (java.util.List)9 TimelineEditMode (com.helospark.tactview.ui.javafx.repository.timelineeditmode.TimelineEditMode)7 ArrayList (java.util.ArrayList)7 Collectors (java.util.stream.Collectors)7 TimelineInterval (com.helospark.tactview.core.timeline.TimelineInterval)6 Set (java.util.Set)6 NotificationMessage (com.helospark.tactview.core.timeline.message.NotificationMessage)5 TimelineLength (com.helospark.tactview.core.timeline.TimelineLength)4 Level (com.helospark.tactview.core.timeline.message.NotificationMessage.Level)4 Optional (java.util.Optional)4 Generated (javax.annotation.Generated)4 ClipChannelIdPair (com.helospark.tactview.core.timeline.ClipChannelIdPair)3 TimelineChannel (com.helospark.tactview.core.timeline.TimelineChannel)3 MessagingService (com.helospark.tactview.core.util.messaging.MessagingService)3 Collections (java.util.Collections)3