use of com.helospark.tactview.core.timeline.effect.EffectFactory 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();
}
use of com.helospark.tactview.core.timeline.effect.EffectFactory in project tactview by helospark.
the class EffectFactoryChain method createEffect.
public StatelessEffect createEffect(CreateEffectRequest request) {
EffectFactory factory = findSupportedFactory(request).orElseThrow(() -> new IllegalArgumentException("No factory for " + request));
StatelessEffect result = factory.createEffect(request);
result.setFactoryId(factory.getId());
if (result instanceof LongProcessAware) {
((LongProcessAware) result).setLongProcessRequestor(longProcessRequestor);
}
if (factory.isFullWidth()) {
result.setInterval(new TimelineInterval(TimelinePosition.ofZero(), request.getClipInterval().getLength()));
}
return result;
}
use of com.helospark.tactview.core.timeline.effect.EffectFactory in project tactview by helospark.
the class EffectFactoryChain method restoreEffect.
public StatelessEffect restoreEffect(JsonNode node, LoadMetadata loadMetadata) {
String factoryId = node.get("factoryId").asText();
EffectFactory factory = context.getListOfBeans(EffectFactory.class).stream().filter(effectFactory -> effectFactory.getId().equals(factoryId)).findFirst().orElseThrow(() -> new IllegalArgumentException("No factory for " + factoryId));
StatelessEffect result = factory.restoreEffect(node, loadMetadata);
if (result instanceof LongProcessAware) {
((LongProcessAware) result).setLongProcessRequestor(longProcessRequestor);
}
return result;
}
use of com.helospark.tactview.core.timeline.effect.EffectFactory in project tactview by helospark.
the class AbstractEffectTabFactory method fillFlowPane.
@Override
protected void fillFlowPane(FlowPane effectTabContent, String searchData) {
List<EffectFactory> effects = lightDi.getListOfBeans(EffectFactory.class);
List<ScoredNodeHolder> icons = new ArrayList<>();
effects.stream().filter(factory -> factory.getEffectType().equals(effectType)).sorted((a, b) -> a.getEffectName().compareToIgnoreCase(b.getEffectName())).forEach(factory -> {
Optional<LocalizedDetailDomain> localizedDetail = localizedDetailRepository.queryData(factory.getEffectId());
int score = getScore(localizedDetail, factory.getId(), factory.getEffectName(), searchData);
if (score > 0) {
String iconUri = localizedDetail.flatMap(data -> data.getIconUrl()).orElse(DEFAULT_URI);
Optional<String> description = localizedDetail.map(a -> a.getDescription());
VBox icon = iconFactory.createIcon("effect:" + factory.getEffectId(), factory.getEffectName(), iconUri, description);
icons.add(new ScoredNodeHolder(icon, score));
}
});
effectTabContent.getChildren().clear();
icons.stream().sorted().forEach(entry -> {
effectTabContent.getChildren().add(entry.node);
});
}
use of com.helospark.tactview.core.timeline.effect.EffectFactory in project tactview by helospark.
the class StandardClipContextMenuChainItemConfiguration method scaleToFrameMenuItem.
@Bean
@Order(0)
public ClipContextMenuChainItem scaleToFrameMenuItem(UiCommandInterpreterService commandInterpreter, TimelineManagerAccessor timelineManager, ProjectRepository projectRepository, @Qualifier("scaleEffect") EffectFactory scaleFactory, EffectFactoryChain effectFactoryChain, SelectedNodeRepository selectedNodeRepository) {
return typeSupportingContextMenuItem(VisualTimelineClip.class, request -> {
MenuItem scaleToImageMenuItem = new MenuItem("Scale to frame");
scaleToImageMenuItem.setOnAction(e -> {
List<AddScaleCommand> commands = request.getAllClips().stream().map(a -> a.getId()).map(clipId -> AddScaleCommand.builder().withClipId(clipId).withProjectRepository(projectRepository).withScaleEffectFactory(scaleFactory).withTimelineManager(timelineManager).withEffectFactoryChain(effectFactoryChain).build()).collect(Collectors.toList());
if (commands.size() > 0) {
commandInterpreter.sendWithResult(new CompositeCommand(commands));
}
});
return scaleToImageMenuItem;
});
}
Aggregations