Search in sources :

Example 1 with EffectParametersRepository

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

the class DoubleRangeProviderValueSetterChainItem method handle.

@Override
protected EffectLine handle(DoubleRangeProvider doubleRangeProvider, ValueProviderDescriptor descriptor) {
    PrimitiveEffectLine lowEndProvider = (PrimitiveEffectLine) doublePropertyValueSetterChainItem.create(descriptor, doubleRangeProvider.getLowEnd());
    PrimitiveEffectLine highEndProvider = (PrimitiveEffectLine) doublePropertyValueSetterChainItem.create(descriptor, doubleRangeProvider.getHighEnd());
    RangeSlider rangeSlider = new RangeSlider(doubleRangeProvider.getMin(), doubleRangeProvider.getMax(), doubleRangeProvider.getMin(), doubleRangeProvider.getMax());
    rangeSlider.setShowTickMarks(true);
    rangeSlider.setShowTickLabels(true);
    HBox box = new HBox();
    box.getChildren().add(rangeSlider);
    CompositeEffectLine result = CompositeEffectLine.builder().withVisibleNode(box).withValues(List.of(lowEndProvider, highEndProvider)).withDescriptorId(doubleRangeProvider.getId()).withEffectParametersRepository(effectParametersRepository).withCommandInterpreter(commandInterpreter).withDescriptor(descriptor).withCurrentValueSupplier(() -> new InterpolationLine((Point) lowEndProvider.getCurrentValueSupplier().get(), (Point) highEndProvider.getCurrentValueSupplier().get())).withUpdateFromValue(value -> {
        DoubleRange point = (DoubleRange) value;
        lowEndProvider.getUpdateFromValue().accept(point.lowEnd);
        highEndProvider.getUpdateFromValue().accept(point.highEnd);
    }).withAdditionalUpdateUi(time -> {
        double lowEnd = effectLineToDouble(lowEndProvider);
        double highEnd = effectLineToDouble(highEndProvider);
        System.out.println("Lowhigh: " + lowEnd + " " + highEnd);
        if (!rangeSlider.isFocused()) {
            rangeSlider.setLowValue(lowEnd);
            rangeSlider.setHighValue(highEnd);
        }
    }).build();
    rangeSlider.lowValueProperty().addListener((obj, oldValue, newValue) -> {
        if (!Objects.equals(oldValue, newValue)) {
            KeyframeAddedRequest keyframeRequest = KeyframeAddedRequest.builder().withDescriptorId(doubleRangeProvider.getLowEnd().getId()).withGlobalTimelinePosition(timelineManager.getCurrentPosition()).withValue(newValue).withRevertable(true).build();
            commandInterpreter.sendWithResult(new AddKeyframeForPropertyCommand(effectParametersRepository, keyframeRequest));
        }
    });
    rangeSlider.highValueProperty().addListener((obj, oldValue, newValue) -> {
        if (!Objects.equals(oldValue, newValue)) {
            KeyframeAddedRequest keyframeRequest = KeyframeAddedRequest.builder().withDescriptorId(doubleRangeProvider.getHighEnd().getId()).withGlobalTimelinePosition(timelineManager.getCurrentPosition()).withValue(newValue).withRevertable(true).build();
            commandInterpreter.sendWithResult(new AddKeyframeForPropertyCommand(effectParametersRepository, keyframeRequest));
        }
    });
    contextMenuAppender.addContextMenu(result, doubleRangeProvider, descriptor, rangeSlider);
    return result;
}
Also used : Component(com.helospark.lightdi.annotation.Component) ValueProviderDescriptor(com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor) DoubleRangeProvider(com.helospark.tactview.core.timeline.effect.interpolation.provider.DoubleRangeProvider) HBox(javafx.scene.layout.HBox) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) EffectParametersRepository(com.helospark.tactview.core.timeline.effect.EffectParametersRepository) ContextMenuAppender(com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.contextmenu.ContextMenuAppender) Objects(java.util.Objects) List(java.util.List) RangeSlider(org.controlsfx.control.RangeSlider) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) DoubleRange(com.helospark.tactview.core.timeline.effect.interpolation.pojo.DoubleRange) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) DoubleRange(com.helospark.tactview.core.timeline.effect.interpolation.pojo.DoubleRange) HBox(javafx.scene.layout.HBox) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) RangeSlider(org.controlsfx.control.RangeSlider)

