Java Code Examples for javax.swing.plaf.basic.BasicTreeUI

The following examples show how to use javax.swing.plaf.basic.BasicTreeUI. These examples are extracted from open source projects. 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 Project: netbeans   Source File: BeanTreeView.java    License: Apache License 2.0 6 votes vote down vote up
/** Make a path visible.
* @param path the path
*/
private void showPathWithoutExpansion(TreePath path) {
    Rectangle rect = tree.getPathBounds(path);
    if (rect != null) { //PENDING
        TreeUI tmp = tree.getUI();
        int correction = 0;
        if (tmp instanceof BasicTreeUI) {
            correction = ((BasicTreeUI) tmp).getLeftChildIndent();
            correction += ((BasicTreeUI) tmp).getRightChildIndent();
        }
        rect.x = Math.max(0, rect.x - correction);
        if (rect.y >= 0) { //#197514 - do not scroll to negative y values
            tree.scrollRectToVisible(rect);
        }
    }
}
 
Example 2
Source Project: netbeans   Source File: TreeTable.java    License: Apache License 2.0 6 votes vote down vote up
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 3
Source Project: netbeans   Source File: TemplatesPanelGUI.java    License: Apache License 2.0 6 votes vote down vote up
/** Make a path visible.
* @param path the path
*/
private void showPathWithoutExpansion(TreePath path) {
    Rectangle rect = tree.getPathBounds(path);
    if (rect != null) { //PENDING
        TreeUI tmp = tree.getUI();
        int correction = 0;
        if (tmp instanceof BasicTreeUI) {
            correction = ((BasicTreeUI) tmp).getLeftChildIndent();
            correction += ((BasicTreeUI) tmp).getRightChildIndent();
        }
        rect.x = Math.max(0, rect.x - correction);
        rect.y += rect.height;
        if (rect.y >= 0) { //#197514 - do not scroll to negative y values
            tree.scrollRectToVisible(rect);
        }
    }
}
 
Example 4
public InspectorTree(final DefaultMutableTreeNode treemodel,
                     String treeName,
                     boolean detailsSubtree,
                     String parentTreeName,
                     boolean rootVisible,
                     boolean legacyMode,
                     Disposable parentDisposable) {
  super(treemodel);
  setUI(new InspectorTreeUI());
  final BasicTreeUI ui = (BasicTreeUI)getUI();
  this.detailsSubtree = detailsSubtree;

  setRootVisible(rootVisible);
  getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  registerShortcuts(parentDisposable);
  if (detailsSubtree) {
    // TODO(devoncarew): This empty text is not showing up for the details area, even when there are no detail nodes.
    getEmptyText().setText(treeName + " subtree of the selected " + parentTreeName);
  }
  else {
    getEmptyText().setText(treeName + " tree for the running app");
  }
}
 
Example 5
public InspectorTree(final DefaultMutableTreeNode treemodel,
                     String treeName,
                     boolean detailsSubtree,
                     String parentTreeName,
                     boolean rootVisible,
                     boolean legacyMode,
                     Disposable parentDisposable) {
  super(treemodel);
  setUI(new InspectorTreeUI());
  final BasicTreeUI ui = (BasicTreeUI)getUI();
  this.detailsSubtree = detailsSubtree;

  setRootVisible(rootVisible);
  getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  registerShortcuts(parentDisposable);
  if (detailsSubtree) {
    // TODO(devoncarew): This empty text is not showing up for the details area, even when there are no detail nodes.
    getEmptyText().setText(treeName + " subtree of the selected " + parentTreeName);
  }
  else {
    getEmptyText().setText(treeName + " tree for the running app");
  }
}
 
Example 6
Source Project: FlatLaf   Source File: FlatTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyChangeListener createPropertyChangeListener() {
	if( !wideSelection )
		return super.createPropertyChangeListener();

	return new BasicTreeUI.PropertyChangeHandler() {
		@Override
		public void propertyChange( PropertyChangeEvent e ) {
			super.propertyChange( e );

			if( e.getSource() == tree && e.getPropertyName() == "dropLocation" ) {
				JTree.DropLocation oldValue = (JTree.DropLocation) e.getOldValue();
				repaintWideDropLocation( oldValue );
				repaintWideDropLocation( tree.getDropLocation() );
			}
		}

		private void repaintWideDropLocation(JTree.DropLocation loc) {
			if( loc == null || isDropLine( loc ) )
				return;

			Rectangle r = tree.getPathBounds( loc.getPath() );
			if( r != null )
				tree.repaint( 0, r.y, tree.getWidth(), r.height );
		}
	};
}
 
