use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.
the class FilterControllerImpl method selectVisible.
@Override
public void selectVisible(Query query) {
if (query != null && model.getCurrentQuery() == query && model.isSelecting()) {
return;
}
model.setSelecting(query != null);
model.setCurrentQuery(query);
if (model.getFilterThread() != null) {
model.getFilterThread().setRunning(false);
model.setFilterThread(null);
}
model.getGraphModel().setVisibleView(null);
if (model.getCurrentResult() != null) {
model.getGraphModel().destroyView(model.getCurrentResult());
model.setCurrentResult(null);
}
if (query != null) {
FilterThread filterThread = new FilterThread(model);
model.setFilterThread(filterThread);
filterThread.setRootQuery((AbstractQueryImpl) query);
filterThread.start();
} else {
VisualizationController visController = Lookup.getDefault().lookup(VisualizationController.class);
if (visController != null) {
visController.selectNodes(null);
}
}
}
use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.
the class FilterThread method select.
private void select(AbstractQueryImpl query) {
FilterProcessor processor = new FilterProcessor();
GraphModel graphModel = model.getGraphModel();
Graph result = processor.process((AbstractQueryImpl) query, graphModel);
if (running) {
VisualizationController visController = Lookup.getDefault().lookup(VisualizationController.class);
if (visController != null) {
visController.selectNodes(result.getNodes().toArray());
visController.selectEdges(result.getEdges().toArray());
}
GraphView view = result.getView();
model.setCurrentResult(view);
} else {
//destroy view
graphModel.destroyView(result.getView());
}
}
use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.
the class EdgeLabelBuilder method getItems.
@Override
public Item[] getItems(Graph graph) {
boolean useTextData = false;
for (Edge e : graph.getEdges()) {
TextProperties textData = e.getTextProperties();
if (textData != null && textData.getText() != null && !textData.getText().isEmpty()) {
useTextData = true;
}
}
//Build text
VisualizationController vizController = Lookup.getDefault().lookup(VisualizationController.class);
Column[] edgeColumns = vizController != null ? vizController.getEdgeTextColumns() : null;
List<Item> items = new ArrayList<>();
for (Edge e : graph.getEdges()) {
EdgeLabelItem labelItem = new EdgeLabelItem(e);
String label = getLabel(e, edgeColumns, graph.getView());
labelItem.setData(EdgeLabelItem.LABEL, label);
TextProperties textData = e.getTextProperties();
if (textData != null && useTextData) {
if (textData.getAlpha() != 0) {
labelItem.setData(EdgeLabelItem.COLOR, textData.getColor());
}
// labelItem.setData(EdgeLabelItem.WIDTH, textData.getWidth());
// labelItem.setData(EdgeLabelItem.HEIGHT, textData.getHeight());
labelItem.setData(EdgeLabelItem.SIZE, textData.getSize());
labelItem.setData(EdgeLabelItem.VISIBLE, textData.isVisible());
if (textData.isVisible() && textData.getText() != null && !textData.getText().isEmpty()) {
items.add(labelItem);
}
} else if (label != null && !label.isEmpty()) {
items.add(labelItem);
}
}
return items.toArray(new Item[0]);
}
use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.
the class NodeLabelBuilder method getItems.
@Override
public Item[] getItems(Graph graph) {
boolean useTextData = false;
for (Node n : graph.getNodes()) {
TextProperties textData = n.getTextProperties();
if (textData != null && textData.getText() != null && !textData.getText().isEmpty()) {
useTextData = true;
}
}
//Build text
VisualizationController vizController = Lookup.getDefault().lookup(VisualizationController.class);
Column[] nodeColumns = vizController != null ? vizController.getNodeTextColumns() : null;
List<Item> items = new ArrayList<>();
for (Node n : graph.getNodes()) {
NodeLabelItem labelItem = new NodeLabelItem(n);
String label = getLabel(n, nodeColumns, graph.getView());
labelItem.setData(NodeLabelItem.LABEL, label);
TextProperties textData = n.getTextProperties();
if (textData != null && useTextData) {
if (textData.getR() != -1) {
labelItem.setData(NodeLabelItem.COLOR, new Color((int) (textData.getR() * 255), (int) (textData.getG() * 255), (int) (textData.getB() * 255), (int) (textData.getAlpha() * 255)));
}
// labelItem.setData(NodeLabelItem.WIDTH, textData.getWidth());
// labelItem.setData(NodeLabelItem.HEIGHT, textData.getHeight());
labelItem.setData(NodeLabelItem.SIZE, textData.getSize());
labelItem.setData(NodeLabelItem.VISIBLE, textData.isVisible());
labelItem.setData(NodeLabelItem.LABEL, textData.getText());
if (textData.isVisible() && label != null && !label.isEmpty()) {
items.add(labelItem);
}
} else if (label != null && !label.isEmpty()) {
items.add(labelItem);
}
}
return items.toArray(new Item[0]);
}
Aggregations