Search in sources :

Example 1 with FilterBuilder

use of org.gephi.filters.spi.FilterBuilder in project gephi by gephi.

the class CategoryChildFactory method createKeys.

@Override
protected boolean createKeys(List<Object> toPopulate) {
    Object[] children = utils.getChildren(category);
    Arrays.sort(children, new Comparator() {

        @Override
        public int compare(Object o1, Object o2) {
            String s1;
            String s2;
            if (o1 == FiltersExplorer.QUERIES || o2 == FiltersExplorer.QUERIES) {
                return o1 == FiltersExplorer.QUERIES ? 1 : -1;
            } else if (o1 instanceof Category && o2 instanceof Category) {
                s1 = ((Category) o1).getName();
                s2 = ((Category) o2).getName();
                return s1.compareTo(s2);
            } else if (o1 instanceof FilterBuilder && o2 instanceof FilterBuilder) {
                s1 = ((FilterBuilder) o1).getName();
                s2 = ((FilterBuilder) o2).getName();
                return s1.compareTo(s2);
            } else if (o1 instanceof Query && o2 instanceof Query) {
                s1 = ((Query) o1).getName();
                s2 = ((Query) o2).getName();
                return s1.compareTo(s2);
            } else if (o1 instanceof Category) {
                return -1;
            }
            return 1;
        }
    });
    toPopulate.addAll(Arrays.asList(children));
    return true;
}
Also used : Category(org.gephi.filters.spi.Category) Query(org.gephi.filters.api.Query) FilterBuilder(org.gephi.filters.spi.FilterBuilder) Comparator(java.util.Comparator)

Example 2 with FilterBuilder

use of org.gephi.filters.spi.FilterBuilder in project gephi by gephi.

the class FilterLibraryImpl method buildBuildersMap.

private void buildBuildersMap() {
    for (FilterBuilder builder : lookup.lookupAll(FilterBuilder.class)) {
        try {
            Filter f = builder.getFilter(workspace);
            buildersMap.put(f.getClass(), builder);
            builder.destroy(f);
        } catch (Exception e) {
        }
    }
    for (CategoryBuilder catBuilder : Lookup.getDefault().lookupAll(CategoryBuilder.class)) {
        for (FilterBuilder builder : catBuilder.getBuilders(workspace)) {
            try {
                Filter f = builder.getFilter(workspace);
                buildersMap.put(f.getClass(), builder);
                builder.destroy(f);
            } catch (Exception e) {
            }
        }
    }
}
Also used : Filter(org.gephi.filters.spi.Filter) FilterBuilder(org.gephi.filters.spi.FilterBuilder) CategoryBuilder(org.gephi.filters.spi.CategoryBuilder)

Example 3 with FilterBuilder

use of org.gephi.filters.spi.FilterBuilder in project gephi by gephi.

the class FilterModelImpl method destroyQuery.

private void destroyQuery(Query query) {
    if (query instanceof AbstractQueryImpl) {
        AbstractQueryImpl absQuery = (AbstractQueryImpl) query;
        for (Query q : absQuery.getDescendantsAndSelf()) {
            if (q instanceof FilterQueryImpl) {
                Filter f = ((FilterQueryImpl) q).getFilter();
                FilterBuilder builder = ((FilterQueryImpl) q).getBuilder();
                if (builder != null) {
                    builder.destroy(f);
                }
            }
        }
    }
}
Also used : Query(org.gephi.filters.api.Query) Filter(org.gephi.filters.spi.Filter) FilterBuilder(org.gephi.filters.spi.FilterBuilder)

Example 4 with FilterBuilder

use of org.gephi.filters.spi.FilterBuilder in project gephi by gephi.

the class DynamicRangeBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders(Workspace workspace) {
    List<FilterBuilder> builders = new ArrayList<>();
    GraphModel am = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
    if (am.isDynamic()) {
        builders.add(new DynamicRangeFilterBuilder(am));
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : FilterBuilder(org.gephi.filters.spi.FilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) GraphController(org.gephi.graph.api.GraphController)

Example 5 with FilterBuilder

use of org.gephi.filters.spi.FilterBuilder in project gephi by gephi.

the class InterEdgesBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders(Workspace workspace) {
    List<FilterBuilder> builders = new ArrayList<>();
    GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
    Graph graph = gm.getGraph();
    AppearanceModel am = Lookup.getDefault().lookup(AppearanceController.class).getModel(workspace);
    // Force refresh
    am.getNodeFunctions(graph);
    for (Column nodeCol : gm.getNodeTable()) {
        if (!nodeCol.isProperty()) {
            if (am.getNodePartition(graph, nodeCol) != null) {
                InterEdgesFilterBuilder builder = new InterEdgesFilterBuilder(nodeCol, am);
                builders.add(builder);
            }
        }
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : Graph(org.gephi.graph.api.Graph) AppearanceModel(org.gephi.appearance.api.AppearanceModel) Column(org.gephi.graph.api.Column) FilterBuilder(org.gephi.filters.spi.FilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) AppearanceController(org.gephi.appearance.api.AppearanceController) GraphController(org.gephi.graph.api.GraphController)

Aggregations

FilterBuilder (org.gephi.filters.spi.FilterBuilder)13 ArrayList (java.util.ArrayList)6 Query (org.gephi.filters.api.Query)6 GraphController (org.gephi.graph.api.GraphController)6 GraphModel (org.gephi.graph.api.GraphModel)6 Column (org.gephi.graph.api.Column)5 AppearanceController (org.gephi.appearance.api.AppearanceController)3 AppearanceModel (org.gephi.appearance.api.AppearanceModel)3 FilterController (org.gephi.filters.api.FilterController)3 Graph (org.gephi.graph.api.Graph)3 Transferable (java.awt.datatransfer.Transferable)2 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)2 IOException (java.io.IOException)2 FilterBuilderNode (org.gephi.desktop.filters.library.FilterBuilderNode)2 Filter (org.gephi.filters.spi.Filter)2 AbstractNode (org.openide.nodes.AbstractNode)2 Node (org.openide.nodes.Node)2 PasteType (org.openide.util.datatransfer.PasteType)2 Comparator (java.util.Comparator)1 SavedQueryNode (org.gephi.desktop.filters.library.SavedQueryNode)1