Example 7
Source Project: dragonwell8_jdk   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 8
Source Project: TencentKona-8   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 9
Source Project: jdk8u60   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 10
Source Project: openjdk-jdk8u   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 11
Source Project: netbeans   Source File: ProfilerTreeTable.java    License: Apache License 2.0 5 votes vote down vote up
public void setUI(TreeUI ui) {
            if (ui instanceof SynthTreeUI) {
//                if (synthLikeUI == null) {
                    super.setUI(ui);
                    SynthTreeUI synthUI = (SynthTreeUI)ui;
                    int left = synthUI.getLeftChildIndent();
                    int right = synthUI.getRightChildIndent();

                    synthLikeUI = new SynthLikeTreeUI();
                    super.setUI(synthLikeUI);

                    boolean nimbus = UIUtils.isNimbusLookAndFeel();
                    synthLikeUI.setLeftChildIndent(left + (nimbus ? 4 : 6));
                    synthLikeUI.setRightChildIndent(right);
//                } else {
//                    super.setUI(synthLikeUI);
//                }
            } else {
                synthLikeUI = null;
                
                super.setUI(ui);
                
                // #269500 - performance workaround for BasicTreeUI
                if (!DISABLE_TREEUI_FIX && ui instanceof BasicTreeUI)
                    workaroundVerticalLines = UIManager.getBoolean("Tree.paintLines"); // NOI18N
            }
        }
 
Example 12
Source Project: netbeans   Source File: JTreeTable.java    License: Apache License 2.0 5 votes vote down vote up
private void setTreeUIVariables() {
    if (tree.getUI() instanceof BasicTreeUI) {
        BasicTreeUI treeUI = (BasicTreeUI) tree.getUI();
        treeSignExtent = treeUI.getExpandedIcon().getIconWidth() / 2;
        treeSignRightMargin = treeUI.getRightChildIndent();
    }
}
 
Example 13
Source Project: netbeans   Source File: DebugTreeView.java    License: Apache License 2.0 5 votes vote down vote up
private static void clearDrawingCache(JTree tree) {
   TreeUI tui = tree.getUI();
   if (tui instanceof BasicTreeUI) {
       try {
           Field drawingCacheField = BasicTreeUI.class.getDeclaredField("drawingCache");
           drawingCacheField.setAccessible(true);
           Map table = (Map) drawingCacheField.get(tui);
           table.clear();
       } catch (Exception ex) {}
   }
}
 
Example 14
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 15
Source Project: openjdk-jdk9   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 16
Source Project: jdk8u-jdk   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 17
Source Project: hottub   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 18
Source Project: openjdk-8-source   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 19
Source Project: visualvm   Source File: ProfilerTreeTable.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void setUI(TreeUI ui) {
            if (ui instanceof SynthTreeUI) {
//                if (synthLikeUI == null) {
                    super.setUI(ui);
                    SynthTreeUI synthUI = (SynthTreeUI)ui;
                    int left = synthUI.getLeftChildIndent();
                    int right = synthUI.getRightChildIndent();

                    synthLikeUI = new SynthLikeTreeUI();
                    super.setUI(synthLikeUI);

                    boolean nimbus = UIUtils.isNimbusLookAndFeel();
                    synthLikeUI.setLeftChildIndent(left + (nimbus ? 4 : 6));
                    synthLikeUI.setRightChildIndent(right);
//                } else {
//                    super.setUI(synthLikeUI);
//                }
            } else {
                synthLikeUI = null;
                
                super.setUI(ui);
                
                // #269500 - performance workaround for BasicTreeUI
                if (!DISABLE_TREEUI_FIX && ui instanceof BasicTreeUI)
                    workaroundVerticalLines = UIManager.getBoolean("Tree.paintLines"); // NOI18N
            }
        }
 
Example 20
Source Project: visualvm   Source File: JTreeTable.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void setTreeUIVariables() {
    if (tree.getUI() instanceof BasicTreeUI) {
        BasicTreeUI treeUI = (BasicTreeUI) tree.getUI();
        treeSignExtent = treeUI.getExpandedIcon().getIconWidth() / 2;
        treeSignRightMargin = treeUI.getRightChildIndent();
    }
}
 
