Esempio n. 1
0
  private void renderTreeHelper(XML xml, int[] widths, int depth, int[] ltor) {
    float x = (g.width / widths[depth]) * (0.5f + ltor[depth]++);
    float y = (g.height / widths.length) * (0.5f + depth);
    xml.setFloat("x", x);
    xml.setFloat("y", y);
    if (xml.getParent() != null)
      g.line(
          xml.getParent().getFloat("x"),
          xml.getParent().getFloat("y") + RECT_HEIGHT / 2,
          x,
          y - RECT_HEIGHT / 2);
    if (xml.hasAttribute("altColor")) {
      String hexColor = xml.getString("altColor");
      g.fill(
          getColorComponent(hexColor, 0),
          getColorComponent(hexColor, 1),
          getColorComponent(hexColor, 2));
    }
    g.rect(x, y, RECT_WIDTH, RECT_HEIGHT, 4);
    g.fill(0);
    if (xml.hasAttribute("altName"))
      g.text(xml.getString("altName"), x, y, RECT_WIDTH, RECT_HEIGHT);
    else g.text(xml.getName(), x, y, RECT_WIDTH, RECT_HEIGHT);
    g.fill(255);

    XML[] children = xml.getChildren();
    for (int i = 0; i < children.length; i++)
      renderTreeHelper(children[i], widths, depth + 1, ltor);
  }