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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations