Search in sources :

Example 1 with StylesheetAdderService

use of com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService in project tactview by helospark.

the class SingleFullImageViewController method renderFullScreenAtCurrentLocation.

public void renderFullScreenAtCurrentLocation() {
    TimelinePosition currentPosition = uiTimelineManager.getCurrentPosition();
    int height = projectRepository.getHeight();
    int width = projectRepository.getWidth();
    TimelineManagerFramesRequest frameRequest = TimelineManagerFramesRequest.builder().withPosition(currentPosition).withScale(1.0).withPreviewWidth(width).withPreviewHeight(height).build();
    CompletableFuture.supplyAsync(() -> {
        ByteBuffer image = timelineManagerRenderService.getFrame(frameRequest).getAudioVideoFragment().getVideoResult().getBuffer();
        return byteBufferToImageConverter.convertToJavafxImage(image, width, height);
    }).exceptionally(e -> {
        logger.error("Error rendering image", e);
        return null;
    }).thenAccept(image -> {
        Platform.runLater(() -> {
            ImageShowDialog dialog = new ImageShowDialog(image, stylesheetAdderService);
            dialog.show();
        });
    });
}
Also used : Component(com.helospark.lightdi.annotation.Component) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) CompletableFuture(java.util.concurrent.CompletableFuture) ByteBuffer(java.nio.ByteBuffer) TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) ScrollPane(javafx.scene.control.ScrollPane) ContextMenu(javafx.scene.control.ContextMenu) ImageIO(javax.imageio.ImageIO) ByteBufferToJavaFxImageConverter(com.helospark.tactview.ui.javafx.util.ByteBufferToJavaFxImageConverter) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) JavaFXUiMain(com.helospark.tactview.ui.javafx.JavaFXUiMain) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) MenuItem(javafx.scene.control.MenuItem) BufferedImage(java.awt.image.BufferedImage) GraphicsContext(javafx.scene.canvas.GraphicsContext) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Canvas(javafx.scene.canvas.Canvas) IOException(java.io.IOException) TimelineManagerRenderService(com.helospark.tactview.core.timeline.TimelineManagerRenderService) Slf4j(com.helospark.tactview.core.util.logger.Slf4j) File(java.io.File) Platform(javafx.application.Platform) FileChooser(javafx.stage.FileChooser) Stage(javafx.stage.Stage) StylesheetAdderService(com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService) SwingFXUtils(javafx.embed.swing.SwingFXUtils) ProjectRepository(com.helospark.tactview.core.repository.ProjectRepository) Image(javafx.scene.image.Image) TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) ByteBuffer(java.nio.ByteBuffer)

Example 2 with StylesheetAdderService

use of com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService in project tactview by helospark.

the class JavaFXUiMain method start.

