Java Code Examples for javax.swing.tree.DefaultTreeCellRenderer#setLeafIcon()

The following examples show how to use javax.swing.tree.DefaultTreeCellRenderer#setLeafIcon() . 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: MainFrame.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Inits the IR tree.
 */
private void initIRTree() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode(noIndexReposLabel);
  DefaultTreeModel model = new DefaultTreeModel(root);
  this.indexTree = new JTree(model);
  this.indexTree.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
  // Only one node can be selected at any one time.
  this.indexTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.indexTree.addTreeSelectionListener(new IndexTreeSelectionListener(this));
  // No icons.
  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  // cellRenderer.setIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  this.indexTree.setCellRenderer(cellRenderer);
}
 
Example 2
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Inits the FS tree.
 */
private void initFSTree() {
  FSTreeModel treeModel = new FSTreeModel();
  this.fsTree = new JTree(treeModel);
  this.fsTree.addMouseListener(new StringFsPopupEventAdapter());
  this.fsTree.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
  this.fsTree.setLargeModel(true);
  // Only one node can be selected at any one time.
  this.fsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.fsTree.addTreeSelectionListener(new FSTreeSelectionListener(this));
  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  // cellRenderer.setIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  this.fsTree.setCellRenderer(cellRenderer);
}
 
Example 3
Source File: AnnotationFeaturesViewer.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Populate.
 *
 * @param analysisEngine the analysis engine
 * @param aeMetaData the ae meta data
 */
public void populate(AnalysisEngine analysisEngine, AnalysisEngineMetaData aeMetaData) {
  tree = generateTreeView(analysisEngine, aeMetaData);

  tree.setDragEnabled(true); // To allow drag to stylemap table.
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true); // Displays node expansion glyphs.

  TreeSelectionModel selectionModel = tree.getSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  tree.setCellRenderer(cellRenderer);

  scrollPane.getViewport().add(tree, null);
}
 
Example 4
Source File: CTagFilterTree.java    From binnavi with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new filter tree object.
 * 
 * @param tagManager Provides the tags the user can select.
 */
public CTagFilterTree(final ITagManager tagManager) {
  super(new CFilterTreeModel(tagManager.getRootTag()));

  m_tagManager = tagManager;

  setDigIn(false);

  final DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  renderer.setOpenIcon(ICON_CONTAINER_TAG);
  renderer.setClosedIcon(ICON_CONTAINER_TAG);
  renderer.setLeafIcon(ICON_TAG);
  setCellRenderer(renderer);

  setRootVisible(false);
  TreeHelpers.expandAll(this, true);

  tagManager.addListener(m_tagManagerListener);
}
 
Example 5
Source File: AnnotationFeaturesViewer.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Populate.
 *
 * @param analysisEngine the analysis engine
 * @param aeMetaData the ae meta data
 * @param cas the cas
 */
public void populate(AnalysisEngineDescription analysisEngine, AnalysisEngineMetaData aeMetaData,
        CAS cas) {
  tree = generateTreeView(analysisEngine, aeMetaData, cas);

  tree.setDragEnabled(true); // To allow drag to stylemap table.
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true); // Displays node expansion glyphs.

  TreeSelectionModel selectionModel = tree.getSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  tree.setCellRenderer(cellRenderer);

  scrollPane.getViewport().add(tree, null);
}
 
Example 6
Source File: NetworkDisplay.java    From yeti with MIT License 5 votes vote down vote up
private DefaultTreeCellRenderer getPortRenderer(URL image) {
    DefaultTreeCellRenderer portRenderer = new DefaultTreeCellRenderer();
    portRenderer.setLeafIcon(new ImageIcon(image));
    portRenderer.setOpenIcon(new ImageIcon(image));
    portRenderer.setClosedIcon(new ImageIcon(image));

    return portRenderer;
}
 
Example 7
Source File: CodeEditor.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
protected DefaultTreeCellRenderer makeRenderer() {
	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
	renderer.setLeafIcon(null);
	renderer.setOpenIcon(null);
	renderer.setClosedIcon(null);
	return renderer;
}
 
Example 8
Source File: ImageTreePanel.java    From moa with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 * @param chart
 */
