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;
}
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;
}
Aggregations