protected void paintVerticalPartOfLeg()

in flutter-idea/src/io/flutter/view/InspectorTreeUI.java [329:421]


  protected void paintVerticalPartOfLeg(final Graphics g, final Rectangle clipBounds, final Insets insets, final TreePath path) {
    final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    if (node.getChildCount() < 2) {
      // We could draw lines for nodes with a single child but we omit them
      // to more of an emphasis of lines for nodes with multiple children.
      return;
    }
    final DiagnosticsNode diagnostic = maybeGetDiagnostic(node);
    if (diagnostic != null && !diagnostic.hasChildren()) {
      // This avoids drawing lines for nodes with only property children.
      return;
    }

    final int depth = path.getPathCount() - 1;
    if (depth == 0 && !getShowsRootHandles() && !isRootVisible()) {
      return;
    }

    int lineX = getRowX(-1, depth);
    if (leftToRight) {
      lineX = lineX - getRightChildIndent() + insets.left;
    }
    else {
      lineX = tree.getWidth() - lineX - insets.right +
              getRightChildIndent() - 1;
    }
    final int clipLeft = clipBounds.x;
    final int clipRight = clipBounds.x + (clipBounds.width - 1);

    if (lineX >= clipLeft && lineX <= clipRight) {
      final int clipTop = clipBounds.y;
      final int clipBottom = clipBounds.y + clipBounds.height;
      Rectangle parentBounds = getPathBounds(tree, path);
      boolean previousDashed = false;

      int top;
      if (parentBounds == null) {
        top = Math.max(insets.top + getVerticalLegBuffer(),
                       clipTop);
      }
      else {
        top = Math.max(parentBounds.y + parentBounds.height +
                       getVerticalLegBuffer(), clipTop);
      }

      if (depth == 0 && !isRootVisible()) {
        final TreeModel model = getModel();

        if (model != null) {
          final Object root = model.getRoot();

          if (model.getChildCount(root) > 0) {
            parentBounds = getPathBounds(tree, path.
              pathByAddingChild(model.getChild(root, 0)));
            if (parentBounds != null) {
              top = Math.max(insets.top + getVerticalLegBuffer(),
                             parentBounds.y +
                             parentBounds.height / 2);
            }
          }
        }
      }

      for (int i = 0; i < node.getChildCount(); ++i) {
        final DefaultMutableTreeNode child = (DefaultMutableTreeNode)node.getChildAt(i);
        final DiagnosticsNode childDiagnostic = maybeGetDiagnostic(child);
        boolean dashed = false;
        if (childDiagnostic != null) {
          dashed = childDiagnostic.getStyle() == DiagnosticsTreeStyle.offstage;
        }

        final Rectangle childBounds = getPathBounds(tree, path.pathByAddingChild(child));
        if (childBounds == null)
        // This shouldn't happen, but if the model is modified
        // in another thread it is possible for this to happen.
        // Swing isn't multithreaded, but I'll add this check in
        // anyway.
        {
          continue;
        }

        final int bottom = Math.min(childBounds.y +
                                    (childBounds.height / 2), clipBottom);

        if (top <= bottom && bottom >= clipTop && top <= clipBottom) {
          g.setColor(JBColor.GRAY);
          paintVerticalLine(g, tree, lineX, top, bottom, dashed);
        }
        top = bottom;
        previousDashed = dashed;
      }
    }
  }