use of org.gephi.graph.api.types.TimeMap in project gephi by gephi.
the class AbstractProcessor method flushToElementAttributes.
protected void flushToElementAttributes(ElementDraft elementDraft, Element element) {
for (ColumnDraft col : elementDraft.getColumns()) {
if (elementDraft instanceof EdgeDraft && col.getId().equals("weight")) {
continue;
}
Object val = elementDraft.getValue(col.getId());
if (val != null) {
TimeMap existingMap;
if (col.isDynamic() && (existingMap = (TimeMap) element.getAttribute(col.getId())) != null && !existingMap.isEmpty()) {
TimeMap valMap = (TimeMap) val;
Object[] keys = existingMap.toKeysArray();
Object[] vals = existingMap.toValuesArray();
for (int i = 0; i < keys.length; i++) {
valMap.put(keys[i], vals[i]);
}
element.setAttribute(col.getId(), valMap);
} else {
element.setAttribute(col.getId(), val);
}
}
}
}
use of org.gephi.graph.api.types.TimeMap in project gephi by gephi.
the class AbstractProcessor method flushEdgeWeight.
protected void flushEdgeWeight(EdgeDraft edgeDraft, Edge edge) {
Object val = edgeDraft.getValue("weight");
if (val != null && val instanceof TimeMap) {
TimeMap valMap = (TimeMap) val;
TimeMap existingMap = (TimeMap) edge.getAttribute("weight");
if (existingMap != null) {
Object[] keys = ((TimeMap) val).toKeysArray();
Object[] vals = ((TimeMap) val).toValuesArray();
for (int i = 0; i < keys.length; i++) {
valMap.put(keys[i], ((Number) vals[i]).doubleValue());
}
}
edge.setAttribute("weight", val);
}
}
use of org.gephi.graph.api.types.TimeMap in project gephi by gephi.
the class AttributePartitionImpl method refresh.
@Override
protected void refresh() {
if (graph != null) {
parts.clear();
elements = 0;
ElementIterable<? extends Element> iterable = AttributeUtils.isNodeColumn(column) ? graph.getNodes() : graph.getEdges();
for (Element el : iterable) {
TimeMap val = (TimeMap) el.getAttribute(column);
if (val != null) {
Object[] va = val.toValuesArray();
for (Object v : va) {
Integer count = parts.get(v);
if (count == null) {
count = 0;
}
parts.put(v, ++count);
elements++;
}
}
}
}
}
Aggregations