@Override
public void start(Stage stage) throws IOException {
    DirtyRepository dirtyRepository = lightDi.getBean(DirtyRepository.class);
    ExitWithSaveService exitWithSaveService = lightDi.getBean(ExitWithSaveService.class);
    StylesheetAdderService styleSheetAdder = lightDi.getBean(StylesheetAdderService.class);
    styleSheetAdder.setTactviewIconForStage(stage);
    JavaFXUiMain.STAGE = stage;
    lightDi.getListOfBeans(MainWindowStageAware.class).forEach(listener -> listener.setMainWindowStage(stage));
    NotificationPane notificationPane = new NotificationPane();
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 650, 550, Color.GREY);
    styleSheetAdder.addStyleSheets(root, "stylesheet.css");
    MenuBar menuBar = lightDi.getBean(MenuProcessor.class).createMenuBar();
    if (SystemUtils.IS_OS_MAC_OSX) {
        // https://stackoverflow.com/a/28874063
        menuBar.useSystemMenuBarProperty().set(true);
    }
    stage.setOnCloseRequest(e -> {
        exitApplication(exitWithSaveService, e);
    });
    root.setTop(menuBar);
    stage.setScene(scene);
    stage.setTitle("TactView - Video editor");
    dirtyRepository.addUiChangeListener(value -> {
        Platform.runLater(() -> {
            String title = "";
            if (value) {
                title += "* ";
            }
            title += "TactView - Video editor";
            stage.setTitle(title);
        });
    });
    stage.setMaximized(true);
    if (SystemUtils.IS_OS_MAC) {
        SwingFXUtils.toFXImage(new BufferedImage(100, 100, TYPE_INT_BGR), null);
    }
    // spacing between child nodes only.
    SplitPane mainContentPane = new SplitPane();
    mainContentPane.setId("content-area");
    mainContentPane.setPrefWidth(scene.getWidth());
    // space between vbox border and child nodes column
    mainContentPane.setPadding(new Insets(1));
    mainContentPane.setDividerPositions(0.6);
    canvas = new Canvas();
    lightDi.getBean(CanvasStateHolder.class).setCanvas(canvas);
    lightDi.getBean(DefaultCanvasTranslateSetter.class).setDefaultCanvasTranslate(uiProjectRepository.getPreviewWidth(), uiProjectRepository.getPreviewHeight());
    InputModeRepository inputModeRepository = lightDi.getBean(InputModeRepository.class);
    inputModeRepository.setCanvas(canvas);
    displayUpdateService.setCanvas(canvas);
    displayUpdateService.updateCurrentPositionWithInvalidatedCache();
    Tooltip tooltip = new Tooltip();
    StringProperty statusTextProperty = lightDi.getBean(VideoStatusBarUpdater.class).getTextProperty();
    tooltip.textProperty().bind(statusTextProperty);
    tooltip.setHideOnEscape(false);
    tooltip.setAutoHide(false);
    tooltip.setAnchorLocation(AnchorLocation.CONTENT_TOP_LEFT);
    statusTextProperty.addListener((e, oldV, newV) -> {
        if (newV.length() > 0) {
            Bounds canvasBottom = canvas.localToScene(canvas.getBoundsInLocal());
            double x = canvasBottom.getMinX();
            double y = canvasBottom.getMaxY() + 60;
            tooltip.show(canvas, x, y);
        } else {
            tooltip.hide();
        }
    });
    tooltip.setWrapText(true);
    HBox upperPane = new HBox();
    upperPane.setId("upper-content-area");
    upperPane.setMinHeight(300);
    upperPane.setFillHeight(true);
    DetachableTabPaneLoadModel layoutToLoad = lightDi.getBean(DefaultLayoutProvider.class).provideDefaultLayout();
    DockableTabRepository dockableTabRepository = lightDi.getBean(DockableTabRepository.class);
    dockableTabRepository.setParentPane(upperPane);
    dockableTabRepository.loadAndSetModelToParent(layoutToLoad);
    TiwulFXUtil.setTiwulFXStyleSheet(scene);
    VBox lower = new VBox(5);
    lower.setPrefWidth(scene.getWidth());
    lower.setPrefHeight(300);
    lower.setId("timeline-view");
    BorderPane timeline = uiTimeline.createTimeline(lower, root);
    lower.getChildren().add(timeline);
    VBox.setVgrow(timeline, Priority.ALWAYS);
    mainContentPane.getItems().add(upperPane);
    mainContentPane.getItems().add(lower);
    mainContentPane.setOrientation(Orientation.VERTICAL);
    root.setCenter(mainContentPane);
    notificationPane.setContent(root);
    inputModeRepository.registerInputModeChangeConsumerr(onClassChangeDisableTabs());
    inputModeRepository.registerInputModeChangeConsumerr(onClassChange(timeline));
    lightDi.getListOfBeans(ScenePostProcessor.class).stream().forEach(processor -> processor.postProcess(scene));
    lightDi.getListOfBeans(PostInitializationArgsCallback.class).forEach(postInitCallback -> postInitCallback.call(mainArgs));
    if (splashStage.isShowing()) {
        stage.show();
        splashStage.toFront();
        FadeTransition fadeSplash = new FadeTransition(Duration.seconds(0.5), splasViewh);
        fadeSplash.setDelay(Duration.millis(800));
        fadeSplash.setFromValue(1.0);
        fadeSplash.setToValue(0.0);
        fadeSplash.setOnFinished(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {
                splashStage.hide();
            }
        });
        fadeSplash.play();
    }
}
Also used : BorderPane(javafx.scene.layout.BorderPane) HBox(javafx.scene.layout.HBox) NotificationPane(org.controlsfx.control.NotificationPane) Insets(javafx.geometry.Insets) ActionEvent(javafx.event.ActionEvent) ExitWithSaveService(com.helospark.tactview.ui.javafx.save.ExitWithSaveService) MenuBar(javafx.scene.control.MenuBar) StringProperty(javafx.beans.property.StringProperty) SplitPane(javafx.scene.control.SplitPane) BufferedImage(java.awt.image.BufferedImage) DefaultLayoutProvider(com.helospark.tactview.ui.javafx.layout.DefaultLayoutProvider) DirtyRepository(com.helospark.tactview.core.save.DirtyRepository) MainWindowStageAware(com.helospark.tactview.ui.javafx.aware.MainWindowStageAware) MenuProcessor(com.helospark.tactview.ui.javafx.menu.MenuProcessor) DetachableTabPaneLoadModel(com.helospark.tactview.ui.javafx.tiwulfx.com.panemu.tiwulfx.control.DetachableTabPaneLoadModel) FadeTransition(javafx.animation.FadeTransition) Canvas(javafx.scene.canvas.Canvas) Tooltip(javafx.scene.control.Tooltip) Bounds(javafx.geometry.Bounds) DefaultCanvasTranslateSetter(com.helospark.tactview.ui.javafx.uicomponents.DefaultCanvasTranslateSetter) StylesheetAdderService(com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService) Scene(javafx.scene.Scene) PostInitializationArgsCallback(com.helospark.tactview.core.init.PostInitializationArgsCallback) DockableTabRepository(com.helospark.tactview.ui.javafx.tabs.dockabletab.DockableTabRepository) VideoStatusBarUpdater(com.helospark.tactview.ui.javafx.uicomponents.VideoStatusBarUpdater) InputModeRepository(com.helospark.tactview.ui.javafx.inputmode.InputModeRepository) VBox(javafx.scene.layout.VBox)

