use of org.gephi.graph.api.types.IntervalSet 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.IntervalSet in project gephi by gephi.
the class IntervalSetGraphicsComponentProvider method getTimeIntervalGraphicsParameters.
@Override
public TimeIntervalGraphicsParameters getTimeIntervalGraphicsParameters(TimeSet value) {
IntervalSet intervalSet = (IntervalSet) value;
double[] intervals = intervalSet.getIntervals();
double[] starts = new double[intervals.length / 2];
double[] ends = new double[intervals.length / 2];
for (int i = 0, startIndex = 0; startIndex < intervals.length; i++, startIndex += 2) {
starts[i] = intervals[startIndex];
ends[i] = intervals[startIndex + 1];
}
return new TimeIntervalGraphicsParameters(starts, ends);
}
Aggregations