use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIController method setSelectedElementClass.
public void setSelectedElementClass(String elementClass) {
if (graphObserver != null) {
graphObserver.destroy();
graphObserver = null;
}
if (!elementClass.equals(NODE_ELEMENT) && !elementClass.equals(EDGE_ELEMENT)) {
throw new RuntimeException("Element class has to be " + NODE_ELEMENT + " or " + EDGE_ELEMENT);
}
if (model != null) {
String oldValue = model.getSelectedElementClass();
if (!oldValue.equals(elementClass)) {
model.setSelectedElementClass(elementClass);
Function function = model.getSelectedFunction();
if (function != null) {
model.refreshSelectedFunction();
if (!function.isSimple()) {
graphObserver = new GraphChangeObserver(function.getGraph(), function instanceof AttributeFunction ? ((AttributeFunction) function).getColumn() : null);
graphObserver.start();
}
}
firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_ELEMENT_CLASS, oldValue, elementClass);
}
}
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIController method setSelectedTransformerUI.
public void setSelectedTransformerUI(TransformerUI ui) {
if (graphObserver != null) {
graphObserver.destroy();
graphObserver = null;
}
if (model != null) {
TransformerUI oldValue = model.getSelectedTransformerUI();
if (!oldValue.equals(ui)) {
model.setAutoApply(false);
model.setSelectedTransformerUI(ui);
Function function = model.getSelectedFunction();
if (function != null) {
model.refreshSelectedFunction();
if (!function.isSimple()) {
graphObserver = new GraphChangeObserver(function.getGraph(), function instanceof AttributeFunction ? ((AttributeFunction) function).getColumn() : null);
graphObserver.start();
}
}
firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_TRANSFORMER_UI, oldValue, ui);
}
}
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIController method setSelectedCategory.
public void setSelectedCategory(TransformerCategory category) {
if (graphObserver != null) {
graphObserver.destroy();
graphObserver = null;
}
if (model != null) {
TransformerCategory oldValue = model.getSelectedCategory();
if (!oldValue.equals(category)) {
model.setSelectedCategory(category);
Function function = model.getSelectedFunction();
if (function != null) {
model.refreshSelectedFunction();
if (!function.isSimple()) {
graphObserver = new GraphChangeObserver(function.getGraph(), function instanceof AttributeFunction ? ((AttributeFunction) function).getColumn() : null);
graphObserver.start();
}
}
firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_CATEGORY, oldValue, category);
}
}
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIModel method saveTransformerProperties.
public void saveTransformerProperties() {
Function func = getSelectedFunction();
if (func != null) {
Transformer transformer = func.getTransformer();
Map<String, Object> props = savedProperties.get(func);
if (props == null) {
props = new HashMap<>();
savedProperties.put(func, new HashMap<String, Object>());
}
for (Map.Entry<String, Method[]> entry : getProperties(transformer).entrySet()) {
String name = entry.getKey();
Method getMethod = entry.getValue()[0];
try {
Object o = getMethod.invoke(transformer);
props.put(name, o);
} catch (Exception ex) {
}
}
}
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIModel method refreshSelectedFunctions.
private void refreshSelectedFunctions(String elementClass) {
Set<Function> functionSet = new HashSet<>();
Graph graph = graphController.getGraphModel(appearanceModel.getWorkspace()).getGraph();
for (Function func : elementClass.equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions(graph) : appearanceModel.getEdgeFunctions(graph)) {
TransformerUI ui = func.getUI();
if (ui != null) {
functionSet.add(func);
}
}
for (Function func : functionSet) {
Function oldFunc = selectedFunction.get(elementClass).get(func.getUI());
if (oldFunc == null || !functionSet.contains(oldFunc)) {
if (func.isSimple()) {
selectedFunction.get(elementClass).put(func.getUI(), func);
}
}
}
}
Aggregations