Search in sources :

Example 1 with LightDiContext

use of com.helospark.lightdi.LightDiContext in project tactview by helospark.

the class JavaFXUiMain method init.

@Override
public void init() throws Exception {
    super.init();
    Platform.runLater(() -> {
        splashStage = new Stage(StageStyle.DECORATED);
        splashStage.setTitle("Tactview starting...");
        StylesheetAdderService.setTactviewIconForStageStatic(splashStage);
        splasViewh = new ImageView(new Image(getClass().getResource("/tactview-splash.png").toString()));
        splashStage.initStyle(StageStyle.TRANSPARENT);
        showSplash(splashStage, splasViewh);
    });
    LightDiContextConfiguration configuration = LightDiContextConfiguration.builder().withThreadNumber(4).withCheckForIntegrity(true).withAdditionalDependencies(Collections.singletonList(new JnaLightDiPlugin())).withUseClasspathFile(false).build();
    List<Class<?>> allClasses = new ArrayList<>();
    allClasses.add(MainApplicationConfiguration.class);
    allClasses.addAll(PluginMainClassProviders.getPluginClasses());
    lightDi = new LightDiContext(configuration);
    lightDi.addPropertySource(createInitialPropertySource());
    lightDi.loadDependencies(List.of(), allClasses);
    uiTimeline = lightDi.getBean(UiTimeline.class);
    uiTimelineManager = lightDi.getBean(UiTimelineManager.class);
    effectPropertyView = lightDi.getBean(PropertyView.class);
    uiTimelineManager.registerUiPlaybackConsumer(position -> uiTimeline.updateLine(position));
    uiTimelineManager.registerUiPlaybackConsumer(position -> effectPropertyView.updateValues(position));
    displayUpdateService = lightDi.getBean(DisplayUpdaterService.class);
    projectSizeInitializer = lightDi.getBean(ProjectSizeInitializer.class);
    uiTimelineManager.setDisplayUpdaterService(lightDi.getBean(DisplayUpdaterService.class));
    uiProjectRepository = lightDi.getBean(UiProjectRepository.class);
    renderService = lightDi.getBean(RenderDialogOpener.class);
    lightDi.eagerInitAllBeans();
}
Also used : LightDiContext(com.helospark.lightdi.LightDiContext) UiProjectRepository(com.helospark.tactview.ui.javafx.repository.UiProjectRepository) ArrayList(java.util.ArrayList) BufferedImage(java.awt.image.BufferedImage) Image(javafx.scene.image.Image) RenderDialogOpener(com.helospark.tactview.ui.javafx.render.RenderDialogOpener) UiTimeline(com.helospark.tactview.ui.javafx.uicomponents.UiTimeline) JnaLightDiPlugin(com.helospark.tactview.core.util.jpaplugin.JnaLightDiPlugin) Stage(javafx.stage.Stage) ProjectSizeInitializer(com.helospark.tactview.ui.javafx.menu.defaultmenus.projectsize.ProjectSizeInitializer) ImageView(javafx.scene.image.ImageView) LightDiContextConfiguration(com.helospark.lightdi.LightDiContextConfiguration) PropertyView(com.helospark.tactview.ui.javafx.uicomponents.PropertyView)

Example 2 with LightDiContext

use of com.helospark.lightdi.LightDiContext in project tactview by helospark.

the class IntegrationTestUtil method startContext.

public static LightDiContext startContext() {
    LightDiContextConfiguration configuration = LightDiContextConfiguration.builder().withThreadNumber(4).withCheckForIntegrity(true).withAdditionalDependencies(Collections.singletonList(new JnaLightDiPlugin())).build();
    LightDiContext lightDi = LightDi.initContextByClass(TestContextConfiguration.class, configuration);
    lightDi.eagerInitAllBeans();
    return lightDi;
}
Also used : LightDiContext(com.helospark.lightdi.LightDiContext) JnaLightDiPlugin(com.helospark.tactview.core.util.jpaplugin.JnaLightDiPlugin) LightDiContextConfiguration(com.helospark.lightdi.LightDiContextConfiguration)

Example 3 with LightDiContext

use of com.helospark.lightdi.LightDiContext 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 4 with LightDiContext

use of com.helospark.lightdi.LightDiContext 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)

Example 5 with LightDiContext

use of com.helospark.lightdi.LightDiContext in project tactview by helospark.

the class CoreContextStartedIT method testContextShouldStart.

@Test
public void testContextShouldStart() {
    LightDiContext lightDi = IntegrationTestUtil.startContext();
    TactViewCoreConfiguration asd = lightDi.getBean(TactViewCoreConfiguration.class);
    assertThat(asd, is(not(nullValue())));
}
Also used : LightDiContext(com.helospark.lightdi.LightDiContext) TactViewCoreConfiguration(com.helospark.tactview.core.TactViewCoreConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

LightDiContext (com.helospark.lightdi.LightDiContext)6 Test (org.junit.jupiter.api.Test)3 LightDiContextConfiguration (com.helospark.lightdi.LightDiContextConfiguration)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 VisualTimelineClip (com.helospark.tactview.core.timeline.VisualTimelineClip)2 CreateEffectRequest (com.helospark.tactview.core.timeline.effect.CreateEffectRequest)2 EffectFactory (com.helospark.tactview.core.timeline.effect.EffectFactory)2 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)2 JnaLightDiPlugin (com.helospark.tactview.core.util.jpaplugin.JnaLightDiPlugin)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 TactViewCoreConfiguration (com.helospark.tactview.core.TactViewCoreConfiguration)1 LoadMetadata (com.helospark.tactview.core.save.LoadMetadata)1 SaveMetadata (com.helospark.tactview.core.save.SaveMetadata)1 CacheableTestContext (com.helospark.tactview.core.util.cacheable.context.CacheableTestContext)1 ProjectSizeInitializer (com.helospark.tactview.ui.javafx.menu.defaultmenus.projectsize.ProjectSizeInitializer)1 RenderDialogOpener (com.helospark.tactview.ui.javafx.render.RenderDialogOpener)1 UiProjectRepository (com.helospark.tactview.ui.javafx.repository.UiProjectRepository)1 PropertyView (com.helospark.tactview.ui.javafx.uicomponents.PropertyView)1