Example 2 with EffectParametersRepository

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

the class FilePropertyValueSetterChainItem method handle.

@Override
protected EffectLine handle(FileProvider fileProvider, ValueProviderDescriptor descriptor) {
    TextField textArea = new TextField();
    FileChooser fileChooser = new FileChooser();
    ExtensionFilter allFilesFilter = new ExtensionFilter("All files", List.of("*"));
    ExtensionFilter supportedFileFilter = new ExtensionFilter(fileProvider.getExtensions().stream().collect(Collectors.joining(", ")), fileProvider.getExtensions().toArray(new String[0]));
    fileChooser.getExtensionFilters().add(allFilesFilter);
    fileChooser.getExtensionFilters().add(supportedFileFilter);
    fileChooser.setSelectedExtensionFilter(supportedFileFilter);
    fileChooser.setTitle("Open Resource File");
    Button browseButton = new Button("Browse");
    HBox hbox = new HBox();
    hbox.getChildren().addAll(textArea, browseButton);
    PrimitiveEffectLine lineItem = PrimitiveEffectLine.builder().withCurrentValueProvider(() -> textArea.getText()).withDescriptorId(fileProvider.getId()).withUpdateFunction(position -> {
        String fileName = providerValueToString(fileProvider.getId(), position);
        textArea.setText(fileName);
        fileChooser.setInitialFileName(fileName);
    }).withVisibleNode(hbox).withCommandInterpreter(commandInterpreter).withEffectParametersRepository(effectParametersRepository).withDescriptor(descriptor).withUpdateFromValue(value -> {
        textArea.setText((String) value);
        fileChooser.setInitialFileName((String) value);
    }).build();
    browseButton.setOnMouseClicked(e -> {
        File file = fileChooser.showOpenDialog(JavaFXUiMain.STAGE);
        if (file != null) {
            KeyframeAddedRequest keyframeRequest = KeyframeAddedRequest.builder().withDescriptorId(fileProvider.getId()).withGlobalTimelinePosition(uiTimelineManager.getCurrentPosition()).withValue(file.getAbsolutePath()).withRevertable(true).build();
            commandInterpreter.sendWithResult(new AddKeyframeForPropertyCommand(effectParametersRepository, keyframeRequest));
        }
    });
    contextMenuAppender.addContextMenu(lineItem, fileProvider, descriptor, hbox);
    return lineItem;
}
Also used : Button(javafx.scene.control.Button) Component(com.helospark.lightdi.annotation.Component) ValueProviderDescriptor(com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor) JavaFXUiMain(com.helospark.tactview.ui.javafx.JavaFXUiMain) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) FileProvider(com.helospark.tactview.core.timeline.effect.interpolation.provider.FileProvider) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) EffectParametersRepository(com.helospark.tactview.core.timeline.effect.EffectParametersRepository) Collectors(java.util.stream.Collectors) ContextMenuAppender(com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.contextmenu.ContextMenuAppender) File(java.io.File) FileChooser(javafx.stage.FileChooser) List(java.util.List) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) HBox(javafx.scene.layout.HBox) Button(javafx.scene.control.Button) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) FileChooser(javafx.stage.FileChooser) TextField(javafx.scene.control.TextField) File(java.io.File) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand)

Example 3 with EffectParametersRepository

use of com.helospark.tactview.core.timeline.effect.EffectParametersRepository 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)

Example 4 with EffectParametersRepository

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

the class BezierPolygonSetterChainItem method handle.

