Java Code Examples for javax.swing.plaf.basic.BasicTreeUI#getLeftChildIndent()
The following examples show how to use
javax.swing.plaf.basic.BasicTreeUI#getLeftChildIndent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeTable.java From netbeans with Apache License 2.0 | 6 votes |
private boolean isLocationInExpandControl( TreePath path, Point location ) { if( tree.getModel().isLeaf( path.getLastPathComponent() ) ) return false; Rectangle r = tree.getPathBounds(path); int boxWidth = 8; Insets i = tree.getInsets(); int indent = 0; if( tree.getUI() instanceof BasicTreeUI ) { BasicTreeUI ui = (BasicTreeUI)tree.getUI(); if( null != ui.getExpandedIcon() ) boxWidth = ui.getExpandedIcon().getIconWidth(); indent = ui.getLeftChildIndent(); } int boxX; if( tree.getComponentOrientation().isLeftToRight() ) { boxX = r.x - positionX - indent - boxWidth; } else { boxX = r.x - positionX + indent + r.width; } return location.getX() >= boxX && location.getX() <= (boxX + boxWidth); }
Example 2
Source File: TreeUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static Range<Integer> getExpandControlRange(@Nonnull final JTree aTree, @Nullable final TreePath path) { TreeModel treeModel = aTree.getModel(); final BasicTreeUI basicTreeUI = (BasicTreeUI)aTree.getUI(); Icon expandedIcon = basicTreeUI.getExpandedIcon(); Range<Integer> box = null; if (path != null && !treeModel.isLeaf(path.getLastPathComponent())) { int boxWidth; Insets i = aTree.getInsets(); boxWidth = expandedIcon != null ? expandedIcon.getIconWidth() : 8; int boxLeftX = i != null ? i.left : 0; boolean leftToRight = aTree.getComponentOrientation().isLeftToRight(); int depthOffset = getDepthOffset(aTree); int totalChildIndent = basicTreeUI.getLeftChildIndent() + basicTreeUI.getRightChildIndent(); if (leftToRight) { boxLeftX += (path.getPathCount() + depthOffset - 2) * totalChildIndent + basicTreeUI.getLeftChildIndent() - boxWidth / 2; } int boxRightX = boxLeftX + boxWidth; box = new Range<>(boxLeftX, boxRightX); } return box; }
Example 3
Source File: CommittedChangeListRenderer.java From consulo with Apache License 2.0 | 5 votes |
public static int getRowX(JTree tree, int depth) { if (tree == null) return 0; final TreeUI ui = tree.getUI(); if (ui instanceof BasicTreeUI) { final BasicTreeUI treeUI = ((BasicTreeUI)ui); return (treeUI.getLeftChildIndent() + treeUI.getRightChildIndent()) * depth; } final int leftIndent = UIUtil.getTreeLeftChildIndent(); final int rightIndent = UIUtil.getTreeRightChildIndent(); return (leftIndent + rightIndent) * depth; }