Search in sources :

Example 1 with TimelineInterval

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

the class ClipInsertCommand method revert.

@Override
public void revert() {
    if (success) {
        TimelineInterval newCombinedInterval = findCombinedInterval(clipsToMove);
        List<ClipChannelIdPair> removedClips = removeClipsToInsert(actuallyInsertedClips.stream().map(a -> a.clip).collect(Collectors.toList()));
        moveBackClipsBehind(combinedInterval.getStartPosition(), channelIndices, distanceToMove.negate(), !moveBackward, newCombinedInterval);
        insertClipsAt(combinedInterval.getStartPosition(), new TimelineInterval(insertInPlace.getInterval().getStartPosition(), distanceToMove.toLength()), removedClips);
    }
}
Also used : ClipChannelIdPair(com.helospark.tactview.core.timeline.ClipChannelIdPair) TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval)

Example 2 with TimelineInterval

use of com.helospark.tactview.core.timeline.TimelineInterval 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 3 with TimelineInterval

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

the class ClipInsertCommand method findCombinedInterval.

private TimelineInterval findCombinedInterval(List<TimelineClip> clipsToMove) {
    TimelinePosition startPosition = clipsToMove.get(0).getInterval().getStartPosition();
    TimelinePosition endPosition = clipsToMove.get(0).getInterval().getEndPosition();
    for (var clip : clipsToMove) {
        TimelineInterval interval = clip.getInterval();
        if (interval.getStartPosition().isLessThan(startPosition)) {
            startPosition = interval.getStartPosition();
        }
        if (interval.getEndPosition().isGreaterThan(endPosition)) {
            endPosition = interval.getEndPosition();
        }
    }
    return new TimelineInterval(startPosition, endPosition);
}
Also used : TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition)

Example 4 with TimelineInterval

use of com.helospark.tactview.core.timeline.TimelineInterval 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 5 with TimelineInterval

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

the class RippleRemoveClipCommand method checkIfRippleDeleteCanBePerformed.

private boolean checkIfRippleDeleteCanBePerformed(List<TimelineClip> clipsToRemove, TimelineLength maxLengthOfClip, List<TimelineClip> clipsToMoveBack) {
    List<String> excludedIdsInCheck = new ArrayList<>();
    clipsToMoveBack.stream().forEach(a -> excludedIdsInCheck.add(a.getId()));
    clipsToRemove.stream().forEach(a -> excludedIdsInCheck.add(a.getId()));
    Set<Integer> conflictingChannels = new HashSet<>();
    for (var clip : clipsToMoveBack) {
        TimelineChannel channel = timelineManager.findChannelForClipId(clip.getId()).get();
        int channelIndex = timelineManager.findChannelIndexForClipId(clip.getId()).get();
        TimelineInterval newInterval = clip.getInterval().butAddOffset(maxLengthOfClip.toPosition().negate());
        boolean canAddResource = channel.canAddResourceAtExcluding(newInterval, excludedIdsInCheck);
        if (!canAddResource) {
            conflictingChannels.add(channelIndex);
        }
    }
    boolean canPerformRippleDelete = conflictingChannels.isEmpty();
    if (!canPerformRippleDelete) {
        messagingService.sendMessage(new NotificationMessage("Unable to ripple delete", "Clips in channel " + conflictingChannels + " cannot be moved back", Level.ERROR));
    }
    return canPerformRippleDelete;
}
Also used : TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) NotificationMessage(com.helospark.tactview.core.timeline.message.NotificationMessage) TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

TimelineInterval (com.helospark.tactview.core.timeline.TimelineInterval)15 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)6 ArrayList (java.util.ArrayList)6 TimelineChannel (com.helospark.tactview.core.timeline.TimelineChannel)5 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)5 List (java.util.List)4 ClipChannelIdPair (com.helospark.tactview.core.timeline.ClipChannelIdPair)3 MoveClipRequest (com.helospark.tactview.core.timeline.MoveClipRequest)3 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)3 Collectors (java.util.stream.Collectors)3 MergeOnIntersectingIntervalList (com.helospark.tactview.core.timeline.MergeOnIntersectingIntervalList)2 TimelineLength (com.helospark.tactview.core.timeline.TimelineLength)2 KeyframeSuccesfullyAddedMessage (com.helospark.tactview.core.timeline.message.KeyframeSuccesfullyAddedMessage)2 NotificationMessage (com.helospark.tactview.core.timeline.message.NotificationMessage)2 UiCommand (com.helospark.tactview.ui.javafx.commands.UiCommand)2 TimelineEditMode (com.helospark.tactview.ui.javafx.repository.timelineeditmode.TimelineEditMode)2 File (java.io.File)2 Component (com.helospark.lightdi.annotation.Component)1 ImageMetadataResponse (com.helospark.tactview.core.decoder.opencv.ImageMetadataResponse)1 FFmpegRenderThreadResult (com.helospark.tactview.core.render.domain.FFmpegRenderThreadResult)1