@Override
protected EffectLine handle(BezierPolygonProvider polygonProvider, ValueProviderDescriptor descriptor) {
    Button button = new Button("", new Glyph("FontAwesome", FontAwesome.Glyph.DIAMOND));
    PrimitiveEffectLine result = PrimitiveEffectLine.builder().withCurrentValueProvider(() -> effectParametersRepository.getValueAtAsObject(polygonProvider.getId(), uiTimelineManager.getCurrentPosition())).withVisibleNode(button).withDescriptorId(polygonProvider.getId()).withEffectParametersRepository(effectParametersRepository).withCommandInterpreter(commandInterpreter).withDescriptor(descriptor).withUpdateFunction(position -> {
    // TODO
    }).withUpdateFromValue(value -> {
    // TODO
    }).build();
    button.setOnMouseClicked(event -> {
        if (event.getButton() == MouseButton.PRIMARY) {
            BezierPolygon currentPolygon = (BezierPolygon) effectParametersRepository.getValueAtAsObject(polygonProvider.getId(), uiTimelineManager.getCurrentPosition());
            if (currentPolygon.getPoints().isEmpty()) {
                inputModeRepository.requestBezierPolygon(polygon -> {
                    boolean revertable = this.inputModeRepository.getResultType().equals(ResultType.DONE);
                    KeyframeAddedRequest keyframeRequest = KeyframeAddedRequest.builder().withDescriptorId(polygonProvider.getId()).withGlobalTimelinePosition(uiTimelineManager.getCurrentPosition()).withValue(polygon).withRevertable(revertable).withPreviousValue(Optional.of(currentPolygon)).build();
                    commandInterpreter.sendWithResult(new AddKeyframeForPropertyCommand(effectParametersRepository, keyframeRequest));
                }, polygonProvider.getSizeFunction());
            } else {
                inputModeRepository.requestBezierPolygonPrefilled(polygon -> {
                    KeyframeAddedRequest keyframeRequest = KeyframeAddedRequest.builder().withDescriptorId(polygonProvider.getId()).withGlobalTimelinePosition(uiTimelineManager.getCurrentPosition()).withValue(polygon).withRevertable(true).build();
                    commandInterpreter.sendWithResult(new AddKeyframeForPropertyCommand(effectParametersRepository, keyframeRequest));
                }, polygonProvider.getSizeFunction(), currentPolygon.getPoints());
            }
        }
    });
    return result;
}
Also used : Button(javafx.scene.control.Button) Component(com.helospark.lightdi.annotation.Component) ValueProviderDescriptor(com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor) MouseButton(javafx.scene.input.MouseButton) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) EffectParametersRepository(com.helospark.tactview.core.timeline.effect.EffectParametersRepository) Glyph(org.controlsfx.glyphfont.Glyph) BezierPolygonProvider(com.helospark.tactview.core.timeline.effect.interpolation.provider.BezierPolygonProvider) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) InputModeRepository(com.helospark.tactview.ui.javafx.inputmode.InputModeRepository) ResultType(com.helospark.tactview.ui.javafx.inputmode.strategy.ResultType) Optional(java.util.Optional) FontAwesome(org.controlsfx.glyphfont.FontAwesome) BezierPolygon(com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.bezier.BezierPolygon) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) Button(javafx.scene.control.Button) MouseButton(javafx.scene.input.MouseButton) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) Glyph(org.controlsfx.glyphfont.Glyph) BezierPolygon(com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.bezier.BezierPolygon) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand)

Example 5 with EffectParametersRepository

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

the class RectangleProviderValueSetterChainItem method handle.

