Search in sources :

Example 1 with Transformer

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

the class AppearanceControllerImpl method getTransformer.

@Override
public Transformer getTransformer(TransformerUI ui) {
    Class<? extends Transformer> transformerClass = ui.getTransformerClass();
    Transformer transformer = Lookup.getDefault().lookup(transformerClass);
    if (transformer != null) {
        return transformer;
    }
    return null;
}
Also used : Transformer(org.gephi.appearance.spi.Transformer)

Example 2 with Transformer

use of org.gephi.appearance.spi.Transformer 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) {
            }
        }
    }
}
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 3 with Transformer

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

Aggregations

Transformer (org.gephi.appearance.spi.Transformer)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AttributeFunction (org.gephi.appearance.api.AttributeFunction)2 Function (org.gephi.appearance.api.Function)2 PartitionTransformer (org.gephi.appearance.spi.PartitionTransformer)2 RankingTransformer (org.gephi.appearance.spi.RankingTransformer)2