Search in sources :

Example 1 with TimestampMap

use of org.gephi.graph.api.types.TimestampMap in project gephi by gephi.

the class TimestampMapSparklinesGraphicsComponentProvider method getSparklinesXAndYNumbers.

@Override
public Number[][] getSparklinesXAndYNumbers(Object value) {
    TimestampMap timestampMap = (TimestampMap) value;
    Double[] timestamps = timestampMap.toKeysArray();
    Number[] values = (Number[]) timestampMap.toValuesArray();
    return new Number[][] { timestamps, values };
}
Also used : TimestampMap(org.gephi.graph.api.types.TimestampMap)

Example 2 with TimestampMap

use of org.gephi.graph.api.types.TimestampMap in project gephi by gephi.

the class TimestampMapSparklinesGraphicsComponentProvider method getTextFromValue.

@Override
public String getTextFromValue(Object value) {
    if (value == null) {
        return null;
    }
    TimeFormat timeFormat = graphModelProvider.getGraphModel().getTimeFormat();
    DateTimeZone timeZone = graphModelProvider.getGraphModel().getTimeZone();
    return ((TimestampMap) value).toString(timeFormat, timeZone);
}
Also used : TimeFormat(org.gephi.graph.api.TimeFormat) TimestampMap(org.gephi.graph.api.types.TimestampMap) DateTimeZone(org.joda.time.DateTimeZone)

Example 3 with TimestampMap

use of org.gephi.graph.api.types.TimestampMap in project gephi by gephi.

the class ElementDraftImpl method setAttributeValue.

protected void setAttributeValue(ColumnDraft column, Object value, double timestamp) throws Exception {
    int index = ((ColumnDraftImpl) column).getIndex();
    Class typeClass = column.getTypeClass();
    value = AttributeUtils.standardizeValue(value);
    if (!value.getClass().equals(typeClass)) {
        throw new RuntimeException("The expected value class was " + typeClass.getSimpleName() + " and " + value.getClass().getSimpleName() + " was found");
    }
    if (!column.isDynamic()) {
        throw new RuntimeException("Can't set a dynamic value to a static column");
    }
    if (index >= attributes.length) {
        Object[] newArray = new Object[index + 1];
        System.arraycopy(attributes, 0, newArray, 0, attributes.length);
        attributes = newArray;
    }
    TimestampMap m = (TimestampMap) attributes[index];
    if (m == null) {
        m = AttributeUtils.getTimestampMapType(column.getTypeClass()).newInstance();
        attributes[index] = m;
    }
    m.put(timestamp, value);
}
Also used : TimestampMap(org.gephi.graph.api.types.TimestampMap)

Example 4 with TimestampMap

use of org.gephi.graph.api.types.TimestampMap in project gephi by gephi.

the class AttributeColumnsControllerImpl method getDynamicNumberColumnNumbers.

/**
     * Used for obtaining a list of the numbers of row of a dynamic number column.
     *
     * @param row Row
     * @param column Column with dynamic type
     * @return list of numbers
     */
private List<Number> getDynamicNumberColumnNumbers(Element row, Column column) {
    Class type = column.getTypeClass();
    if (!(AttributeUtils.isNumberType(type) && AttributeUtils.isDynamicType(type))) {
        throw new IllegalArgumentException("Column must be a dynamic number column");
    }
    if (TimestampMap.class.isAssignableFrom(type)) {
        //Timestamp type:
        TimestampMap timestampMap = (TimestampMap) row.getAttribute(column);
        if (timestampMap == null) {
            return new ArrayList<>();
        }
        Number[] dynamicNumbers = (Number[]) timestampMap.toValuesArray();
        return Arrays.asList(dynamicNumbers);
    } else if (IntervalMap.class.isAssignableFrom(type)) {
        //Interval type:
        IntervalMap intervalMap = (IntervalMap) row.getAttribute(column);
        if (intervalMap == null) {
            return new ArrayList<>();
        }
        Number[] dynamicNumbers = (Number[]) intervalMap.toValuesArray();
        return Arrays.asList(dynamicNumbers);
    } else {
        throw new IllegalArgumentException("Unsupported dynamic type class " + type.getCanonicalName());
    }
}
Also used : TimestampMap(org.gephi.graph.api.types.TimestampMap) ArrayList(java.util.ArrayList) IntervalMap(org.gephi.graph.api.types.IntervalMap)

Aggregations

TimestampMap (org.gephi.graph.api.types.TimestampMap)4 ArrayList (java.util.ArrayList)1 TimeFormat (org.gephi.graph.api.TimeFormat)1 IntervalMap (org.gephi.graph.api.types.IntervalMap)1 DateTimeZone (org.joda.time.DateTimeZone)1