private void writeTimeInterval(XMLStreamWriter xmlWriter, TimeInterval timeInterval)
     throws Exception {
   List<Interval<Double[]>> intervals =
       timeInterval.getIntervals(visibleInterval.getLow(), visibleInterval.getHigh());
   if (intervals.size() > 1) {
     xmlWriter.writeStartElement(SLICES);
     for (Interval<Double[]> interval : intervals) {
       xmlWriter.writeStartElement(SLICE);
       if (!Double.isInfinite(interval.getLow())) {
         String intervalLow = formatTime(interval.getLow());
         xmlWriter.writeAttribute(interval.isLowExcluded() ? START_OPEN : START, intervalLow);
       }
       if (!Double.isInfinite(interval.getHigh())) {
         String intervalHigh = formatTime(interval.getHigh());
         xmlWriter.writeAttribute(interval.isHighExcluded() ? END_OPEN : END, intervalHigh);
       }
       xmlWriter.writeEndElement();
     }
     xmlWriter.writeEndElement();
   } else if (intervals.size() == 1) {
     Interval<Double[]> interval = intervals.get(0);
     if (!Double.isInfinite(interval.getLow())) {
       String intervalLow = formatTime(interval.getLow());
       xmlWriter.writeAttribute(interval.isLowExcluded() ? START_OPEN : START, intervalLow);
     }
     if (!Double.isInfinite(interval.getHigh())) {
       String intervalHigh = formatTime(interval.getHigh());
       xmlWriter.writeAttribute(interval.isHighExcluded() ? END_OPEN : END, intervalHigh);
     }
   }
 }
示例#2
0
  private Number[][] getDynamicNumberNumbers(DynamicType dynamicNumber) {
    ArrayList<Number> xValues = new ArrayList<Number>();
    ArrayList<Number> yValues = new ArrayList<Number>();
    if (dynamicNumber == null) {
      return new Number[2][0];
    }

    List<Interval> intervals = dynamicNumber.getIntervals();
    Number n;
    for (Interval interval : intervals) {
      n = (Number) interval.getValue();
      if (n != null) {
        xValues.add(interval.getLow());
        yValues.add(n);
      }
    }
    return new Number[][] {xValues.toArray(new Number[0]), yValues.toArray(new Number[0])};
  }
 private void writeAttValues(
     XMLStreamWriter xmlWriter, AttributeRow row, TimeInterval visibleInterval) throws Exception {
   xmlWriter.writeStartElement(ATTVALUES);
   for (AttributeValue val : row.getValues()) {
     AttributeColumn col = val.getColumn();
     if (!col.getOrigin().equals(AttributeOrigin.PROPERTY)
         || (exportDynamic
             && col.getOrigin().equals(AttributeOrigin.PROPERTY)
             && col.getIndex() == PropertiesColumn.EDGE_WEIGHT.getIndex())) {
       AttributeType type = col.getType();
       if (type.isDynamicType()) {
         DynamicType dynamicValue = (DynamicType) val.getValue();
         if (dynamicValue != null && visibleInterval != null && exportDynamic) {
           List<Interval<?>> intervals =
               dynamicValue.getIntervals(visibleInterval.getLow(), visibleInterval.getHigh());
           for (Interval<?> interval : intervals) {
             Object value = interval.getValue();
             if (value != null) {
               xmlWriter.writeStartElement(ATTVALUE);
               xmlWriter.writeAttribute(ATTVALUE_FOR, col.getId());
               xmlWriter.writeAttribute(ATTVALUE_VALUE, value.toString());
               if (!Double.isInfinite(interval.getLow())) {
                 String intervalLow = formatTime(interval.getLow());
                 xmlWriter.writeAttribute(
                     interval.isLowExcluded() ? START_OPEN : START, intervalLow);
               }
               if (!Double.isInfinite(interval.getHigh())) {
                 String intervalHigh = formatTime(interval.getHigh());
                 xmlWriter.writeAttribute(
                     interval.isHighExcluded() ? END_OPEN : END, intervalHigh);
               }
               xmlWriter.writeEndElement();
             }
           }
         } else if (dynamicValue != null) {
           TimeInterval interval = visibleInterval;
           if (interval == null) {
             interval = new TimeInterval();
           }
           Object value =
               DynamicUtilities.getDynamicValue(
                   dynamicValue, interval.getLow(), interval.getHigh());
           if (value != null) {
             xmlWriter.writeStartElement(ATTVALUE);
             xmlWriter.writeAttribute(ATTVALUE_FOR, val.getColumn().getId());
             xmlWriter.writeAttribute(ATTVALUE_VALUE, value.toString());
             xmlWriter.writeEndElement();
           }
         }
       } else {
         if (val.getValue() != null) {
           xmlWriter.writeStartElement(ATTVALUE);
           xmlWriter.writeAttribute(ATTVALUE_FOR, col.getId());
           xmlWriter.writeAttribute(ATTVALUE_VALUE, val.getValue().toString());
           xmlWriter.writeEndElement();
         }
       }
     }
   }
   xmlWriter.writeEndElement();
 }