Package syn3d.ui

Source Code of syn3d.ui.Component3DTree

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2004, by :
*     Corporate:
*         Astrium SAS
*     Individual:
*         Claude Cazenave
*
* $Id: Component3DTree.java,v 1.3 2004/03/24 15:03:52 brodu Exp $
*
* Changes
* -------
* 28-Jan-2004 : Creation date (CC);
*
*/
package syn3d.ui;

import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

import simtools.ui.MenuResourceBundle;
import simtools.ui.ResourceFinder;

/**
* Class description ...
*
* @author Claude CAZENAVE
*
*/
public class Component3DTree extends JTree {

  /** Resources */
  protected static MenuResourceBundle resources=ResourceFinder.getMenu(SceneGraphModel.class);

  protected DefaultTreeModel model;
   
  /**
   *
   */
  public Component3DTree() {
    DefaultMutableTreeNode root=new DefaultMutableTreeNode();
    model= new DefaultTreeModel(root, true);
    setModel(model);
    setCellRenderer(new SceneGraphTreeRenderer());
    setRootVisible(false);
  }
 
  /* (non-Javadoc)
   * @see javax.swing.JTree#convertValueToText(java.lang.Object, boolean, boolean, boolean, int, boolean)
   */
  public String convertValueToText(
    Object value,
    boolean selected,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus) {
   
    Object o=((DefaultMutableTreeNode)value).getUserObject()
    if (o instanceof Integer) {
      int k = ((Integer) o).intValue();
      if (k >= 0) {
        return resources.getStringValue("item" + k);
      }
    }
    return super.convertValueToText(value,selected,expanded,leaf,row,hasFocus);
  }

  /**
   * A helper to add  the tree into a tabbed pane
   */
  public void addToTabbedPane(JTabbedPane p) {
    JScrollPane pp =
      new JScrollPane(
        this,
        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
        JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    p.add(resources.getStringValue("title"),pp);
  }
}
TOP

Related Classes of syn3d.ui.Component3DTree

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.