Example 21
Source Project: openjdk-8   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 22
Source Project: jdk8u_jdk   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 23
Source Project: jdk8u-jdk   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 24
Source Project: jdk8u-dev-jdk   Source File: bug8003830.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNPEAtActionsPage() {
    JTree tree = new JTree();
    BasicTreeUI ui = new NullReturningTreeUI();
    tree.setUI(ui);
    BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
    tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
 
Example 25
public MyTree() {
    setBackground(Color.white);
    setUI(new BasicTreeUI() {
        @Override
        public void paint(Graphics g, JComponent c) {
            setHashColor(Color.gray);
            super.paint(g, c);
        }
    });
    setCellRenderer(new MyTreeCellRenderer());
    setCellEditor(new MyTreeCellEditor(this));
    setInvokesStopCellEditing(true);

}
 
Example 26
Source Project: jpexs-decompiler   Source File: TagTree.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TagTree(TagTreeModel treeModel, MainPanel mainPanel) {
    super(treeModel);
    this.mainPanel = mainPanel;
    setCellRenderer(new TagTreeCellRenderer());
    setRootVisible(false);
    setBackground(Color.white);
    setRowHeight(Math.max(getFont().getSize() + 5, 16));
    setLargeModel(true);
    setUI(new BasicTreeUI() {
        {
            setHashColor(Color.gray);
        }
    });
}
 
Example 27
Source Project: jpexs-decompiler   Source File: DumpTree.java    License: GNU General Public License v3.0 5 votes vote down vote up
public DumpTree(DumpTreeModel treeModel, MainPanel mainPanel) {
    super(treeModel);
    this.mainPanel = mainPanel;
    setCellRenderer(new DumpTreeCellRenderer());
    setRootVisible(false);
    setBackground(Color.white);
    setUI(new BasicTreeUI() {
        {
            setHashColor(Color.gray);
        }
    });
}
 
Example 28
public MyTreeTableCellRenderer(MyTreeTable treeTable, TreeModel model) {
    super(model);
    setUI(new BasicTreeUI());

    this.treeTable = treeTable;

    // Setzen der Zeilenhoehe fuer die JTable
    // Muss explizit aufgerufen werden, weil treeTable noch
    // null ist, wenn super(model) setRowHeight aufruft!
    setRowHeight(getRowHeight());
}
 
Example 29
Source Project: consulo   Source File: UsageViewImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void clearRendererCache() {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (myExpandingCollapsing) return; // to avoid quadratic row enumeration
  // clear renderer cache of node preferred size
  TreeUI ui = myTree.getUI();
  if (ui instanceof BasicTreeUI) {
    AbstractLayoutCache treeState = ReflectionUtil.getField(BasicTreeUI.class, ui, AbstractLayoutCache.class, "treeState");
    Rectangle visibleRect = myTree.getVisibleRect();
    int rowForLocation = myTree.getClosestRowForLocation(0, visibleRect.y);
    int visibleRowCount = getVisibleRowCount();
    List<Node> toUpdate = new ArrayList<>();
    for (int i = rowForLocation + visibleRowCount + 1; i >= rowForLocation; i--) {
      final TreePath eachPath = myTree.getPathForRow(i);
      if (eachPath == null) continue;

      treeState.invalidatePathBounds(eachPath);
      Object node = eachPath.getLastPathComponent();
      if (node instanceof UsageNode) {
        toUpdate.add((Node)node);
      }
    }
    queueUpdateBulk(toUpdate, () -> {
      if (!isDisposed()) {
        myTree.repaint(visibleRect);
      }
    });
  }
  else {
    myTree.setCellRenderer(myUsageViewTreeCellRenderer);
  }
}
 
Example 30
Source Project: consulo   Source File: SimpleTree.java    License: Apache License 2.0 5 votes vote down vote up
private static int getBoxWidth(JTree tree) {
  BasicTreeUI basicTreeUI = (BasicTreeUI)tree.getUI();
  int boxWidth;
  if (basicTreeUI.getExpandedIcon() != null) {
    boxWidth = basicTreeUI.getExpandedIcon().getIconWidth();
  }
  else {
    boxWidth = 8;
  }
  return boxWidth;
}