コード例 #1
0
  private void writeGraph(XMLStreamWriter xmlWriter, HierarchicalGraph graph) throws Exception {
    xmlWriter.writeStartElement(GRAPH);
    xmlWriter.writeAttribute(
        GRAPH_DEFAULT_EDGETYPE,
        graph instanceof DirectedGraph
            ? "directed"
            : graph instanceof UndirectedGraph ? "undirected" : "mixed");

    if (exportDynamic) {
      if (!Double.isInfinite(visibleInterval.getLow())) {
        String intervalLow = formatTime(visibleInterval.getLow());
        xmlWriter.writeAttribute(GRAPH_START, intervalLow);
      }
      if (!Double.isInfinite(visibleInterval.getHigh())) {
        String intervalHigh = formatTime(visibleInterval.getHigh());
        xmlWriter.writeAttribute(GRAPH_END, intervalHigh);
      }
      String timeFormat =
          dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DATE) ? "date" : "double";
      xmlWriter.writeAttribute(GRAPH_TIMEFORMAT, timeFormat);
    }
    xmlWriter.writeAttribute(GRAPH_MODE, exportDynamic ? "dynamic" : "static");

    writeAttributes(xmlWriter, attributeModel.getNodeTable());
    writeAttributes(xmlWriter, attributeModel.getEdgeTable());
    writeNodes(xmlWriter, graph);
    writeEdges(xmlWriter, graph);

    xmlWriter.writeEndElement();
  }
コード例 #2
0
 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);
     }
   }
 }
コード例 #3
0
  private void updateEdges(HierarchicalGraph graph) {
    Modeler edgeInit = engine.getModelClasses()[AbstractEngine.CLASS_EDGE].getCurrentModeler();
    Modeler arrowInit = engine.getModelClasses()[AbstractEngine.CLASS_ARROW].getCurrentModeler();

    EdgeIterable edgeIterable;
    edgeIterable = graph.getEdges();

    float minWeight = Float.POSITIVE_INFINITY;
    float maxWeight = Float.NEGATIVE_INFINITY;

    TimeInterval timeInterval = DynamicUtilities.getVisibleInterval(dynamicModel);

    for (Edge edge : edgeIterable) {
      if (edge.getSource().getNodeData().getModel() == null
          || edge.getTarget().getNodeData().getModel() == null) {
        continue;
      }
      float weight = 1f;
      if (timeInterval == null) {
        weight = edge.getWeight();
      } else {
        weight = edge.getWeight(timeInterval.getLow(), timeInterval.getHigh());
      }
      minWeight = Math.min(minWeight, weight);
      maxWeight = Math.max(maxWeight, weight);
      Edge2dModel obj = (Edge2dModel) edge.getEdgeData().getModel();
      if (obj == null) {
        // Model is null, ADD
        obj = (Edge2dModel) edgeInit.initModel(edge.getEdgeData());
        engine.addObject(AbstractEngine.CLASS_EDGE, obj);
        if (!undirected && vizConfig.isShowArrows() && !edge.isSelfLoop()) {
          Arrow2dModel arrowObj = (Arrow2dModel) arrowInit.initModel(edge.getEdgeData());
          engine.addObject(AbstractEngine.CLASS_ARROW, arrowObj);
          arrowObj.setCacheMarker(cacheMarker);
          arrowObj.setWeight(weight);
          obj.setArrow(arrowObj);
        }
      } else if (!obj.isValid()) {
        engine.addObject(AbstractEngine.CLASS_EDGE, obj);
        if (!undirected && vizConfig.isShowArrows() && !edge.isSelfLoop()) {
          Arrow2dModel arrowObj = obj.getArrow();
          engine.addObject(AbstractEngine.CLASS_ARROW, arrowObj);
          arrowObj.setCacheMarker(cacheMarker);
          arrowObj.setWeight(weight);
        }
      } else {
        if (!undirected && vizConfig.isShowArrows() && !edge.isSelfLoop() && edge.isDirected()) {
          Arrow2dModel arrowObj = obj.getArrow();
          arrowObj.setCacheMarker(cacheMarker);
          arrowObj.setWeight(weight);
        }
      }
      obj.setWeight(weight);
      obj.setCacheMarker(cacheMarker);
    }

    limits.setMinWeight(minWeight);
    limits.setMaxWeight(maxWeight);
  }
コード例 #4
0
 @Override
 public void dynamicModelChanged(DynamicModelEvent event) {
   if (event.getEventType().equals(DynamicModelEvent.EventType.MIN_CHANGED)
       || event.getEventType().equals(DynamicModelEvent.EventType.MAX_CHANGED)) {
     double newMax = event.getSource().getMax();
     double newMin = event.getSource().getMin();
     setMinMax(newMin, newMax);
   } else if (event.getEventType().equals(DynamicModelEvent.EventType.VISIBLE_INTERVAL)) {
     TimeInterval timeInterval = (TimeInterval) event.getData();
     double min = timeInterval.getLow();
     double max = timeInterval.getHigh();
     fireTimelineModelEvent(
         new TimelineModelEvent(
             TimelineModelEvent.EventType.INTERVAL, model, new double[] {min, max}));
   } else if (event.getEventType().equals(DynamicModelEvent.EventType.TIME_FORMAT)) {
   }
 }
コード例 #5
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();
 }