Example #1
0
  public void writeGraphicsLayout(
      List<GraphVertex> vertices, List<GraphEdge> edges, Dimension size) {

    GraphicLayoutInfo graphicLayoutInfo = calculateOffsetAndScale(size);
    int sizeX = (int) size.getWidth();
    int sizeY = (int) size.getHeight();

    // Draw the edges.
    for (GraphEdge edge : edges) {
      if (options.getOption(OptionsEnum.showEdges).getBool() || edge.showEdge()) {
        // Only draw the edge if it and both of its incident vertices are visible
        if ((edge.getSource().isShowVertex() || edge.getTarget().isShowVertex())
            && !edge.isAuxiliaryEdge()) {
          Position sourcePos = graphicLayoutInfo.mapToOriginal(edge.getSource().getPosition());
          Position targetPos = graphicLayoutInfo.mapToOriginal(edge.getTarget().getPosition());

          writeEdge(
              edge,
              (int) sourcePos.x,
              (int) sourcePos.y,
              (int) sourcePos.z,
              (int) targetPos.x,
              (int) targetPos.y,
              (int) targetPos.z);
        }
      }
    }

    // Draw the vertices.
    // First draw the vertices that are not annotated (put them to background).
    for (GraphVertex vertex : vertices) {
      if (vertex.isShowVertex()
          && !(options.getOption(OptionsEnum.hideSource).getBool() && vertex.isSource())
          && !vertex.isAuxiliary()
          && !vertex.isShowName()) {

        calculateAndWriteVertex(sizeX, sizeY, graphicLayoutInfo, vertex);
      }
    }

    // Draw the annotated vertices.
    // Second draw the annotated vertices (put them to foreground).
    for (GraphVertex vertex : vertices) {
      if (vertex.isShowVertex()
          && !(options.getOption(OptionsEnum.hideSource).getBool() && vertex.isSource())
          && !vertex.isAuxiliary()
          && vertex.isShowName()) {

        calculateAndWriteVertex(sizeX, sizeY, graphicLayoutInfo, vertex);
      }
    }
  }