Search in sources :

Example 1 with AttributeFunction

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

Example 2 with AttributeFunction

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

Example 3 with AttributeFunction

use of org.gephi.appearance.api.AttributeFunction 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 4 with AttributeFunction

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

the class AppearanceUIController method setSelectedFunction.

public void setSelectedFunction(Function function) {
    if (graphObserver != null) {
        graphObserver.destroy();
        graphObserver = null;
    }
    if (model != null) {
        Function oldValue = model.getSelectedFunction();
        if ((oldValue == null && function != null) || (oldValue != null && function == null) || (function != null && oldValue != null && !oldValue.equals(function))) {
            model.setAutoApply(false);
            model.setSelectedFunction(function);
            firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_FUNCTION, oldValue, function);
            if (function != null && !function.isSimple()) {
                graphObserver = new GraphChangeObserver(function.getGraph(), function instanceof AttributeFunction ? ((AttributeFunction) function).getColumn() : null);
                graphObserver.start();
            }
        }
    }
}
Also used : Function(org.gephi.appearance.api.Function) AttributeFunction(org.gephi.appearance.api.AttributeFunction) AttributeFunction(org.gephi.appearance.api.AttributeFunction)

Example 5 with AttributeFunction

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

the class AppearanceUIModel method replaceSelectedFunction.

public synchronized Function replaceSelectedFunction() {
    Graph graph = graphController.getGraphModel(appearanceModel.getWorkspace()).getGraph();
    Function sFunction = getSelectedFunction();
    if (sFunction instanceof AttributeFunction) {
        AttributeFunction af = (AttributeFunction) sFunction;
        for (Function func : getSelectedElementClass().equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions(graph) : appearanceModel.getEdgeFunctions(graph)) {
            if (func instanceof AttributeFunction) {
                if (af.getColumn().equals(((AttributeFunction) func).getColumn()) && sFunction.getUI().getCategory().equals(func.getUI().getCategory())) {
                    return func;
                }
            }
        }
    }
    return null;
}
Also used : Function(org.gephi.appearance.api.Function) AttributeFunction(org.gephi.appearance.api.AttributeFunction) Graph(org.gephi.graph.api.Graph) AttributeFunction(org.gephi.appearance.api.AttributeFunction)

Aggregations

AttributeFunction (org.gephi.appearance.api.AttributeFunction)5 Function (org.gephi.appearance.api.Function)5 TransformerCategory (org.gephi.appearance.spi.TransformerCategory)1 TransformerUI (org.gephi.appearance.spi.TransformerUI)1 Graph (org.gephi.graph.api.Graph)1