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]);
}
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 }));
}
}
}
}
}
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]);
}
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]);
}
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]);
}
Aggregations