use of org.gephi.io.importer.plugin.file.spreadsheet.process.SpreadsheetGeneralConfiguration.Mode in project gephi by gephi.
the class WizardVisualPanel2 method loadColumns.
private void loadColumns(JPanel settingsPanel) {
try {
columnsCheckBoxes.clear();
columnsComboBoxes.clear();
JLabel columnsLabel = new JLabel(getMessage("WizardVisualPanel2.columnsLabel.text"));
settingsPanel.add(columnsLabel, "wrap");
final String[] headers = importer.getHeadersMap().keySet().toArray(new String[0]);
final Mode mode = importer.getMode();
for (String header : headers) {
if (header.isEmpty()) {
// Remove empty column headers:
continue;
}
JCheckBox columnCheckBox = new JCheckBox(header, true);
if (importer.getMode() == Mode.EDGES_TABLE && (header.equalsIgnoreCase("source") || header.equalsIgnoreCase("target"))) {
columnCheckBox.setEnabled(false);
}
columnsCheckBoxes.add(columnCheckBox);
JComboBox columnComboBox = new JComboBox();
if (mode.isSpecialColumn(header)) {
settingsPanel.add(columnCheckBox, "wrap 15px");
// Special columns such as id, label, source and target... don't need a type selector
// The type is not used by the importer anyway
columnsComboBoxes.add(null);
} else {
settingsPanel.add(columnCheckBox, "wrap");
columnsComboBoxes.add(columnComboBox);
fillComboBoxWithColumnTypes(header, columnComboBox);
settingsPanel.add(columnComboBox, "wrap 15px");
}
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
use of org.gephi.io.importer.plugin.file.spreadsheet.process.SpreadsheetGeneralConfiguration.Mode in project gephi by gephi.
the class AbstractImporterSpreadsheet method autoDetectImportMode.
protected void autoDetectImportMode() {
try {
SheetParser parser = createParserWithoutHeaders();
Mode mode = null;
Iterator<SheetRow> iterator = parser.iterator();
if (iterator.hasNext()) {
SheetRow firstRow = iterator.next();
if (firstRow.get(0) == null || firstRow.get(0).trim().isEmpty()) {
mode = Mode.MATRIX;
} else {
// Detect very probable edges table:
for (int i = 0; i < firstRow.size(); i++) {
String value = firstRow.get(i);
if ("source".equalsIgnoreCase(value) || "target".equalsIgnoreCase(value)) {
mode = Mode.EDGES_TABLE;
break;
}
}
// Detect probable nodes table:
if (mode == null) {
for (int i = 0; i < firstRow.size(); i++) {
String value = firstRow.get(i);
if ("id".equalsIgnoreCase(value) || "label".equalsIgnoreCase(value) || "timeset".equalsIgnoreCase(value)) {
mode = Mode.NODES_TABLE;
}
}
}
}
}
if (mode == null) {
// Default adjacency list:
mode = Mode.ADJACENCY_LIST;
}
setMode(mode);
} catch (IOException ex) {
// NOOP
}
}
Aggregations