Search in sources :

Example 1 with CreateEffectRequest

use of com.helospark.tactview.core.timeline.effect.CreateEffectRequest in project tactview by helospark.

the class CommonEffectTest method testThatEffectCanBeSavedAndRestored.

@Test
public void testThatEffectCanBeSavedAndRestored() throws IOException {
    LightDiContext lightDi = IntegrationTestUtil.startContext();
    List<EffectFactory> effectFactories = lightDi.getListOfBeans(EffectFactory.class);
    FakeUi fakeUi = lightDi.getBean(FakeUi.class);
    VisualTimelineClip clip = (VisualTimelineClip) fakeUi.dragProceduralClipToFirstChannel("singlecolor", TimelinePosition.ofZero());
    for (var effectFactory : effectFactories) {
        StatelessEffect effect = effectFactory.createEffect(new CreateEffectRequest(TimelinePosition.ofZero(), effectFactory.getEffectId(), TimelineClipType.VIDEO, clip.getInterval()));
        if (!(effect instanceof StatelessVideoEffect)) {
            continue;
        }
        if (!(effect instanceof StatelessVideoEffect) || effectFactory.getEffectId().equals("lensdistort")) /**
         * trello.201, check why this occasionally fails
         */
        {
            continue;
        }
        ReadOnlyClipImage originalFrame = getFrame((StatelessVideoEffect) effect, clip);
        SaveMetadata saveMetadata = new SaveMetadata(false);
        Object savedEffect = effect.generateSavedContent(saveMetadata);
        String saveData = createObjectMapper(saveMetadata).writeValueAsString(savedEffect);
        JsonNode readData = StaticObjectMapper.objectMapper.readTree(saveData);
        StatelessEffect restoredEffect = effectFactory.restoreEffect(readData, new LoadMetadata("filepath", StaticObjectMapper.objectMapper, lightDi));
        ReadOnlyClipImage clonedFrame = getFrame((StatelessVideoEffect) restoredEffect, clip);
        IntegrationTestUtil.assertFrameEquals(originalFrame, clonedFrame, effectFactory.getEffectId() + " is generating different image after save and restore");
        freeFrame(originalFrame);
        freeFrame(clonedFrame);
    }
    lightDi.close();
}
Also used : LightDiContext(com.helospark.lightdi.LightDiContext) StatelessEffect(com.helospark.tactview.core.timeline.StatelessEffect) LoadMetadata(com.helospark.tactview.core.save.LoadMetadata) JsonNode(com.fasterxml.jackson.databind.JsonNode) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) EffectFactory(com.helospark.tactview.core.timeline.effect.EffectFactory) SaveMetadata(com.helospark.tactview.core.save.SaveMetadata) FakeUi(com.helospark.tactview.core.it.util.ui.FakeUi) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) StatelessVideoEffect(com.helospark.tactview.core.timeline.StatelessVideoEffect) CreateEffectRequest(com.helospark.tactview.core.timeline.effect.CreateEffectRequest) Test(org.junit.jupiter.api.Test)

Example 2 with CreateEffectRequest

use of com.helospark.tactview.core.timeline.effect.CreateEffectRequest in project tactview by helospark.

the class TimelineManagerAccessor method supportsEffect.

public boolean supportsEffect(String id, String effectId, TimelinePosition position) {
    Optional<TimelineClip> clipById = findClipById(id);
    if (!clipById.isPresent()) {
        return false;
    }
    CreateEffectRequest request = new CreateEffectRequest(position, effectId, clipById.get().getType(), clipById.get().getInterval());
    return effectFactoryChain.supports(request);
}
Also used : CreateEffectRequest(com.helospark.tactview.core.timeline.effect.CreateEffectRequest)

Example 3 with CreateEffectRequest

use of com.helospark.tactview.core.timeline.effect.CreateEffectRequest in project tactview by helospark.

the class AddScaleCommand method execute.

