Search in sources :

Example 1 with GraphNodeInputImpl

use of com.gempukku.libgdx.graph.pipeline.producer.node.GraphNodeInputImpl in project gdx-graph by MarcinSc.

the class UIPipelineConfigurer method processBoxProducer.

private static void processBoxProducer(JsonValue boxProducer) {
    String producerType = boxProducer.name();
    String producerName = boxProducer.getString("name");
    String menuLocation = boxProducer.getString("menuLocation");
    NodeConfigurationImpl nodeConfiguration = new NodeConfigurationImpl(producerType, producerName, menuLocation);
    JsonValue inputs = boxProducer.get("inputs");
    if (inputs != null) {
        for (JsonValue input : inputs) {
            String id = input.getString("id");
            String name = input.getString("name");
            boolean required = input.getBoolean("required", false);
            boolean mainConnection = input.getBoolean("mainConnection", false);
            boolean acceptMultiple = input.getBoolean("acceptMultiple", false);
            JsonValue type = input.get("type");
            String[] types = convertToArrayOfStrings(type);
            GraphNodeInputImpl nodeInput = new GraphNodeInputImpl(id, name, required, mainConnection, acceptMultiple, types);
            nodeConfiguration.addNodeInput(nodeInput);
        }
    }
    JsonValue outputs = boxProducer.get("outputs");
    if (outputs != null) {
        for (JsonValue output : outputs) {
            String id = output.getString("id");
            String name = output.getString("name");
            boolean mainConnection = output.getBoolean("mainConnection", false);
            JsonValue validation = output.get("validation");
            Function<ObjectMap<String, Array<String>>, String> validationFunction = convertToValidationFunction(validation);
            JsonValue type = output.get("type");
            String[] types = convertToArrayOfStrings(type);
            GraphNodeOutputImpl nodeOutput = new GraphNodeOutputImpl(id, name, mainConnection, validationFunction, types);
            nodeConfiguration.addNodeOutput(nodeOutput);
        }
    }
    final JsonValue fields = boxProducer.get("fields");
    GraphBoxProducerImpl producer = new GraphBoxProducerImpl(nodeConfiguration) {

        @Override
        public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
            GraphBoxImpl result = createGraphBox(id);
            if (fields != null) {
                for (JsonValue field : fields) {
                    String fieldType = field.getString("type");
                    GraphBoxPart fieldGraphBoxPart = createFieldGraphBoxPart(fieldType, field);
                    fieldGraphBoxPart.initialize(data);
                    result.addGraphBoxPart(fieldGraphBoxPart);
                }
            }
            addConfigurationInputsAndOutputs(result);
            return result;
        }
    };
    UIPipelineConfiguration.register(producer);
}
Also used : GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) JsonValue(com.badlogic.gdx.utils.JsonValue) GraphBoxProducerImpl(com.gempukku.libgdx.graph.ui.producer.GraphBoxProducerImpl) GraphBoxPart(com.gempukku.libgdx.graph.ui.graph.GraphBoxPart) ObjectMap(com.badlogic.gdx.utils.ObjectMap) NodeConfigurationImpl(com.gempukku.libgdx.graph.data.NodeConfigurationImpl) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) GraphNodeOutputImpl(com.gempukku.libgdx.graph.pipeline.producer.node.GraphNodeOutputImpl) GraphNodeInputImpl(com.gempukku.libgdx.graph.pipeline.producer.node.GraphNodeInputImpl)

Aggregations

Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 ObjectMap (com.badlogic.gdx.utils.ObjectMap)1 NodeConfigurationImpl (com.gempukku.libgdx.graph.data.NodeConfigurationImpl)1 GraphNodeInputImpl (com.gempukku.libgdx.graph.pipeline.producer.node.GraphNodeInputImpl)1 GraphNodeOutputImpl (com.gempukku.libgdx.graph.pipeline.producer.node.GraphNodeOutputImpl)1 GraphBoxImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl)1 GraphBoxPart (com.gempukku.libgdx.graph.ui.graph.GraphBoxPart)1 GraphBoxProducerImpl (com.gempukku.libgdx.graph.ui.producer.GraphBoxProducerImpl)1