Search in sources :

Example 6 with TimeSet

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

the class ExporterGEXF method writeTimeSet.

private void writeTimeSet(XMLStreamWriter xmlWriter, Graph graph, Element element) throws Exception {
    Interval visibleInterval = graph.getView().getTimeInterval();
    TimeRepresentation timeRepresentation = graph.getModel().getConfiguration().getTimeRepresentation();
    TimeSet timeSet = (TimeSet) element.getAttribute("timeset");
    TimeFormat timeFormat = graph.getModel().getTimeFormat();
    DateTimeZone timeZone = graph.getModel().getTimeZone();
    if (timeSet != null && !timeSet.isEmpty()) {
        if (timeSet.size() > 1) {
            xmlWriter.writeStartElement(SPELLS);
            if (timeRepresentation.equals(TimeRepresentation.INTERVAL)) {
                for (Interval interval : ((IntervalSet) timeSet).toArray()) {
                    if (!exportVisible || interval.compareTo(visibleInterval) == 0) {
                        xmlWriter.writeStartElement(SPELL);
                        if (!Double.isInfinite(interval.getLow())) {
                            String intervalLow = AttributeUtils.printTimestampInFormat(interval.getLow(), timeFormat, timeZone);
                            xmlWriter.writeAttribute(START, intervalLow);
                        }
                        if (!Double.isInfinite(interval.getHigh())) {
                            String intervalHigh = AttributeUtils.printTimestampInFormat(interval.getHigh(), timeFormat, timeZone);
                            xmlWriter.writeAttribute(END, intervalHigh);
                        }
                        xmlWriter.writeEndElement();
                    }
                }
            } else if (timeRepresentation.equals(TimeRepresentation.TIMESTAMP)) {
                for (Double timestamp : ((TimestampSet) timeSet).toArray()) {
                    if (!exportVisible || visibleInterval.compareTo(timestamp) == 0) {
                        xmlWriter.writeStartElement(SPELL);
                        xmlWriter.writeAttribute(TIMESTAMP, AttributeUtils.printTimestampInFormat(timestamp, timeFormat, timeZone));
                        xmlWriter.writeEndElement();
                    }
                }
            }
            xmlWriter.writeEndElement();
        } else if (timeRepresentation.equals(TimeRepresentation.INTERVAL)) {
            Interval interval = ((IntervalSet) timeSet).toArray()[0];
            if (!Double.isInfinite(interval.getLow())) {
                String intervalLow = AttributeUtils.printTimestampInFormat(interval.getLow(), timeFormat, timeZone);
                xmlWriter.writeAttribute(START, intervalLow);
            }
            if (!Double.isInfinite(interval.getHigh())) {
                String intervalHigh = AttributeUtils.printTimestampInFormat(interval.getHigh(), timeFormat, timeZone);
                xmlWriter.writeAttribute(END, intervalHigh);
            }
        } else if (timeRepresentation.equals(TimeRepresentation.TIMESTAMP)) {
            Double timestamp = ((TimestampSet) timeSet).toArray()[0];
            xmlWriter.writeAttribute(TIMESTAMP, AttributeUtils.printTimestampInFormat(timestamp, timeFormat, timeZone));
        }
    }
}
Also used : TimeSet(org.gephi.graph.api.types.TimeSet) IntervalSet(org.gephi.graph.api.types.IntervalSet) DateTimeZone(org.joda.time.DateTimeZone)

Example 7 with TimeSet

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

the class AbstractProcessor method flushTimeSet.

protected void flushTimeSet(TimeSet timeSet, Element element) {
    TimeSet existingTimeSet = (TimeSet) element.getAttribute("timeset");
    element.setAttribute("timeset", mergeTimeSets(existingTimeSet, timeSet));
}
Also used : TimeSet(org.gephi.graph.api.types.TimeSet)

Aggregations

TimeSet (org.gephi.graph.api.types.TimeSet)7 TimeMap (org.gephi.graph.api.types.TimeMap)3 ColumnDraft (org.gephi.io.importer.api.ColumnDraft)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Column (org.gephi.graph.api.Column)1 TimeRepresentation (org.gephi.graph.api.TimeRepresentation)1 IntervalDoubleMap (org.gephi.graph.api.types.IntervalDoubleMap)1 IntervalIntegerMap (org.gephi.graph.api.types.IntervalIntegerMap)1 IntervalLongMap (org.gephi.graph.api.types.IntervalLongMap)1 IntervalSet (org.gephi.graph.api.types.IntervalSet)1 IntervalStringMap (org.gephi.graph.api.types.IntervalStringMap)1 TimestampDoubleMap (org.gephi.graph.api.types.TimestampDoubleMap)1 TimestampIntegerMap (org.gephi.graph.api.types.TimestampIntegerMap)1 TimestampLongMap (org.gephi.graph.api.types.TimestampLongMap)1 TimestampMap (org.gephi.graph.api.types.TimestampMap)1