use of org.gephi.graph.api.TimeRepresentation in project gephi by gephi.
the class SupportedColumnTypeWrapper method buildOrderedSupportedTypesList.
/**
* Build a list of column type wrappers from GraphStore supported types.
*
* @param graphModel
* @return Ordered column type wrappers list
*/
public static List<SupportedColumnTypeWrapper> buildOrderedSupportedTypesList(GraphModel graphModel) {
List<SupportedColumnTypeWrapper> supportedTypesWrappers = new ArrayList<>();
TimeRepresentation timeRepresentation = graphModel.getConfiguration().getTimeRepresentation();
for (Class<?> type : AttributeUtils.getSupportedTypes()) {
if (type.equals(Map.class) || type.equals(List.class) || type.equals(Set.class)) {
continue;
//Not yet supported in Gephi
}
if (AttributeUtils.isStandardizedType(type) && isTypeAvailable(type, timeRepresentation)) {
supportedTypesWrappers.add(new SupportedColumnTypeWrapper(type));
}
}
Collections.sort(supportedTypesWrappers);
return supportedTypesWrappers;
}
use of org.gephi.graph.api.TimeRepresentation in project gephi by gephi.
the class AttributeColumnsControllerImpl method convertColumnToDynamic.
private Column convertColumnToDynamic(Table table, Column column, double low, double high, String newColumnTitle) {
Class oldType = column.getTypeClass();
TimeRepresentation timeRepresentation = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getConfiguration().getTimeRepresentation();
Class<?> newType;
if (timeRepresentation == TimeRepresentation.TIMESTAMP) {
newType = AttributeUtils.getTimestampMapType(oldType);
} else {
newType = AttributeUtils.getIntervalMapType(oldType);
}
if (newColumnTitle != null) {
if (newColumnTitle.equals(column.getTitle())) {
throw new IllegalArgumentException("Column titles can't be equal");
}
}
Element[] rows = getTableAttributeRows(table);
Object[] oldValues = new Object[rows.length];
for (int i = 0; i < rows.length; i++) {
oldValues[i] = rows[i].getAttribute(column);
}
Column newColumn;
if (newColumnTitle == null) {
table.removeColumn(column);
newColumn = table.addColumn(column.getTitle(), newType, column.getOrigin());
} else {
newColumn = table.addColumn(newColumnTitle, newType, column.getOrigin());
}
if (timeRepresentation == TimeRepresentation.TIMESTAMP) {
for (int i = 0; i < rows.length; i++) {
if (oldValues[i] != null) {
rows[i].setAttribute(newColumn, oldValues[i], low);
}
}
} else {
Interval interval = new Interval(low, high);
for (int i = 0; i < rows.length; i++) {
if (oldValues[i] != null) {
rows[i].setAttribute(newColumn, oldValues[i], interval);
}
}
}
return newColumn;
}
Aggregations