use of org.gephi.preview.plugin.items.EdgeLabelItem 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]);
}
Aggregations