Search in sources :

Example 1 with EffectGraph

use of com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph in project tactview by helospark.

the class GraphProceduralClip method createProceduralFrame.

@Override
public ReadOnlyClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
    EffectGraph effectGraph = graphProvider.getValueAt(relativePosition);
    EffectGraphInputRequest egr = EffectGraphInputRequest.builder().withApplyEffects(true).withExpectedWidth(request.getExpectedWidth()).withExpectedHeight(request.getExpectedHeight()).withInput(null).withLowResolutionPreview(false).withPosition(request.getGlobalPosition()).withRelativePosition(relativePosition).withScale(request.getScale()).withUseApproximatePosition(false).build();
    return effectGraph.evaluate(egr);
}
Also used : EffectGraph(com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph) EffectGraphInputRequest(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.EffectGraphInputRequest)

Example 2 with EffectGraph

use of com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph in project tactview by helospark.

the class GraphProviderFactory method deserialize.

@Override
public GraphProvider deserialize(JsonNode data, SavedContentAddable<?> currentFieldValue, LoadMetadata loadMetadata) {
    ObjectMapper mapper = loadMetadata.getObjectMapperUsed();
    Map<ConnectionIndex, List<ConnectionIndex>> connections = mapper.convertValue(data.get("connections"), new TypeReference<Map<ConnectionIndex, List<ConnectionIndex>>>() {
    });
    List<GraphElementFactory> factories = loadMetadata.getLightDiContext().getListOfBeans(GraphElementFactory.class);
    Map<GraphIndex, GraphElement> graph = new LinkedHashMap<>();
    for (var element : data.get("graph")) {
        String factoryId = element.get("factoryId").asText();
        GraphElement restoredElement = factories.stream().filter(a -> a.getId().equals(factoryId)).findFirst().get().restoreElement(element.get("object"), loadMetadata);
        GraphIndex id = new GraphIndex(element.get("id").asText());
        graph.put(id, restoredElement);
    }
    return new GraphProvider(new EffectGraph(graph, connections));
}
Also used : EffectGraph(com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph) GraphElement(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElement) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ArrayList(java.util.ArrayList) DesSerFactory(com.helospark.tactview.core.util.DesSerFactory) LinkedHashMap(java.util.LinkedHashMap) ConnectionIndex(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.ConnectionIndex) List(java.util.List) GraphIndex(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.GraphIndex) GraphElementFactory(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElementFactory) Map(java.util.Map) SaveMetadata(com.helospark.tactview.core.save.SaveMetadata) JsonNode(com.fasterxml.jackson.databind.JsonNode) LoadMetadata(com.helospark.tactview.core.save.LoadMetadata) TypeReference(com.fasterxml.jackson.core.type.TypeReference) SavedContentAddable(com.helospark.tactview.core.util.SavedContentAddable) EffectGraph(com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph) GraphElementFactory(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElementFactory) ConnectionIndex(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.ConnectionIndex) LinkedHashMap(java.util.LinkedHashMap) GraphIndex(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.GraphIndex) GraphElement(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElement) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with EffectGraph

use of com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph in project tactview by helospark.

the class GraphProceduralClip method getDescriptorsInternal.

@Override
public List<ValueProviderDescriptor> getDescriptorsInternal() {
    List<ValueProviderDescriptor> result = super.getDescriptorsInternal();
    // if is there to distinguish between load and new init
    if (graphProvider == null) {
        EffectGraph effectGraph = defaultGraphArrangementFactory.createEffectGraphProviderWithOutput();
        graphProvider = new GraphProvider(effectGraph);
    }
    graphProvider.setContainingIntervalAware(this);
    graphProvider.setContainingElementId(this.getId());
    // TODO: this is not a pretty solution, but current arch does not provider better, must think of different way
    effectGraphAccessor.sendProviderMessageFor(graphProvider);
    ValueProviderDescriptor graphDescriptor = ValueProviderDescriptor.builder().withKeyframeableEffect(graphProvider).withName("Graph").build();
    result.add(graphDescriptor);
    return result;
}
Also used : ValueProviderDescriptor(com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor) EffectGraph(com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph) GraphProvider(com.helospark.tactview.core.timeline.effect.interpolation.provider.GraphProvider)

Example 4 with EffectGraph

use of com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph in project tactview by helospark.

the class DefaultGraphArrangementFactory method createEffectGraphProviderWithOutput.

public EffectGraph createEffectGraphProviderWithOutput() {
    EffectGraph effectGraph = new EffectGraph();
    OutputElement outputElement = (OutputElement) outputElementFactory.createElement(new GraphCreatorRequest(null, "output"));
    effectGraph.getGraphElements().put(GraphIndex.random(), outputElement);
    effectGraph.autoArrangeUi();
    return effectGraph;
}
Also used : EffectGraph(com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph) OutputElement(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.OutputElement) GraphCreatorRequest(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElementFactory.GraphCreatorRequest)

Example 5 with EffectGraph

use of com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph in project tactview by helospark.

the class DefaultGraphArrangementFactory method createEffectGraphProviderWithInputAndOutput.

public EffectGraph createEffectGraphProviderWithInputAndOutput() {
    EffectGraph effectGraph = new EffectGraph();
    InputElement inputElement = (InputElement) inputElementFactory.createElement(new GraphCreatorRequest(null, "input"));
    OutputElement outputElement = (OutputElement) outputElementFactory.createElement(new GraphCreatorRequest(null, "output"));
    effectGraph.getGraphElements().put(GraphIndex.random(), inputElement);
    effectGraph.getGraphElements().put(GraphIndex.random(), outputElement);
    effectGraph.getConnections().put(inputElement.getOutputIndex(), new ArrayList<>(List.of(outputElement.getInputIndex())));
    effectGraph.autoArrangeUi();
    return effectGraph;
}
Also used : EffectGraph(com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph) OutputElement(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.OutputElement) InputElement(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.InputElement) GraphCreatorRequest(com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElementFactory.GraphCreatorRequest)

Aggregations

EffectGraph (com.helospark.tactview.core.timeline.effect.interpolation.graph.EffectGraph)8 EffectGraphInputRequest (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.EffectGraphInputRequest)2 GraphCreatorRequest (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElementFactory.GraphCreatorRequest)2 OutputElement (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.OutputElement)2 GraphProvider (com.helospark.tactview.core.timeline.effect.interpolation.provider.GraphProvider)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 LoadMetadata (com.helospark.tactview.core.save.LoadMetadata)1 SaveMetadata (com.helospark.tactview.core.save.SaveMetadata)1 ValueProviderDescriptor (com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor)1 ConnectionIndex (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.ConnectionIndex)1 GraphIndex (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.GraphIndex)1 GraphElement (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElement)1 GraphElementFactory (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.GraphElementFactory)1 InputElement (com.helospark.tactview.core.timeline.effect.interpolation.graph.domain.types.InputElement)1 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)1 DesSerFactory (com.helospark.tactview.core.util.DesSerFactory)1 SavedContentAddable (com.helospark.tactview.core.util.SavedContentAddable)1 ArrayList (java.util.ArrayList)1