@Override
protected EffectLine handle(RectangleProvider rectangleProvider, ValueProviderDescriptor descriptor) {
    List<EffectLine> pointProviders = new ArrayList<>();
    for (int i = 0; i < 4; ++i) {
        pointProviders.add(pointProviderValueSetterChainItem.create(descriptor, rectangleProvider.getChildren().get(i)));
    }
    Button button = new Button("", new Glyph("FontAwesome", FontAwesome.Glyph.SQUARE));
    VBox vbox = new VBox();
    pointProviders.stream().forEach(a -> vbox.getChildren().add(a.visibleNode));
    HBox hbox = new HBox();
    hbox.getChildren().add(vbox);
    hbox.getChildren().add(button);
    CompositeEffectLine result = CompositeEffectLine.builder().withVisibleNode(hbox).withValues(pointProviders).withDescriptorId(rectangleProvider.getId()).withEffectParametersRepository(effectParametersRepository).withCommandInterpreter(commandInterpreter).withDescriptor(descriptor).withUpdateFromValue(value -> {
        Rectangle line = (Rectangle) value;
        for (int i = 0; i < 4; ++i) {
            pointProviders.get(i).getUpdateFromValue().accept(line.points.get(i));
        }
    }).build();
    button.setOnMouseClicked(event -> {
        if (event.getButton() == MouseButton.PRIMARY) {
            Rectangle previousValue = rectangleProvider.getValueAt(uiTimelineManager.getCurrentPosition());
            inputModeRepository.requestRectangle(rectangle -> {
                boolean revertable = this.inputModeRepository.getResultType().equals(ResultType.DONE);
                KeyframeAddedRequest keyframeRequest = KeyframeAddedRequest.builder().withDescriptorId(rectangleProvider.getId()).withGlobalTimelinePosition(uiTimelineManager.getCurrentPosition()).withValue(rectangle).withPreviousValue(Optional.ofNullable(previousValue)).withRevertable(revertable).build();
                commandInterpreter.sendWithResult(new AddKeyframeForPropertyCommand(effectParametersRepository, keyframeRequest));
            }, getCurrentValue(pointProviders), rectangleProvider.getSizeFunction());
        }
    });
    contextMenuAppender.addContextMenu(result, rectangleProvider, descriptor, button);
    return result;
}
Also used : Button(javafx.scene.control.Button) Component(com.helospark.lightdi.annotation.Component) ValueProviderDescriptor(com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor) HBox(javafx.scene.layout.HBox) MouseButton(javafx.scene.input.MouseButton) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) RectangleProvider(com.helospark.tactview.core.timeline.effect.interpolation.provider.RectangleProvider) EffectParametersRepository(com.helospark.tactview.core.timeline.effect.EffectParametersRepository) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) ContextMenuAppender(com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.contextmenu.ContextMenuAppender) Rectangle(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Rectangle) ArrayList(java.util.ArrayList) List(java.util.List) Glyph(org.controlsfx.glyphfont.Glyph) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) InputModeRepository(com.helospark.tactview.ui.javafx.inputmode.InputModeRepository) ResultType(com.helospark.tactview.ui.javafx.inputmode.strategy.ResultType) Optional(java.util.Optional) FontAwesome(org.controlsfx.glyphfont.FontAwesome) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) HBox(javafx.scene.layout.HBox) KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) ArrayList(java.util.ArrayList) Rectangle(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Rectangle) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) Button(javafx.scene.control.Button) MouseButton(javafx.scene.input.MouseButton) Glyph(org.controlsfx.glyphfont.Glyph) VBox(javafx.scene.layout.VBox)

Aggregations

Component (com.helospark.lightdi.annotation.Component)18 EffectParametersRepository (com.helospark.tactview.core.timeline.effect.EffectParametersRepository)18 UiCommandInterpreterService (com.helospark.tactview.ui.javafx.UiCommandInterpreterService)18 ValueProviderDescriptor (com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor)14 UiTimelineManager (com.helospark.tactview.ui.javafx.UiTimelineManager)14 KeyframeAddedRequest (com.helospark.tactview.core.timeline.message.KeyframeAddedRequest)13 AddKeyframeForPropertyCommand (com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand)13 ContextMenuAppender (com.helospark.tactview.ui.javafx.uicomponents.propertyvalue.contextmenu.ContextMenuAppender)11 List (java.util.List)9 HBox (javafx.scene.layout.HBox)8 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)7 Optional (java.util.Optional)6 Collectors (java.util.stream.Collectors)6 Button (javafx.scene.control.Button)6 MouseButton (javafx.scene.input.MouseButton)6 InputModeRepository (com.helospark.tactview.ui.javafx.inputmode.InputModeRepository)5 Order (com.helospark.lightdi.annotation.Order)4 ResultType (com.helospark.tactview.ui.javafx.inputmode.strategy.ResultType)4 Objects (java.util.Objects)4 Menu (javafx.scene.control.Menu)4