use of com.gempukku.libgdx.graph.data.NodeGroup in project gdx-graph by MarcinSc.
the class GraphDesignTab method serializeGraph.
public JsonValue serializeGraph() {
JsonValue graph = new JsonValue(JsonValue.ValueType.object);
graph.addChild("version", new JsonValue(GraphLoader.VERSION));
graph.addChild("type", new JsonValue(type.getType()));
JsonValue objects = new JsonValue(JsonValue.ValueType.array);
for (JsonValue jsonValue : getSortedNodesAsJson()) {
objects.addChild(jsonValue);
}
graph.addChild("nodes", objects);
List<JsonValue> connectionJsonValues = getSortedConnectionsAsJson();
JsonValue connections = new JsonValue(JsonValue.ValueType.array);
for (JsonValue connection : connectionJsonValues) {
connections.addChild(connection);
}
graph.addChild("connections", connections);
JsonValue properties = new JsonValue(JsonValue.ValueType.array);
for (PropertyBox propertyBox : propertyBoxes) {
JsonValue property = new JsonValue(JsonValue.ValueType.object);
property.addChild("name", new JsonValue(propertyBox.getName()));
property.addChild("type", new JsonValue(propertyBox.getType()));
PropertyLocation location = propertyBox.getLocation();
if (location != null)
property.addChild("location", new JsonValue(location.name()));
JsonValue data = propertyBox.getData();
if (data != null)
property.addChild("data", data);
properties.addChild(property);
}
graph.addChild("properties", properties);
JsonValue groups = new JsonValue(JsonValue.ValueType.array);
for (NodeGroup nodeGroup : graphContainer.getNodeGroups()) {
JsonValue group = new JsonValue(JsonValue.ValueType.object);
group.addChild("name", new JsonValue(nodeGroup.getName()));
JsonValue nodes = new JsonValue(JsonValue.ValueType.array);
for (String nodeId : nodeGroup.getNodeIds()) {
nodes.addChild(new JsonValue(nodeId));
}
group.addChild("nodes", nodes);
groups.addChild(group);
}
graph.addChild("groups", groups);
return graph;
}
Aggregations