Interface FilterController


  • public interface FilterController
    Use filters and queries for filtering the Graph. This controller manages FilterModel instances. A model is defined for each workspace.

    This controller is a singleton and can therefore be found in Lookup:

    FilterController fc = Lookup.getDefault().lookup(FilterController.class);

    The controller has two ways to execute filtering, a one-shot one that immediately returns the GraphView and a more complex one suitable for user interface interaction, with live parameter change.

    The one-shot filtering can be executed like below:

     Filter filter = ...
     Query query = controller.createQuery(filter);
     GraphView view = controller.filter(query);
     
    The normal mode is to call filterVisible(org.gephi.filters.api.Query) which let this controller manage the execution. The benefit of this of this mode is that properties change on filters are listened and filtering is automatically reexecuted if values changes. See how to execute a filter with two different values:
     Filter filter = ...
     filter.getProperties()[0].setValue(1);       //Set value 1, for example a threshold
     Query query = controller.createQuery(filter);
     controller.add(query);
     controller.filterVisible(query);     //A background thread executes the query
     filter.getProperties[0].setValue(2)      //The background thread reexecute the query
     
    Author:
    Mathieu Bastian
    See Also:
    GraphView
    • Method Detail

      • createQuery

        Query createQuery​(FilterBuilder builder)
        Creates a query from builder. The created query is a root query.
        Parameters:
        builder - the builder that can create the filter that is to be wrapped in a new query
        Returns:
        a query that is wrapping builder
      • createQuery

        Query createQuery​(Filter filter)
        Creates a query from filter. The created query is a root query.
        Parameters:
        filter - the filter that is to be wrapped in a new query
        Returns:
        a query that is wrapping filter
      • add

        void add​(Query query)
        Adds query as a new query in the system. The query should be a root query.
        Parameters:
        query - the query that is to be added
      • remove

        void remove​(Query query)
        Removes query from the system if exists.
        Parameters:
        query - the query that is to be removed
      • rename

        void rename​(Query query,
                    String name)
        Renames query with name.
        Parameters:
        query - the query that is to be renamed
        name - the new query's name
      • setSubQuery

        void setSubQuery​(Query query,
                         Query subQuery)
        Sets subQuery as a child of query. If subQuery already has a parent query, it will be removed first.
        Parameters:
        query - the query that subQuery is to be added as a new child
        subQuery - the query that is to be added as a child of query
      • removeSubQuery

        void removeSubQuery​(Query query,
                            Query parent)
        Removes query from parent query.
        Parameters:
        query - the query that is to be removed from parent
        parent - the query that query is to be removed as a child
      • filterVisible

        void filterVisible​(Query query)
        Filters main graph with query and set result as the new visible graph. Note that the query will be executed in a background thread and results delivered as soon as ready. Then, query is defined as the currently active query and property's value changes are watched. If a query's property is changed the query is automatically reexecuted.
        Parameters:
        query - the query that is to be executed
      • selectVisible

        void selectVisible​(Query query)
        Selects query results on the main graph visualization window. Note that the query will be executed in a background thread and results delivered as soon as ready. Then, query is defined as the currently active query and property's value changes are watched. If a query's property is changed the query is automatically reexecuted.
        Parameters:
        query - the query that is to be executed
      • filter

        GraphView filter​(Query query)
        Filtering method for API users. The query is executed and the GraphView result is returned.
        Parameters:
        query - the query that is to be executed
        Returns:
        a graph view that represents the query result
      • exportToColumn

        void exportToColumn​(String title,
                            Query query)
        Exports query result in a new column title. Nodes and edges that pass the query have true value and false for others.
        Parameters:
        title - the column's title
        query - the query that is to be executed
      • exportToNewWorkspace

        void exportToNewWorkspace​(Query query)
        Exports query result in a new workspace. Note that query is executed in a separate thread and the workspace may not be ready immediately when this method returns.
        Parameters:
        query - the query that is to be executed
      • exportToLabelVisible

        void exportToLabelVisible​(Query query)
        Exports query result to visible/hidden labels. Each node and edge not present in the query result has its label set hidden. Label visibility is controlled from TextData object, accessible from NodeData or EdgeData.
        Parameters:
        query - the query that is to be used to hide labels
      • setAutoRefresh

        void setAutoRefresh​(boolean autoRefresh)
      • setCurrentQuery

        void setCurrentQuery​(Query query)
      • getModel

        FilterModel getModel()
        Returns the filter's model.
        Returns:
        the filter's model
      • getModel

        FilterModel getModel​(Workspace workspace)
        Returns the filter's model for workspace.
        Parameters:
        workspace - workspace
        Returns:
        the filter's model in the given workspace