TreePanel. This class lays out the ImageJ user plugins in a vertical, hierarchical tree.. Plugins are launched by double-clicking on their names, in the vertical tree. Advantages: uses less screen estate, and provides a realistic graphical presentation of the plugins installed in the file sy
| 639 | |
| 640 | |
| 641 | class TreePanel implements |
| 642 | ActionListener, WindowListener, TreeExpansionListener, TreeWillExpandListener { |
| 643 | |
| 644 | ControlPanel pcp; |
| 645 | //Vector childrenPanels = new Vector(); |
| 646 | boolean isMainPanel; |
| 647 | String title; |
| 648 | boolean isDragging=false; |
| 649 | //boolean requireDoubleClick=false; |
| 650 | Point defaultLocation; |
| 651 | |
| 652 | private JTree pTree; |
| 653 | private JMenuBar pMenuBar; |
| 654 | private DefaultMutableTreeNode root; |
| 655 | private DefaultMutableTreeNode draggingNode=null; |
| 656 | private DefaultTreeModel pTreeModel; |
| 657 | private ActionListener listener; |
| 658 | private JFrame pFrame; |
| 659 | private JCheckBoxMenuItem pMenu_saveOnClose, pMenu_noClutter; |
| 660 | private TreePath rootPath; |
| 661 | |
| 662 | // the "up" arrow |
| 663 | private static final int _uparrow1_data[] = { |
| 664 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 665 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 666 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 667 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 668 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 669 | 0x00,0x0d,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 670 | 0x00,0x00,0x0d,0x01,0x01,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 671 | 0x00,0x00,0x00,0x00,0x01,0x0e,0x02,0x01,0x03,0x00,0x00,0x00,0x00,0x00, |
| 672 | 0x00,0x00,0x00,0x00,0x00,0x01,0x0e,0x04,0x05,0x06,0x01,0x07,0x00,0x00, |
| 673 | 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x08,0x04,0x09,0x0e,0x02,0x06,0x01, |
| 674 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x08,0x04,0x09,0x0e,0x0e,0x0e, |
| 675 | 0x02,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04,0x09,0x0e,0x0e, |
| 676 | 0x0e,0x0e,0x0e,0x02,0x06,0x02,0x00,0x00,0x00,0x08,0x0a,0x0e,0x08,0x0a, |
| 677 | 0x0b,0x0b,0x0c,0x0c,0x0c,0x0c,0x0c,0x06,0x02,0x00,0x0e,0x01,0x01,0x01, |
| 678 | 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x0e,0x00,0x00, |
| 679 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 680 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 681 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 682 | 0x00,0x00,0x00,0x00 |
| 683 | }; |
| 684 | |
| 685 | private static final int _uparrow1_ctable[] = { |
| 686 | 0x21,0xff000000,0xff303030,0xffaaaaaa,0xffffffff,0xff3c3c3c,0xff252525,0xffb6b6b6,0xff585858,0xffc3c3c3,0xff222222,0xff2b2b2b,0xff2e2e2e,0xffa0a0a0, |
| 687 | 0xff808080 |
| 688 | }; |
| 689 | |
| 690 | private static IndexColorModel iconCM = new IndexColorModel(8,_uparrow1_ctable.length,_uparrow1_ctable,0,true,255,DataBuffer.TYPE_BYTE); |
| 691 | private static final ImageIcon upIcon = new ImageIcon( Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16,16,iconCM,_uparrow1_data,0,16))); |
| 692 | |
| 693 | public TreePanel (DefaultMutableTreeNode root, ControlPanel pcp, boolean isMainPanel) { |
| 694 | new TreePanel(root,pcp,isMainPanel,null); |
| 695 | } |
| 696 | |
| 697 | public TreePanel(DefaultMutableTreeNode root, ControlPanel pcp, boolean isMainPanel, Point location) { |
| 698 | this.root=root; |
nothing calls this directly
no test coverage detected