public ImageTreePanel(ImageChart chart[]) {
    super(new GridLayout(1, 0));
    this.chart = chart;
    //Create the nodes.
    DefaultMutableTreeNode top
            = new DefaultMutableTreeNode("Images");
    imgPanel = new JPanel();
    imgPanel.setLayout(new GridLayout(1, 0));
    createNodes(top);
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    tree.setSelectionRow(1);

    tree.addTreeSelectionListener(this);
    ImageIcon leafIcon = new ImageIcon("icon/img.png");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer
                = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    }
    imgPanel.updateUI();
    JScrollPane treeView = new JScrollPane(tree);
    treeView.setMinimumSize(new Dimension(100, 50));

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(imgPanel);
    splitPane.setDividerLocation(100);
    splitPane.setPreferredSize(new Dimension(500, 300));
    add(splitPane);

}
 
Example 9
Source File: LayerManagerForm.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private CheckBoxTree createCheckBoxTree(LayerTreeModel treeModel) {

        final CheckBoxTree checkBoxTree = new CheckBoxTree(treeModel) {
            @Override
            public boolean isPathEditable(TreePath path) {
                Layer layer = getLayer(path);
                if (layer != null) {
                    return isLayerNameEditable(layer);
                }
                return false;
            }  
        };
        checkBoxTree.setRootVisible(false);
        checkBoxTree.setShowsRootHandles(true);
        checkBoxTree.setDigIn(false);

        checkBoxTree.setEditable(true);
        checkBoxTree.setDragEnabled(true);
        checkBoxTree.setDropMode(DropMode.ON_OR_INSERT);
        checkBoxTree.setTransferHandler(new LayerTreeTransferHandler(view, checkBoxTree));

        checkBoxTree.getSelectionModel().addTreeSelectionListener(new LayerSelectionListener());

        final CheckBoxTreeSelectionModel checkBoxSelectionModel = checkBoxTree.getCheckBoxTreeSelectionModel();
        checkBoxSelectionModel.addTreeSelectionListener(new CheckBoxTreeSelectionListener());

        final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
        renderer.setLeafIcon(null);
        renderer.setClosedIcon(null);
        renderer.setOpenIcon(null);
        return checkBoxTree;
    }
 
Example 10
Source File: GroupedBandChoosingStrategy.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public JPanel createCheckersPane() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    Map<String, Integer> groupNodeMap = initGrouping(root);
    List<TreePath> selectedPaths = new ArrayList<>();
    addBandCheckBoxes(root, selectedPaths, groupNodeMap);
    addTiePointGridCheckBoxes(root, selectedPaths, groupNodeMap);
    removeEmptyGroups(root, groupNodeMap);

    TreeModel treeModel = new DefaultTreeModel(root);

    checkBoxTree = new CheckBoxTree(treeModel);
    checkBoxTree.getCheckBoxTreeSelectionModel().setSelectionPaths(selectedPaths.toArray(new TreePath[selectedPaths.size()]));
    checkBoxTree.setRootVisible(false);
    checkBoxTree.setShowsRootHandles(true);
    checkBoxTree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            updateCheckBoxStates();
        }
    });
    final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
    renderer.setFont(SMALL_ITALIC_FONT);
    renderer.setLeafIcon(null);
    renderer.setOpenIcon(null);
    renderer.setClosedIcon(null);
    Color color = new Color(240, 240, 240);
    checkBoxTree.setBackground(color);
    renderer.setBackgroundSelectionColor(color);
    renderer.setBackgroundNonSelectionColor(color);
    renderer.setBorderSelectionColor(color);
    renderer.setTextSelectionColor(Color.BLACK);

    GridBagConstraints gbc2 = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=BOTH");
    final JPanel checkersPane = GridBagUtils.createPanel();
    GridBagUtils.addToPanel(checkersPane, checkBoxTree, gbc2, "weightx=1.0,weighty=1.0");
    return checkersPane;
}
 
Example 11
Source File: DynamicTree.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Update the tree small icons: expanded/collapsed/leaf.
 */
private void changeTreeIcons() {
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
    renderer.setClosedIcon(Icons.CLOSED_ICON_16X16);
    renderer.setOpenIcon(Icons.OPEN_ICON_16X16);
    renderer.setLeafIcon(Icons.LEAF_ICON_16X16);
}
 
