Search in sources :

Example 6 with GraphConnection

use of com.gempukku.libgdx.graph.data.GraphConnection in project gdx-graph by MarcinSc.

the class GraphDesignTab method getSortedConnectionsAsJson.

private List<JsonValue> getSortedConnectionsAsJson() {
    List<JsonValue> connectionJsonValues = new ArrayList<>();
    for (GraphConnection connection : graphContainer.getConnections()) {
        JsonValue conn = new JsonValue(JsonValue.ValueType.object);
        conn.addChild("fromNode", new JsonValue(connection.getNodeFrom()));
        conn.addChild("fromField", new JsonValue(connection.getFieldFrom()));
        conn.addChild("toNode", new JsonValue(connection.getNodeTo()));
        conn.addChild("toField", new JsonValue(connection.getFieldTo()));
        connectionJsonValues.add(conn);
    }
    // Sort the connections
    Collections.sort(connectionJsonValues, new Comparator<JsonValue>() {

        @Override
        public int compare(JsonValue o1, JsonValue o2) {
            String s1 = getNodeString(o1);
            String s2 = getNodeString(o2);
            return s1.compareTo(s2);
        }

        private String getNodeString(JsonValue node) {
            return node.getString("fromNode") + "." + node.getString("fromField") + "." + node.getString("toNode") + "." + node.getString("toField");
        }
    });
    return connectionJsonValues;
}
Also used : GraphConnection(com.gempukku.libgdx.graph.data.GraphConnection) JsonValue(com.badlogic.gdx.utils.JsonValue)

Example 7 with GraphConnection

use of com.gempukku.libgdx.graph.data.GraphConnection in project gdx-graph by MarcinSc.

the class EndScreenShaderBoxProducer method createPipelineGraphBox.

@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
    final ScreenShaderPreviewBoxPart previewBoxPart = new ScreenShaderPreviewBoxPart();
    previewBoxPart.initialize(data);
    GraphBoxImpl result = new GraphBoxImpl(id, getConfiguration()) {

        @Override
        public void graphChanged(GraphChangedEvent event, boolean hasErrors, Graph<? extends GraphNode, ? extends GraphConnection, ? extends GraphProperty> graph) {
            if (event.isData() || event.isStructure()) {
                previewBoxPart.graphChanged(hasErrors, graph);
            }
        }
    };
    addConfigurationInputsAndOutputs(result);
    result.addGraphBoxPart(new SectionBoxPart("Rendering config"));
    BlendingBoxPart blendingBox = new BlendingBoxPart();
    blendingBox.initialize(data);
    result.addGraphBoxPart(blendingBox);
    result.addGraphBoxPart(new SectionBoxPart("Preview"));
    result.addGraphBoxPart(previewBoxPart);
    return result;
}
Also used : GraphProperty(com.gempukku.libgdx.graph.data.GraphProperty) GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) Graph(com.gempukku.libgdx.graph.data.Graph) GraphChangedEvent(com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent) ScreenShaderPreviewBoxPart(com.gempukku.libgdx.graph.plugin.screen.design.ScreenShaderPreviewBoxPart) GraphConnection(com.gempukku.libgdx.graph.data.GraphConnection) BlendingBoxPart(com.gempukku.libgdx.graph.ui.part.BlendingBoxPart) SectionBoxPart(com.gempukku.libgdx.graph.ui.part.SectionBoxPart) GraphNode(com.gempukku.libgdx.graph.data.GraphNode)

Aggregations

GraphConnection (com.gempukku.libgdx.graph.data.GraphConnection)7 Graph (com.gempukku.libgdx.graph.data.Graph)4 GraphNode (com.gempukku.libgdx.graph.data.GraphNode)4 GraphProperty (com.gempukku.libgdx.graph.data.GraphProperty)4 GraphBoxImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl)4 GraphChangedEvent (com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent)4 JsonValue (com.badlogic.gdx.utils.JsonValue)1 ModelShaderPreviewBoxPart (com.gempukku.libgdx.graph.plugin.models.design.producer.ModelShaderPreviewBoxPart)1 ScreenShaderPreviewBoxPart (com.gempukku.libgdx.graph.plugin.screen.design.ScreenShaderPreviewBoxPart)1 BlendingBoxPart (com.gempukku.libgdx.graph.ui.part.BlendingBoxPart)1 CheckboxBoxPart (com.gempukku.libgdx.graph.ui.part.CheckboxBoxPart)1 EnumSelectBoxPart (com.gempukku.libgdx.graph.ui.part.EnumSelectBoxPart)1 SectionBoxPart (com.gempukku.libgdx.graph.ui.part.SectionBoxPart)1 SelectBoxPart (com.gempukku.libgdx.graph.ui.part.SelectBoxPart)1 GraphBoxProducer (com.gempukku.libgdx.graph.ui.producer.GraphBoxProducer)1 Validators (com.kotcrab.vis.ui.util.Validators)1