use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class StatisticsControllerImpl method executeDynamic.
private void executeDynamic(DynamicStatistics statistics, DynamicLongTask dynamicLongTask) {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel();
double window = statistics.getWindow();
double tick = statistics.getTick();
GraphView currentView = graphModel.getVisibleView();
Interval bounds = statistics.getBounds();
if (bounds == null) {
if (currentView.isMainView()) {
bounds = graphModel.getTimeBounds();
} else {
bounds = currentView.getTimeInterval();
}
statistics.setBounds(bounds);
}
if (dynamicLongTask != null) {
//Count
int c = (int) ((bounds.getHigh() - window - bounds.getLow()) / tick);
dynamicLongTask.start(c);
}
//Init
statistics.execute(graphModel);
//Loop
for (double low = bounds.getLow(); low <= bounds.getHigh() - window; low += tick) {
double high = low + window;
Graph graph = graphModel.getGraphVisible();
graph.writeLock();
try {
GraphView view = graphModel.createView();
Subgraph g = graphModel.getGraph(view);
TimeIndex<Node> nodeIndex = graphModel.getNodeTimeIndex(currentView);
if (Double.isInfinite(nodeIndex.getMinTimestamp()) && Double.isInfinite(nodeIndex.getMaxTimestamp())) {
for (Node node : graph.getNodes()) {
g.addNode(node);
}
} else {
for (Node node : nodeIndex.get(new Interval(low, high))) {
g.addNode(node);
}
}
TimeIndex<Edge> edgeIndex = graphModel.getEdgeTimeIndex(currentView);
if (Double.isInfinite(edgeIndex.getMinTimestamp()) && Double.isInfinite(edgeIndex.getMaxTimestamp())) {
for (Edge edge : graph.getEdges()) {
if (g.contains(edge.getSource()) && g.contains(edge.getTarget())) {
g.addEdge(edge);
}
}
} else {
for (Edge edge : edgeIndex.get(new Interval(low, high))) {
if (g.contains(edge.getSource()) && g.contains(edge.getTarget())) {
g.addEdge(edge);
}
}
}
statistics.loop(g.getView(), new Interval(low, high));
} finally {
graph.writeUnlock();
}
//Cancelled?
if (dynamicLongTask != null && dynamicLongTask.isCancelled()) {
return;
} else if (dynamicLongTask != null) {
dynamicLongTask.progress();
}
}
statistics.end();
model.addReport(statistics);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class StatisticsControllerImpl method execute.
@Override
public void execute(Statistics statistics) {
if (statistics instanceof DynamicStatistics) {
executeDynamic((DynamicStatistics) statistics, null);
} else {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel();
statistics.execute(graphModel);
model.addReport(statistics);
}
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class MergeColumnsUI method loadColumns.
private void loadColumns() {
availableColumnsModel.clear();
columnsToMergeModel.clear();
GraphModel am = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
Column[] columns;
if (mode == Mode.NODES_TABLE) {
table = am.getNodeTable();
columns = table.toArray();
} else {
table = am.getEdgeTable();
columns = table.toArray();
}
for (Column column : columns) {
availableColumnsModel.addElement(new ColumnWrapper(column));
}
availableColumnsList.setModel(availableColumnsModel);
columnsToMergeList.setModel(columnsToMergeModel);
}
use of org.gephi.graph.api.GraphModel 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]);
}
use of org.gephi.graph.api.GraphModel in project gephi by gephi.
the class PartitionCountBuilder 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) {
PartitionCountFilterBuilder builder = new PartitionCountFilterBuilder(nodeCol, am);
builders.add(builder);
}
}
}
for (Column edgeCol : gm.getEdgeTable()) {
if (!edgeCol.isProperty()) {
if (am.getEdgePartition(graph, edgeCol) != null) {
PartitionCountFilterBuilder builder = new PartitionCountFilterBuilder(edgeCol, am);
builders.add(builder);
}
}
}
return builders.toArray(new FilterBuilder[0]);
}
Aggregations