use of com.gempukku.libgdx.graph.ui.graph.GraphBoxPart 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);
}
use of com.gempukku.libgdx.graph.ui.graph.GraphBoxPart in project gdx-graph by MarcinSc.
the class UIPipelineConfigurer method processPropertyType.
private static void processPropertyType(JsonValue propertyType) {
final String typeName = propertyType.name();
final String defaultName = propertyType.getString("defaultName");
PipelinePropertyBoxProducerImpl producer = new PipelinePropertyBoxProducerImpl(defaultName, typeName);
JsonValue fields = propertyType.get("fields");
if (fields != null) {
for (final JsonValue field : fields) {
final String fieldType = field.getString("type");
producer.addPropertyBoxPart(new Supplier<PropertyBoxPart>() {
@Override
public PropertyBoxPart get() {
GraphBoxPart propertyBoxPart = createFieldGraphBoxPart(fieldType, field);
if (propertyBoxPart != null)
return propertyBoxPart;
throw new IllegalArgumentException("Unable to resolve field type: " + fieldType);
}
});
}
}
UIPipelineConfiguration.registerPropertyType(producer);
}
Aggregations