use of com.helospark.tactview.core.timeline.ClipFactory in project tactview by helospark.
the class StandardGraphElementFactoryConfiguration method fileClipGraphElementFactory.
@Bean
public GraphElementFactory fileClipGraphElementFactory(List<ClipFactory> clipFactories, ClipFactoryChain clipFactoryChain, MessagingService messagingService) {
return StandardGraphElementFactory.builder().withId("file").withDoesSupport(uri -> uri.startsWith("file://")).withName("File").withCategory(GraphCategory.INPUT).withNeedsInputParam(true).withCreator(graphRequest -> {
AddClipRequest request = AddClipRequest.builder().withAddClipRequestMetadataKey(Map.of()).withPosition(TimelinePosition.ofZero()).withFilePath(graphRequest.uri.replaceFirst("file://", "")).build();
VisualTimelineClip clip = (VisualTimelineClip) clipFactoryChain.createClips(request).get(0);
clip.setInterval(INTERVAL);
messagingService.sendAsyncMessage(new ClipDescriptorsAdded(clip.getId(), clip.getDescriptors(), clip));
return new VisualTimelineClipElement(clip);
}).withRestorer((node, metadata) -> {
node.get("creatorFactoryId").asText();
return new VisualTimelineClipElement(node, metadata, (VisualTimelineClip) clipFactoryChain.restoreClip(node.get("clip"), metadata));
}).build();
}
Aggregations