Example 12
Source File: GenealogyTree.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public GenealogyTree(Person graphNode) {
    super(new GenealogyModel(graphNode));
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    Icon personIcon = null;
    renderer.setLeafIcon(personIcon);
    renderer.setClosedIcon(personIcon);
    renderer.setOpenIcon(personIcon);
    setCellRenderer(renderer);
}
 
Example 13
Source File: HierarchyViewer.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void setupTree(Tree tree) {
	setTree(tree);

	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
	renderer.setOpenIcon(Icons.PARSER_RULE);
	renderer.setClosedIcon(Icons.PARSER_RULE);
	renderer.setLeafIcon(Icons.LEXER_RULE);
	myTree.setCellRenderer(renderer);
}
 
Example 14
Source File: CheckTreeCellRenderer.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void setupCellRendererIcon(DefaultTreeCellRenderer renderer, Icon icon) {
    renderer.setLeafIcon(icon);
    renderer.setOpenIcon(icon);
    renderer.setClosedIcon(icon);
}
 
Example 15
Source File: CheckTreeCellRenderer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void setupCellRendererIcon(DefaultTreeCellRenderer renderer, Icon icon) {
    renderer.setLeafIcon(icon);
    renderer.setOpenIcon(icon);
    renderer.setClosedIcon(icon);
}
 
Example 16
Source File: MWPaneTitleTreeManager.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * Create the title tree manager.
 * 
 * @param textPane Text pane.
 */
