Пример #1
0
  /**
   * Render cells, starting at specified item.
   *
   * @param graphics
   * @param treemap
   * @param item
   * @param active
   */
  public void renderTree(TreemapGraphics graphics, Treemap treemap, Object item, boolean active) {
    TreemapCell cell = treemap.getCell(item);
    if (cell == null) {
      return;
    }
    boolean visible = cell.isLeaf() || cell.getFramed() != null;
    Object value = cell.getValue();

    if (active) {
      if (visible) {
        graphics.fill(cell, colorProvider.getHighlightColor(item, value));
      }
    } else {
      Rectangle borders = cell.getBorders();
      if (borders != null) {
        graphics.fill(borders, colorProvider.getBorderColor(item, value));
      }
      if (visible) {
        Color color1 = colorProvider.getBackgroundColor(item, value);
        Color color2 = colorProvider.getBackgroundGradientColor(item, value);
        graphics.fill(cell, color1, color2);
      }
    }
    if (!cell.isLeaf()) {
      Rectangle framed = cell.getFramed();
      if (framed != null) {
        graphics.fill(framed, colorProvider.getBorderColor(item, value));
      }
      for (Object node : cell.getChildren()) {
        renderTree(graphics, treemap, node, false);
      }
    }
  }