@Override
public void execute() {
    VisualTimelineClip clip = (VisualTimelineClip) timelineManager.findClipById(clipId).orElseThrow();
    VisualMediaMetadata metadata = clip.getMediaMetadata();
    double scaleX = (double) projectRepository.getWidth() / metadata.getWidth();
    double scaleY = (double) projectRepository.getHeight() / metadata.getHeight();
    CreateEffectRequest createEffectRequest = new CreateEffectRequest(TimelinePosition.ofZero(), scaleEffectFactory.getEffectId(), TimelineClipType.VIDEO, clip.getInterval());
    addedEffect = (ScaleEffect) effectFactoryChain.createEffect(createEffectRequest);
    addedEffect.setScale(scaleX, scaleY);
    // due to relative position
    addedEffect.setInterval(clip.getInterval().butMoveStartPostionTo(TimelinePosition.ofZero()));
    timelineManager.addEffectForClip(clip, addedEffect);
}
Also used : VisualMediaMetadata(com.helospark.tactview.core.decoder.VisualMediaMetadata) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) CreateEffectRequest(com.helospark.tactview.core.timeline.effect.CreateEffectRequest)

Example 4 with CreateEffectRequest

use of com.helospark.tactview.core.timeline.effect.CreateEffectRequest in project tactview by helospark.

the class CommonEffectTest method testThatEffectIsGeneratingSameImageAfterCloning.

@Test
public void testThatEffectIsGeneratingSameImageAfterCloning() {
    LightDiContext lightDi = IntegrationTestUtil.startContext();
    List<EffectFactory> effectFactories = lightDi.getListOfBeans(EffectFactory.class);
    FakeUi fakeUi = lightDi.getBean(FakeUi.class);
    VisualTimelineClip clip = (VisualTimelineClip) fakeUi.dragProceduralClipToFirstChannel("singlecolor", TimelinePosition.ofZero());
    for (var effectFactory : effectFactories) {
        StatelessEffect effect = effectFactory.createEffect(new CreateEffectRequest(TimelinePosition.ofZero(), effectFactory.getEffectId(), TimelineClipType.VIDEO, clip.getInterval()));
        if (!(effect instanceof StatelessVideoEffect) || effectFactory.getEffectId().equals("lensdistort")) {
            /**
             * trello.201, check why this occasionally fails
             */
            continue;
        }
        ReadOnlyClipImage originalFrame = getFrame((StatelessVideoEffect) effect, clip);
        StatelessVideoEffect clonedEffect = (StatelessVideoEffect) effect.cloneEffect(CloneRequestMetadata.ofDefault());
        ReadOnlyClipImage clonedFrame = getFrame(clonedEffect, clip);
        IntegrationTestUtil.assertFrameEquals(originalFrame, clonedFrame, effectFactory.getEffectId() + " is generating different image after clone");
        freeFrame(originalFrame);
        freeFrame(clonedFrame);
    }
    lightDi.close();
}
Also used : LightDiContext(com.helospark.lightdi.LightDiContext) FakeUi(com.helospark.tactview.core.it.util.ui.FakeUi) StatelessEffect(com.helospark.tactview.core.timeline.StatelessEffect) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) StatelessVideoEffect(com.helospark.tactview.core.timeline.StatelessVideoEffect) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) EffectFactory(com.helospark.tactview.core.timeline.effect.EffectFactory) CreateEffectRequest(com.helospark.tactview.core.timeline.effect.CreateEffectRequest) Test(org.junit.jupiter.api.Test)

Aggregations

CreateEffectRequest (com.helospark.tactview.core.timeline.effect.CreateEffectRequest)4 VisualTimelineClip (com.helospark.tactview.core.timeline.VisualTimelineClip)3 LightDiContext (com.helospark.lightdi.LightDiContext)2 FakeUi (com.helospark.tactview.core.it.util.ui.FakeUi)2 StatelessEffect (com.helospark.tactview.core.timeline.StatelessEffect)2 StatelessVideoEffect (com.helospark.tactview.core.timeline.StatelessVideoEffect)2 EffectFactory (com.helospark.tactview.core.timeline.effect.EffectFactory)2 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)2 Test (org.junit.jupiter.api.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 VisualMediaMetadata (com.helospark.tactview.core.decoder.VisualMediaMetadata)1 LoadMetadata (com.helospark.tactview.core.save.LoadMetadata)1 SaveMetadata (com.helospark.tactview.core.save.SaveMetadata)1