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));
}
}
}
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));
}
Aggregations