void (Graphics g) { if (!(getUI() instanceof BasicTreeUI)) return; AbstractTreeBuilder builder = AbstractTreeBuilder.getBuilderFor(this); if (builder == null || builder.isDisposed()) return; GraphicsConfig config = new GraphicsConfig(g); config.setAntialiasing(true); AbstractTreeStructure structure = builder.getTreeStructure(); for (int eachRow = 0; eachRow < getRowCount(); eachRow++) { TreePath path = getPathForRow(eachRow); PresentableNodeDescriptor<?> node = TreeUtil.getLastUserObject(PresentableNodeDescriptor.class, path); if (node == null) continue; if (!node.isContentHighlighted()) continue; if (highlightSingleNode()) { if (node.isContentHighlighted()) { TreePath nodePath = getPath(node); Rectangle rect; Rectangle parentRect = getPathBounds(nodePath); if (isExpanded(nodePath)) { int[] max = getMax(node, structure); rect = new Rectangle(parentRect.x, parentRect.y, Math.max((int)parentRect.getMaxX(), max[1]) - parentRect.x - 1, Math.max((int)parentRect.getMaxY(), max[0]) - parentRect.y - 1); } else { rect = parentRect; } if (rect != null) { Color highlightColor = node.getHighlightColor(); g.setColor(highlightColor); g.fillRoundRect(rect.x, rect.y, rect.width, rect.height, 4, 4); g.setColor(highlightColor.darker()); g.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 4, 4); } } } else { //todo: to investigate why it might happen under 1.6: http://www.productiveme.net:8080/browse/PM-217 if (node.getParentDescriptor() == null) continue; Object[] kids = structure.getChildElements(node); if (kids.length == 0) continue; PresentableNodeDescriptor first = null; PresentableNodeDescriptor last = null; int lastIndex = -1; for (int i = 0; i < kids.length; i++) { Object kid = kids[i]; if (kid instanceof PresentableNodeDescriptor eachKid) { if (!node.isHighlightableContentNode(eachKid)) continue; if (first == null) { first = eachKid; } last = eachKid; lastIndex = i; } } if (first == null) continue; Rectangle firstBounds = getPathBounds(getPath(first)); if (isExpanded(getPath(last))) { if (lastIndex + 1 < kids.length) { Object child = kids[lastIndex + 1]; if (child instanceof PresentableNodeDescriptor nextKid) { int nextRow = getRowForPath(getPath(nextKid)); last = TreeUtil.getLastUserObject(PresentableNodeDescriptor.class, getPathForRow(nextRow - 1)); } } else { NodeDescriptor parentNode = node.getParentDescriptor(); if (parentNode instanceof PresentableNodeDescriptor ppd) { int nodeIndex = node.getIndex(); if (nodeIndex + 1 < structure.getChildElements(ppd).length) { PresentableNodeDescriptor nextChild = ppd.getChildToHighlightAt(nodeIndex + 1); int nextRow = getRowForPath(getPath(nextChild)); TreePath prevPath = getPathForRow(nextRow - 1); if (prevPath != null) { last = TreeUtil.getLastUserObject(PresentableNodeDescriptor.class, prevPath); } } else { int lastRow = getRowForPath(getPath(last)); PresentableNodeDescriptor lastParent = last; boolean lastWasFound = false; for (int i = lastRow + 1; i < getRowCount(); i++) { PresentableNodeDescriptor<?> eachNode = TreeUtil.getLastUserObject(PresentableNodeDescriptor.class, getPathForRow(i)); if (!node.isParentOf(eachNode)) { last = lastParent; lastWasFound = true; break; } lastParent = eachNode; } if (!lastWasFound) { last = TreeUtil.getLastUserObject(PresentableNodeDescriptor.class, getPathForRow(getRowCount() - 1)); } } } } } if (last == null) continue; Rectangle lastBounds = getPathBounds(getPath(last)); if (firstBounds == null || lastBounds == null) continue; Rectangle toPaint = new Rectangle(firstBounds.x, firstBounds.y, 0, (int)lastBounds.getMaxY() - firstBounds.y - 1); toPaint.width = getWidth() - toPaint.x - 4; Color highlightColor = first.getHighlightColor(); g.setColor(highlightColor); g.fillRoundRect(toPaint.x, toPaint.y, toPaint.width, toPaint.height, 4, 4); g.setColor(highlightColor.darker()); g.drawRoundRect(toPaint.x, toPaint.y, toPaint.width, toPaint.height, 4, 4); } } config.restore(); }