use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class LoadMultipleNetworksTask method getTargetColumns.
private final ListSingleSelection<String> getTargetColumns(final CyNetwork network) {
final CyTable selectedTable = network.getTable(CyNode.class, CyRootNetwork.SHARED_ATTRS);
final List<String> colNames = new ArrayList<>();
for (CyColumn col : selectedTable.getColumns()) {
// Exclude SUID from the mapping key list
if (!col.getName().equalsIgnoreCase(CyIdentifiable.SUID) && !col.getName().endsWith(".SUID") && (col.getType() == String.class || col.getType() == Integer.class || col.getType() == Long.class))
colNames.add(col.getName());
}
if (colNames.isEmpty() || (colNames.size() == 1 && colNames.contains(CyRootNetwork.SHARED_NAME)))
return new ListSingleSelection<>();
sort(colNames);
return new ListSingleSelection<>(colNames);
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class ModelMonitor method checkType.
public boolean checkType(String name, Class<?> columnType, Class<?> targetType) {
synchronized (lock) {
if (network == null) {
return false;
}
CyTable table = getTable(columnType);
if (table == null) {
return false;
}
CyColumn column = table.getColumn(name);
if (column == null) {
return false;
}
Class<?> type = column.getType();
if (List.class.equals(type)) {
return targetType.equals(column.getListElementType());
}
return targetType.equals(type);
}
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class ModelMonitor method updateColumnSliders.
private void updateColumnSliders() {
for (ColumnFilterController controller : columnViews.values()) {
ColumnFilter filter = controller.getFilter();
Class<? extends CyIdentifiable> columnType = filter.getTableType();
Number[] range;
String name = filter.getColumnName();
if (name == null) {
continue;
}
CyTable table;
if (CyNode.class.equals(columnType)) {
table = network.getDefaultNodeTable();
range = getColumnRange(table, name, nodeColumnRanges);
} else if (CyEdge.class.equals(columnType)) {
table = network.getDefaultEdgeTable();
range = getColumnRange(table, name, edgeColumnRanges);
} else {
continue;
}
CyColumn column = table.getColumn(name);
if (column == null) {
continue;
}
Class<?> type = column.getType();
if (List.class.equals(type)) {
type = column.getListElementType();
}
if (Integer.class.equals(type) || Long.class.equals(type)) {
controller.setSliderBounds(range[0].longValue(), range[1].longValue());
} else {
controller.setSliderBounds(range[0].doubleValue(), range[1].doubleValue());
}
}
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class ModelMonitor method handleEvent.
@Override
public void handleEvent(ColumnNameChangedEvent event) {
synchronized (lock) {
if (network == null) {
return;
}
CyTable nodeTable = network.getDefaultNodeTable();
CyTable edgeTable = network.getDefaultEdgeTable();
CyTable table = event.getSource();
CyColumn column = table.getColumn(event.getNewColumnName());
Class<?> type;
if (table == nodeTable) {
type = CyNode.class;
} else if (table == edgeTable) {
type = CyEdge.class;
} else {
return;
}
for (int i = 0; i < columnNames.size(); i++) {
ColumnElement element = columnNames.get(i);
if (element.getName().equals(event.getOldColumnName()) && type.equals(element.getTableType())) {
columnNames.remove(i);
columnNames.add(new ColumnElement(element.getTableType(), column));
break;
}
}
Collections.sort(columnNames);
updateColumnViews();
}
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class ColumnFilter method validate.
@Override
public List<ValidationWarning> validate(CyNetwork context) {
if (context == null)
return Collections.emptyList();
CyTable table;
String tableType;
Class<?> type = getTableType();
if (CyNode.class.equals(type)) {
table = context.getDefaultNodeTable();
tableType = "Node";
} else if (CyEdge.class.equals(type)) {
table = context.getDefaultEdgeTable();
tableType = "Edge";
} else {
return Collections.emptyList();
}
if (columnName != null) {
CyColumn column = table.getColumn(columnName);
if (column == null) {
return warn(tableType + " table does not have column <b>\"" + columnName + "\"</b>");
}
}
if (rawCriterion == null || predicate == null) {
// This filter is incomplete.
return Collections.emptyList();
}
CyColumn column = table.getColumn(columnName);
Class<?> columnType = column.getType();
if (columnType.equals(List.class)) {
columnType = column.getListElementType();
}
if (String.class.equals(columnType) && stringCriterion == null) {
return warn("Column <b>\"" + columnName + "\"</b> in " + tableType + " table is not a String column");
} else if (Number.class.isAssignableFrom(columnType) && (lowerBound == null || upperBound == null)) {
return warn("Column <b>\"" + columnName + "\"</b> in " + tableType + " table is not a Numeric column");
} else if (Boolean.class.equals(columnType) && booleanCriterion == null) {
return warn("Column <b>\"" + columnName + "\"</b> in " + tableType + " table is not a Boolean column");
}
return Collections.emptyList();
}
Aggregations