public MWPaneTitleTreeManager(MWPane textPane) {

  // Text pane
  this.textPane = textPane;
  splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  JScrollPane scrollContents = new JScrollPane(textPane);
  scrollContents.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  splitPane.setBottomComponent(scrollContents);

  // Table of contents
  JPanel panelTOC = new JPanel(new GridBagLayout());
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.BOTH;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(0, 0, 0, 0);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 1;
  constraints.weighty = 1;

  // Toolbar
  JToolBar toolbarButtons = new JToolBar(SwingConstants.VERTICAL);
  toolbarButtons.setFloatable(false);
  JButton buttonLess = Utilities.createJButton(
      "gnome-go-previous.png", EnumImageSize.NORMAL,
      GT._T("Decrement title level"), false, null);
  buttonLess.addActionListener(EventHandler.create(
      ActionListener.class, this, "decreaseLevel"));
  toolbarButtons.add(buttonLess);
  JButton buttonMore = Utilities.createJButton(
      "gnome-go-next.png", EnumImageSize.NORMAL,
      GT._T("Increment title level"), false, null);
  buttonMore.addActionListener(EventHandler.create(
      ActionListener.class, this, "increaseLevel"));
  toolbarButtons.add(buttonMore);
  JButton buttonDone = Utilities.createJButton(
      "commons-approve-icon.png", EnumImageSize.NORMAL,
      GT._T("Validate the new table of contents"), false, null);
  buttonDone.addActionListener(EventHandler.create(
      ActionListener.class, this, "validate"));
  toolbarButtons.add(buttonDone);
  constraints.weightx = 0;
  panelTOC.add(toolbarButtons, constraints);
  constraints.gridx++;

  // Tree node renderer
  DefaultTreeCellRenderer rendererToc = new DefaultTreeCellRenderer();
  rendererToc.setLeafIcon(rendererToc.getClosedIcon());

  // Table of contents Tree
  MWPaneTitleTreeNode rootToc = new MWPaneTitleTreeNode(null);
  modelToc = new DefaultTreeModel(rootToc);
  treeToc = new JTree(modelToc);
  treeToc.setRootVisible(false);
  treeToc.setShowsRootHandles(true);
  treeToc.getSelectionModel().setSelectionMode(
      TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
  treeToc.setCellRenderer(rendererToc);
  treeToc.addTreeSelectionListener(EventHandler.create(
      TreeSelectionListener.class, this, "selectionChanged"));
  JScrollPane scrollTree = new JScrollPane(treeToc);
  scrollTree.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  constraints.weightx = 1;
  panelTOC.add(scrollTree, constraints);
  constraints.gridx++;

  // Second tree
  MWPaneTitleTreeNode rootToc2 = new MWPaneTitleTreeNode(null);
  modelToc2 = new DefaultTreeModel(rootToc2);
  treeToc2 = new JTree(modelToc2);
  treeToc2.setRootVisible(false);
  treeToc2.setShowsRootHandles(true);
  treeToc2.setCellRenderer(rendererToc);
  JScrollPane scrollTree2 = new JScrollPane(treeToc2);
  scrollTree2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  constraints.weightx = 1;
  panelTOC.add(scrollTree2, constraints);
  constraints.gridx++;
  
  splitPane.setTopComponent(panelTOC);

  // Hide table of contents
  hideToc();
}
 
Example 17
Source File: TreeIconDemo.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public TreeIconDemo() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Set the icon for leaf nodes.
    ImageIcon leafIcon = createImageIcon("images/middle.gif");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    } else {
        System.err.println("Leaf icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
                                       // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
Example 18
Source File: NetworkDisplay.java    From yeti with MIT License 4 votes vote down vote up
public TreeRenderer() {

            URL networkIconUrl = this.getClass().getClassLoader().getResource("com/sensepost/yeti/resources/network.png");
            URL domainIconUrl = this.getClass().getClassLoader().getResource("com/sensepost/yeti/resources/star.png");
            URL hostIconUrl = this.getClass().getClassLoader().getResource("com/sensepost/yeti/resources/server.png");
            URL ipIconUrl = this.getClass().getClassLoader().getResource("com/sensepost/yeti/resources/bullet_blue.png");
            URL attributeIconUrl = this.getClass().getClassLoader().getResource("com/sensepost/yeti/resources/attr.png");
            URL attributeConfigIconUrl = this.getClass().getClassLoader().getResource("com/sensepost/yeti/resources/attr_config.png");
            URL attributeVulnIconUrl = this.getClass().getClassLoader().getResource("com/sensepost/yeti/resources/vuln.png");

            networkNodeRenderer = new DefaultTreeCellRenderer();
            networkNodeRenderer.setLeafIcon(new ImageIcon(networkIconUrl));
            networkNodeRenderer.setOpenIcon(new ImageIcon(networkIconUrl));
            networkNodeRenderer.setClosedIcon(new ImageIcon(networkIconUrl));

            domainNodeRenderer = new DefaultTreeCellRenderer();
            domainNodeRenderer.setLeafIcon(new ImageIcon(domainIconUrl));
            domainNodeRenderer.setOpenIcon(new ImageIcon(domainIconUrl));
            domainNodeRenderer.setClosedIcon(new ImageIcon(domainIconUrl));

            hostNodeRenderer = new DefaultTreeCellRenderer();
            hostNodeRenderer.setLeafIcon(new ImageIcon(hostIconUrl));
            hostNodeRenderer.setOpenIcon(new ImageIcon(hostIconUrl));
            hostNodeRenderer.setClosedIcon(new ImageIcon(hostIconUrl));

            ipNodeRenderer = new DefaultTreeCellRenderer();
            ipNodeRenderer.setLeafIcon(new ImageIcon(ipIconUrl));
            ipNodeRenderer.setOpenIcon(new ImageIcon(ipIconUrl));
            ipNodeRenderer.setClosedIcon(new ImageIcon(ipIconUrl));

            attrNodeRenderer = new DefaultTreeCellRenderer();
            attrNodeRenderer.setLeafIcon(new ImageIcon(attributeIconUrl));
            attrNodeRenderer.setOpenIcon(new ImageIcon(attributeIconUrl));
            attrNodeRenderer.setClosedIcon(new ImageIcon(attributeIconUrl));

            attrConfigNodeRenderer = new DefaultTreeCellRenderer();
            attrConfigNodeRenderer.setLeafIcon(new ImageIcon(attributeConfigIconUrl));
            attrConfigNodeRenderer.setOpenIcon(new ImageIcon(attributeConfigIconUrl));
            attrConfigNodeRenderer.setClosedIcon(new ImageIcon(attributeConfigIconUrl));

            attrVulnNodeRenderer = new DefaultTreeCellRenderer();
            attrVulnNodeRenderer.setLeafIcon(new ImageIcon(attributeVulnIconUrl));
            attrVulnNodeRenderer.setOpenIcon(new ImageIcon(attributeVulnIconUrl));
            attrVulnNodeRenderer.setClosedIcon(new ImageIcon(attributeVulnIconUrl));

            hostsNodeRenderer = new DefaultTreeCellRenderer();
            hostsNodeRenderer.setLeafIcon(new ImageIcon(networkIconUrl));
            hostsNodeRenderer.setOpenIcon(new ImageIcon(networkIconUrl));
            hostsNodeRenderer.setClosedIcon(new ImageIcon(networkIconUrl));

        }
 
Example 19
Source File: OverviewInfoTreeUI.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Constructs new overview info tree.
 * 
 * @param inFrame The application frame in which this exists.
 */
public OverviewInfoTreeUI(ApplicationFrame inFrame) {
	// Create the top node.
	_topNode = new DefaultMutableTreeNode("EA Overview");
	_theFrame = inFrame;

	// Create a tree that allows one selection at a time.
	_infoTreeModel = new DefaultTreeModel(_topNode);
	_infoTree = new JTree(_infoTreeModel);

	_infoTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	_infoTree.setRootVisible(false); // Hides root node
	_infoTree.setShowsRootHandles(true); // Shows nodes off root

	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();

	renderer.setOpenIcon(null);
	renderer.setClosedIcon(null);
	renderer.setLeafIcon(null);
	_infoTree.setCellRenderer(renderer);

	// Add tree into scroll pane and then to this pane
	this.setViewportView(_infoTree);
	this.setMinimumSize(new Dimension(150, 200));

	_popupMenu = new JPopupMenu();
	_newPosition = new Point(50, 50);

	buildPopupMenu();

	// Create Category Heads
	_tree_sketches = new DefaultMutableTreeNode("Sketches");

	_topNode.add(_tree_sketches);

	_tree_views = new DefaultMutableTreeNode("Views");

	_topNode.add(_tree_views);

	// Initialize ArrayList of expansion state information
	expanState = new ArrayList<>();
}
 
Example 20
Source File: ModelInfoTreeUI.java    From CQL with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Default constructor
 *
 * @param inFrame
 */
public ModelInfoTreeUI(F inFrame) {
	// Create the top node.
	_topNode = new DefaultMutableTreeNode("EA Sketch");
	_theFrame = inFrame;
	_newPosition = new Point(50, 50);

	// Create a tree that allows one selection at a time.
	_infoTreeModel = new DefaultTreeModel(_topNode);
	_infoTree = new JTree(_infoTreeModel);

	_infoTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	_infoTree.setRootVisible(false); // Hides root node
	_infoTree.setShowsRootHandles(true); // Shows nodes off root

	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();

	renderer.setOpenIcon(null);
	renderer.setClosedIcon(null);
	renderer.setLeafIcon(null);
	_infoTree.setCellRenderer(renderer);

	// Add tree into scroll pane and then to this pane
	this.setViewportView(_infoTree);
	this.setMinimumSize(new Dimension(150, 200));

	_popupMenu = new JPopupMenu();

	buildPopupMenu();

	// Create Category Heads
	_tree_entities = new DefaultMutableTreeNode("Entities");

	_topNode.add(_tree_entities);

	_tree_constraints = new DefaultMutableTreeNode("Constraints");

	_topNode.add(_tree_constraints);

	_tree_constraints_commutative = new DefaultMutableTreeNode("Commutative Diagrams");

	_tree_constraints.add(_tree_constraints_commutative);

	_tree_constraints_product = new DefaultMutableTreeNode("Product Constraints");

	_tree_constraints.add(_tree_constraints_product);

	_tree_constraints_pullback = new DefaultMutableTreeNode("Pullback Constraints");

	_tree_constraints.add(_tree_constraints_pullback);

	_tree_constraints_equalizer = new DefaultMutableTreeNode("Equalizer Constraints");

	_tree_constraints.add(_tree_constraints_equalizer);

	_tree_constraints_sum = new DefaultMutableTreeNode("Sum Constraints");

	_tree_constraints.add(_tree_constraints_sum);

	_tree_constraints_limit = new DefaultMutableTreeNode("Limit Constraints");

	_tree_constraints.add(_tree_constraints_limit);

	// Initialize ArrayList of expansion state information
	expanState = new ArrayList<>();
}