Search in sources :

Example 11 with Function

use of org.gephi.appearance.api.Function in project gephi by gephi.

the class AppearanceUIModel method refreshSelectedFunction.

public synchronized boolean refreshSelectedFunction() {
    Graph graph = graphController.getGraphModel(appearanceModel.getWorkspace()).getGraph();
    Function sFunction = getSelectedFunction();
    if (sFunction != null && sFunction.isAttribute()) {
        for (Function func : getSelectedElementClass().equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions(graph) : appearanceModel.getEdgeFunctions(graph)) {
            if (func.equals(sFunction)) {
                return false;
            }
        }
    }
    return true;
}
Also used : Function(org.gephi.appearance.api.Function) AttributeFunction(org.gephi.appearance.api.AttributeFunction) Graph(org.gephi.graph.api.Graph)

Example 12 with Function

use of org.gephi.appearance.api.Function in project gephi by gephi.

the class AppearanceUIModel method loadTransformerProperties.

public void loadTransformerProperties() {
    Function func = getSelectedFunction();
    if (func != null) {
        Transformer transformer = func.getTransformer();
        Map<String, Object> props = savedProperties.get(func);
        if (props != null) {
            for (Map.Entry<String, Method[]> entry : getProperties(transformer).entrySet()) {
                String name = entry.getKey();
                Object o = props.get(name);
                if (o != null) {
                    Method setMethod = entry.getValue()[1];
                    try {
                        setMethod.invoke(transformer, o);
                    } catch (Exception ex) {
                    }
                }
            }
        }
    }
}
Also used : Function(org.gephi.appearance.api.Function) AttributeFunction(org.gephi.appearance.api.AttributeFunction) Transformer(org.gephi.appearance.spi.Transformer) PartitionTransformer(org.gephi.appearance.spi.PartitionTransformer) RankingTransformer(org.gephi.appearance.spi.RankingTransformer) Method(java.lang.reflect.Method) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with Function

use of org.gephi.appearance.api.Function in project gephi by gephi.

the class AppearanceUIModel method initSelectedTransformerUIs.

private void initSelectedTransformerUIs(String elementClass) {
    Graph graph = graphController.getGraphModel(appearanceModel.getWorkspace()).getGraph();
    Map<TransformerCategory, TransformerUI> newMap = new HashMap<>();
    for (Function func : elementClass.equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions(graph) : appearanceModel.getEdgeFunctions(graph)) {
        TransformerUI ui = func.getUI();
        if (ui != null) {
            TransformerCategory cat = ui.getCategory();
            if (!newMap.containsKey(cat)) {
                newMap.put(cat, ui);
            }
            if (!selectedCategory.containsKey(elementClass)) {
                selectedCategory.put(elementClass, cat);
            }
        }
    }
    //Prefer color to start
    if (newMap.containsKey(DefaultCategory.COLOR)) {
        selectedCategory.put(elementClass, DefaultCategory.COLOR);
    }
    selectedTransformerUI.put(elementClass, newMap);
    selectedFunction.put(elementClass, new HashMap<TransformerUI, Function>());
    selectedAutoTransformer.put(elementClass, new HashMap<TransformerCategory, AutoAppyTransformer>());
}
Also used : Function(org.gephi.appearance.api.Function) AttributeFunction(org.gephi.appearance.api.AttributeFunction) Graph(org.gephi.graph.api.Graph) TransformerCategory(org.gephi.appearance.spi.TransformerCategory) HashMap(java.util.HashMap) TransformerUI(org.gephi.appearance.spi.TransformerUI)

Aggregations

Function (org.gephi.appearance.api.Function)13 AttributeFunction (org.gephi.appearance.api.AttributeFunction)12 Graph (org.gephi.graph.api.Graph)6 TransformerUI (org.gephi.appearance.spi.TransformerUI)5 HashMap (java.util.HashMap)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 PartitionTransformer (org.gephi.appearance.spi.PartitionTransformer)2 RankingTransformer (org.gephi.appearance.spi.RankingTransformer)2 Transformer (org.gephi.appearance.spi.Transformer)2 TransformerCategory (org.gephi.appearance.spi.TransformerCategory)2 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 List (java.util.List)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 RankingFunction (org.gephi.appearance.api.RankingFunction)1 Test (org.testng.annotations.Test)1