Beispiel #1
0
  private void calculateAndWriteVertex(
      int sizeX, int sizeY, GraphicLayoutInfo graphicLayoutInfo, GraphVertex vertex) {

    Position position = graphicLayoutInfo.mapToOriginal(vertex.getPosition());

    // Determine color for vertex.
    Color color = vertex.getColor();
    if (options.getOption(OptionsEnum.depDegreeColor).getBool()) {
      float redValue = vertex.getDegreeOut() / graph.getMaxOutdegree();
      color = new Color(redValue, 1 - redValue, 0);
    }

    if (vertex.getShape() == Shape.FIXED_SIZE_BOX) {
      int radius = 2;
      writeVertex(vertex, (int) position.x, (int) position.y, (int) position.z, radius, color);

    } else if (vertex.getShape() == Shape.FILLER_RECT) {
      int width = Math.max(1, Math.round(sizeX / graphicLayoutInfo.getWidth()));
      int height = Math.max(1, Math.round(sizeY / graphicLayoutInfo.getHeight()));
      writeVertex(
          vertex, (int) position.x, (int) position.y, (int) position.z, width, height, color);

    } else {
      int radius = calculateVertexRadius(vertex.getDegree());
      writeVertex(vertex, (int) position.x, (int) position.y, (int) position.z, radius, color);
    }
  }
Beispiel #2
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);
      }
    }
  }