Search in sources :

Example 6 with FilterBuilder

use of org.gephi.filters.spi.FilterBuilder in project gephi-plugins-bootcamp by gephi.

the class TopNodesBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders() {
    List<FilterBuilder> builders = new ArrayList<FilterBuilder>();
    //Get all the current attribute columns
    GraphModel am = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
    for (Column c : am.getNodeTable()) {
        //Keep only numerical columns
        if (AttributeUtils.isNumberType(c.getTypeClass())) {
            TopNodesColumnFilterBuilder b = new TopNodesColumnFilterBuilder(c);
            builders.add(b);
        }
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : Column(org.gephi.graph.api.Column) FilterBuilder(org.gephi.filters.spi.FilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) GraphController(org.gephi.graph.api.GraphController)

Example 7 with FilterBuilder

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

the class TimelineControllerImpl method setInterval.

@Override
public void setInterval(double from, double to) {
    if (model != null) {
        if (model.getIntervalStart() != from || model.getIntervalEnd() != to) {
            if (from >= to) {
                throw new IllegalArgumentException("from should be less than to");
            }
            if (!(Double.isInfinite(from) && Double.isInfinite(to))) {
                if (from < model.getCustomMin() || to > model.getCustomMax()) {
                    throw new IllegalArgumentException("From and to should be in the bounds");
                }
            }
            model.setInterval(from, to);
            //Filter magic
            Query dynamicQuery = null;
            boolean selecting = false;
            //Get or create Dynamic Query
            if (filterModel.getCurrentQuery() != null) {
                //Look if current query is dynamic - filtering must be active
                Query query = filterModel.getCurrentQuery();
                Query[] dynamicQueries = query.getQueries(DynamicRangeFilter.class);
                if (dynamicQueries.length > 0) {
                    dynamicQuery = query;
                    selecting = filterModel.isSelecting();
                }
            } else if (filterModel.getQueries().length == 1) {
                //Look if a dynamic query alone exists
                Query query = filterModel.getQueries()[0];
                Query[] dynamicQueries = query.getQueries(DynamicRangeFilter.class);
                if (dynamicQueries.length > 0) {
                    dynamicQuery = query;
                }
            }
            if (Double.isInfinite(from) && Double.isInfinite(to)) {
                if (dynamicQuery != null) {
                    filterController.remove(dynamicQuery);
                }
            } else {
                if (dynamicQuery == null) {
                    //Create dynamic filter
                    DynamicRangeBuilder rangeBuilder = filterModel.getLibrary().getLookup().lookup(DynamicRangeBuilder.class);
                    FilterBuilder[] fb = rangeBuilder.getBuilders(filterModel.getWorkspace());
                    if (fb.length > 0) {
                        dynamicQuery = filterController.createQuery(fb[0]);
                        filterController.add(dynamicQuery);
                    }
                }
                if (dynamicQuery != null) {
                    dynamicQuery.getFilter().getProperties()[0].setValue(new Range(from, to));
                    if (selecting) {
                        filterController.selectVisible(dynamicQuery);
                    } else {
                        filterController.filterVisible(dynamicQuery);
                    }
                    fireTimelineModelEvent(new TimelineModelEvent(TimelineModelEvent.EventType.INTERVAL, model, new double[] { from, to }));
                }
            }
        }
    }
}
Also used : Query(org.gephi.filters.api.Query) DynamicRangeFilter(org.gephi.filters.plugin.dynamic.DynamicRangeBuilder.DynamicRangeFilter) FilterBuilder(org.gephi.filters.spi.FilterBuilder) Range(org.gephi.filters.api.Range) DynamicRangeBuilder(org.gephi.filters.plugin.dynamic.DynamicRangeBuilder)

Example 8 with FilterBuilder

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

the class IntraEdgesBuilder 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) {
                IntraEdgesFilterBuilder builder = new IntraEdgesFilterBuilder(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)

Example 9 with FilterBuilder

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

the class PartitionBuilder 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) {
                PartitionFilterBuilder builder = new PartitionFilterBuilder(nodeCol, am);
                builders.add(builder);
            }
        }
    }
    for (Column edgeCol : gm.getEdgeTable()) {
        if (!edgeCol.isProperty()) {
            if (am.getEdgePartition(graph, edgeCol) != null) {
                PartitionFilterBuilder builder = new PartitionFilterBuilder(edgeCol, 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)

Example 10 with FilterBuilder

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

the class AttributeNonNullBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders(Workspace workspace) {
    List<FilterBuilder> builders = new ArrayList<>();
    GraphModel am = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
    for (Column col : am.getNodeTable()) {
        if (!col.isProperty()) {
            AttributeNonNullFilterBuilder b = new AttributeNonNullFilterBuilder(col);
            builders.add(b);
        }
    }
    for (Column col : am.getEdgeTable()) {
        if (!col.isProperty()) {
            AttributeNonNullFilterBuilder b = new AttributeNonNullFilterBuilder(col);
            builders.add(b);
        }
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : Column(org.gephi.graph.api.Column) FilterBuilder(org.gephi.filters.spi.FilterBuilder) AbstractAttributeFilterBuilder(org.gephi.filters.plugin.AbstractAttributeFilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) 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