public void updateWorld() {
    // System.out.println("update world");
    cacheMarker++;

    GraphModel graphModel = controller.getModel();
    if (graphModel == null) {
      engine.worldUpdated(cacheMarker);
      return;
    }
    if (gm != null && gm != graphModel) {
      reset();
    }
    gm = graphModel;
    HierarchicalGraph graph;
    if (graphModel.isDirected()) {
      undirected = false;
      graph = graphModel.getHierarchicalDirectedGraphVisible();
    } else if (graphModel.isUndirected()) {
      undirected = true;
      graph = graphModel.getHierarchicalUndirectedGraphVisible();
    } else if (graphModel.isMixed()) {
      undirected = false;
      graph = graphModel.getHierarchicalMixedGraphVisible();
    } else {
      undirected = false;
      graph = graphModel.getHierarchicalDirectedGraphVisible();
    }

    if (dynamicModel == null) {
      DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
      dynamicModel = dynamicController.getModel();
    }

    graphView = graph.getView().getViewId();

    ModelClass[] object3dClasses = engine.getModelClasses();

    graph.readLock();

    ModelClass nodeClass = object3dClasses[AbstractEngine.CLASS_NODE];
    if (nodeClass.isEnabled()
        && (graph.getNodeVersion() > nodeVersion || modeManager.requireModeChange())) {
      updateNodes(graph);
      nodeClass.setCacheMarker(cacheMarker);
    }

    ModelClass edgeClass = object3dClasses[AbstractEngine.CLASS_EDGE];
    if (edgeClass.isEnabled()
        && (graph.getEdgeVersion() > edgeVersion || modeManager.requireModeChange())) {
      updateEdges(graph);
      updateMetaEdges(graph);
      edgeClass.setCacheMarker(cacheMarker);
      if (!undirected && vizConfig.isShowArrows()) {
        object3dClasses[AbstractEngine.CLASS_ARROW].setCacheMarker(cacheMarker);
      }
    }

    ModelClass potatoClass = object3dClasses[AbstractEngine.CLASS_POTATO];
    if (potatoClass.isEnabled()
        && (graph.getNodeVersion() > nodeVersion || modeManager.requireModeChange())) {
      updatePotatoes(graph);
      potatoClass.setCacheMarker(cacheMarker);
    }

    nodeVersion = graph.getNodeVersion();
    edgeVersion = graph.getEdgeVersion();

    graph.readUnlock();

    engine.worldUpdated(cacheMarker);
  }
  private void writeEdges(XMLStreamWriter xmlWriter, HierarchicalGraph graph) throws Exception {
    if (cancel) {
      return;
    }
    xmlWriter.writeStartElement(EDGES);

    AttributeColumn dynamicCol =
        dynamicCol = attributeModel.getEdgeTable().getColumn(DynamicModel.TIMEINTERVAL_COLUMN);

    EdgeIterable edgeIterable =
        exportHierarchy ? graph.getEdgesTree() : graph.getEdgesAndMetaEdges();
    for (Edge edge : edgeIterable) {
      xmlWriter.writeStartElement(EDGE);

      if (edge.getEdgeData().getId() != null
          && !edge.getEdgeData().getId().equals(Integer.toString(edge.getId()))) {
        xmlWriter.writeAttribute(EDGE_ID, edge.getEdgeData().getId());
      }
      xmlWriter.writeAttribute(EDGE_SOURCE, edge.getSource().getNodeData().getId());
      xmlWriter.writeAttribute(EDGE_TARGET, edge.getTarget().getNodeData().getId());

      if (edge.isDirected() && graphModel.isMixed()) {
        xmlWriter.writeAttribute(EDGE_TYPE, "directed");
      } else if (!edge.isDirected() && graphModel.isMixed()) {
        xmlWriter.writeAttribute(EDGE_TYPE, "undirected");
      }

      String label = edge.getEdgeData().getLabel();
      if (label != null && !label.isEmpty()) {
        xmlWriter.writeAttribute(EDGE_LABEL, label);
      }

      float weight = edge.getWeight();
      if (weight != 1f) {
        xmlWriter.writeAttribute(EDGE_WEIGHT, "" + weight);
      }

      if (exportDynamic && dynamicCol != null && visibleInterval != null) {
        TimeInterval timeInterval =
            (TimeInterval) edge.getEdgeData().getAttributes().getValue(dynamicCol.getIndex());
        if (timeInterval != null) {
          writeTimeInterval(xmlWriter, timeInterval);
        }
      }

      if (exportColors) {
        writeEdgeColor(xmlWriter, edge);
      }

      if (exportAttributes && edge.getEdgeData().getAttributes() != null) {
        AttributeRow attributeRow = (AttributeRow) edge.getEdgeData().getAttributes();
        writeAttValues(xmlWriter, attributeRow, visibleInterval);
      }

      xmlWriter.writeEndElement();
      Progress.progress(progress);
      if (cancel) {
        break;
      }
    }

    xmlWriter.writeEndElement();
  }