use of com.gempukku.libgdx.graph.ui.graph.property.PropertyBox in project gdx-graph by MarcinSc.
the class GraphDesignTab method createPropertyPopupMenu.
private PopupMenu createPropertyPopupMenu(float x, float y) {
PopupMenu menu = new PopupMenu();
for (UIGraphConfiguration uiGraphConfiguration : uiGraphConfigurations) {
for (Map.Entry<String, PropertyBoxProducer> propertyEntry : uiGraphConfiguration.getPropertyBoxProducers().entrySet()) {
final String name = propertyEntry.getKey();
final PropertyBoxProducer value = propertyEntry.getValue();
MenuItem valueMenuItem = new MenuItem(name);
valueMenuItem.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
PropertyBox defaultPropertyBox = value.createDefaultPropertyBox(skin, type.getPropertyLocations());
addPropertyBox(name, defaultPropertyBox);
}
});
menu.addItem(valueMenuItem);
}
}
return menu;
}
use of com.gempukku.libgdx.graph.ui.graph.property.PropertyBox 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;
}
use of com.gempukku.libgdx.graph.ui.graph.property.PropertyBox in project gdx-graph by MarcinSc.
the class GraphDesignTab method createGraphPopupMenu.
private PopupMenu createGraphPopupMenu(final float popupX, final float popupY) {
PopupMenu popupMenu = new PopupMenu();
for (UIGraphConfiguration uiGraphConfiguration : uiGraphConfigurations) {
boolean hasChild = false;
for (final GraphBoxProducer producer : uiGraphConfiguration.getGraphBoxProducers()) {
String menuLocation = producer.getMenuLocation();
if (menuLocation != null) {
String[] menuSplit = menuLocation.split("/");
PopupMenu targetMenu = findOrCreatePopupMenu(popupMenu, menuSplit, 0);
final String title = producer.getName();
MenuItem valueMenuItem = new MenuItem(title);
valueMenuItem.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
String id = UUID.randomUUID().toString().replace("-", "");
GraphBox graphBox = producer.createDefault(skin, id);
graphContainer.addGraphBox(graphBox, title, true, popupX, popupY);
}
});
targetMenu.addItem(valueMenuItem);
hasChild = true;
}
}
if (hasChild)
popupMenu.addSeparator();
}
MenuItem propertyMenuItem = new MenuItem("Property");
propertyMenuItem.setDisabled(true);
popupMenu.addItem(propertyMenuItem);
if (!propertyBoxes.isEmpty()) {
PopupMenu propertyMenu = new PopupMenu();
for (final PropertyBox propertyProducer : propertyBoxes) {
final String name = propertyProducer.getName();
MenuItem valueMenuItem = new MenuItem(name);
valueMenuItem.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
String id = UUID.randomUUID().toString().replace("-", "");
GraphBox graphBox = propertyProducer.createPropertyBox(skin, id, popupX, popupY);
graphContainer.addGraphBox(graphBox, "Property", true, popupX, popupY);
}
});
propertyMenu.addItem(valueMenuItem);
}
propertyMenuItem.setSubMenu(propertyMenu);
propertyMenuItem.setDisabled(false);
}
return popupMenu;
}
use of com.gempukku.libgdx.graph.ui.graph.property.PropertyBox in project gdx-graph by MarcinSc.
the class UIGraphLoaderCallback method addPipelineProperty.
@Override
public void addPipelineProperty(String type, String name, PropertyLocation location, JsonValue data) {
PropertyBoxProducer producer = findPropertyProducerByType(type);
if (producer == null)
throw new IllegalArgumentException("Unable to find property producer for type: " + type);
PropertyBox propertyBox = producer.createPropertyBox(skin, name, location, data, propertyLocations);
graphDesignTab.addPropertyBox(type, propertyBox);
}
Aggregations