use of org.gephi.io.importer.api.EdgeDirectionDefault in project gephi by gephi.
the class ReportPanel method initGraphTypeCombo.
private void initGraphTypeCombo(final Container[] containers) {
final String directedStr = NbBundle.getMessage(ReportPanel.class, "ReportPanel.graphType.directed");
final String undirectedStr = NbBundle.getMessage(ReportPanel.class, "ReportPanel.graphType.undirected");
final String mixedStr = NbBundle.getMessage(ReportPanel.class, "ReportPanel.graphType.mixed");
EdgeDirectionDefault edd = null;
for (Container container : containers) {
EdgeDirectionDefault d = container.getUnloader().getEdgeDefault();
if (edd == null) {
edd = d;
} else if (d.equals(EdgeDirectionDefault.UNDIRECTED) && !edd.equals(EdgeDirectionDefault.UNDIRECTED)) {
edd = EdgeDirectionDefault.MIXED;
} else if (d.equals(EdgeDirectionDefault.DIRECTED) && !edd.equals(EdgeDirectionDefault.DIRECTED)) {
edd = EdgeDirectionDefault.MIXED;
}
}
final EdgeDirectionDefault dir = edd;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
DefaultComboBoxModel comboModel = new DefaultComboBoxModel();
switch(dir) {
case DIRECTED:
comboModel.addElement(directedStr);
comboModel.addElement(undirectedStr);
comboModel.addElement(mixedStr);
comboModel.setSelectedItem(directedStr);
break;
case UNDIRECTED:
comboModel.addElement(undirectedStr);
comboModel.addElement(mixedStr);
comboModel.setSelectedItem(undirectedStr);
break;
case MIXED:
comboModel.addElement(directedStr);
comboModel.addElement(undirectedStr);
comboModel.addElement(mixedStr);
comboModel.setSelectedItem(mixedStr);
break;
}
graphTypeCombo.setModel(comboModel);
}
});
graphTypeCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
Object g = e.getItem();
if (g.equals(directedStr)) {
for (Container container : containers) {
container.getLoader().setEdgeDefault(EdgeDirectionDefault.DIRECTED);
}
} else if (g.equals(undirectedStr)) {
for (Container container : containers) {
container.getLoader().setEdgeDefault(EdgeDirectionDefault.UNDIRECTED);
}
} else if (g.equals(mixedStr)) {
for (Container container : containers) {
container.getLoader().setEdgeDefault(EdgeDirectionDefault.MIXED);
}
}
}
}
});
}
Aggregations