Search in sources :

Example 1 with TransformerCategory

use of org.gephi.appearance.spi.TransformerCategory 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);
        }
    }
}
Also used : Function(org.gephi.appearance.api.Function) AttributeFunction(org.gephi.appearance.api.AttributeFunction) TransformerCategory(org.gephi.appearance.spi.TransformerCategory) AttributeFunction(org.gephi.appearance.api.AttributeFunction)

Example 2 with TransformerCategory

use of org.gephi.appearance.spi.TransformerCategory in project gephi by gephi.

the class AppearanceUIModel method getAutoAppyTransformer.

public AutoAppyTransformer getAutoAppyTransformer() {
    String elm = getSelectedElementClass();
    TransformerCategory ct = getSelectedCategory();
    if (ct != null) {
        return selectedAutoTransformer.get(elm).get(ct);
    }
    return null;
}
Also used : TransformerCategory(org.gephi.appearance.spi.TransformerCategory)

Example 3 with TransformerCategory

use of org.gephi.appearance.spi.TransformerCategory in project gephi by gephi.

the class AppearanceUIModel method setAutoApply.

protected void setAutoApply(boolean autoApply) {
    if (!autoApply) {
        AutoAppyTransformer aat = getAutoAppyTransformer();
        if (aat != null) {
            aat.stop();
        }
    }
    String elmt = getSelectedElementClass();
    TransformerCategory cat = getSelectedCategory();
    if (autoApply) {
        selectedAutoTransformer.get(elmt).put(cat, new AutoAppyTransformer(controller, getSelectedFunction()));
    } else {
        selectedAutoTransformer.get(elmt).put(cat, null);
    }
}
Also used : TransformerCategory(org.gephi.appearance.spi.TransformerCategory)

Example 4 with TransformerCategory

use of org.gephi.appearance.spi.TransformerCategory 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

TransformerCategory (org.gephi.appearance.spi.TransformerCategory)4 AttributeFunction (org.gephi.appearance.api.AttributeFunction)2 Function (org.gephi.appearance.api.Function)2 HashMap (java.util.HashMap)1 TransformerUI (org.gephi.appearance.spi.TransformerUI)1 Graph (org.gephi.graph.api.Graph)1