Example 3 with StylesheetAdderService

use of com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService in project tactview by helospark.

the class GraphSetterChainItem method handle.

@Override
protected EffectLine handle(GraphProvider graphingProvider, ValueProviderDescriptor descriptor) {
    Button button = new Button("Open graph window", new Glyph("FontAwesome", FontAwesome.Glyph.DIAMOND));
    GraphingComponent graphingComponent = new GraphingComponent(250, 100, effectGraphAccessor, messagingService, menuItemFactories, commandInterpreter, stylesheetAdderService, nameToIdRepository);
    graphingComponent.setGraphProvider(graphingProvider);
    graphingComponent.setZoom(0.4);
    graphingComponent.setParent(scene.getWindow());
    graphingComponent.redrawGraphProvider();
    VBox vbox = new VBox(button, graphingComponent);
    PrimitiveEffectLine result = PrimitiveEffectLine.builder().withCurrentValueProvider(() -> effectParametersRepository.getValueAtAsObject(graphingProvider.getId(), uiTimelineManager.getCurrentPosition())).withVisibleNode(vbox).withDescriptorId(graphingProvider.getId()).withEffectParametersRepository(effectParametersRepository).withCommandInterpreter(commandInterpreter).withDescriptor(descriptor).withUpdateFunction(position -> {
        graphingComponent.redrawGraphProvider();
    }).withUpdateFromValue(value -> {
    }).build();
    button.setOnMouseClicked(event -> {
        dockableTabRepository.openTab(graphingDialog);
        graphingDialog.showProvider(graphingProvider);
    });
    return result;
}
Also used : Button(javafx.scene.control.Button) Component(com.helospark.lightdi.annotation.Component) ValueProviderDescriptor(com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor) Scene(javafx.scene.Scene) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) GraphingComponentFactory(com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.graph.factory.GraphingComponentFactory) NameToIdRepository(com.helospark.tactview.ui.javafx.repository.NameToIdRepository) GraphingDialog(com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.graph.GraphingDialog) EffectParametersRepository(com.helospark.tactview.core.timeline.effect.EffectParametersRepository) DockableTabRepository(com.helospark.tactview.ui.javafx.tabs.dockabletab.DockableTabRepository) VBox(javafx.scene.layout.VBox) MessagingService(com.helospark.tactview.core.util.messaging.MessagingService) List(java.util.List) EffectGraphAccessor(com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraphAccessor) ScenePostProcessor(com.helospark.tactview.ui.javafx.scenepostprocessor.ScenePostProcessor) Glyph(org.controlsfx.glyphfont.Glyph) GraphProvider(com.helospark.tactview.core.timeline.effect.interpolation.provider.GraphProvider) StylesheetAdderService(com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService) FontAwesome(org.controlsfx.glyphfont.FontAwesome) GraphingComponent(com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.graph.GraphingComponent) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) Button(javafx.scene.control.Button) Glyph(org.controlsfx.glyphfont.Glyph) VBox(javafx.scene.layout.VBox) GraphingComponent(com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.graph.GraphingComponent)

Aggregations

StylesheetAdderService (com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService)3 Scene (javafx.scene.Scene)3 Component (com.helospark.lightdi.annotation.Component)2 UiTimelineManager (com.helospark.tactview.ui.javafx.UiTimelineManager)2 DockableTabRepository (com.helospark.tactview.ui.javafx.tabs.dockabletab.DockableTabRepository)2 BufferedImage (java.awt.image.BufferedImage)2 Canvas (javafx.scene.canvas.Canvas)2 VBox (javafx.scene.layout.VBox)2 PostInitializationArgsCallback (com.helospark.tactview.core.init.PostInitializationArgsCallback)1 ProjectRepository (com.helospark.tactview.core.repository.ProjectRepository)1 DirtyRepository (com.helospark.tactview.core.save.DirtyRepository)1 TimelineManagerFramesRequest (com.helospark.tactview.core.timeline.TimelineManagerFramesRequest)1 TimelineManagerRenderService (com.helospark.tactview.core.timeline.TimelineManagerRenderService)1 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)1 EffectParametersRepository (com.helospark.tactview.core.timeline.effect.EffectParametersRepository)1 ValueProviderDescriptor (com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor)1 EffectGraphAccessor (com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraphAccessor)1 GraphProvider (com.helospark.tactview.core.timeline.effect.interpolation.provider.GraphProvider)1 Slf4j (com.helospark.tactview.core.util.logger.Slf4j)1 MessagingService (com.helospark.tactview.core.util.messaging.MessagingService)1