view src/MPipeline2/src/mpipeline/main/LibraryTree.java @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents f0afece42f48
children
line wrap: on
line source

/*
 * Copyright (c) 2009 Max-Planck-Gesellschaft, Martin Hewitson <martin.hewitson at aei.mpg.de>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */

package mpipeline.main;

import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.ToolTipManager;
import javax.swing.tree.DefaultTreeCellRenderer;
import mpipeline.canvas.AlgorithmTransfer;

/**
 * A subclass of JTree for displaying the LTPDA library blocks with nice icons
 * and meaningful tooltips.
 * 
 * @author hewitson
 */
public class LibraryTree extends JTree {

  /**
   * Construct a new LibraryTree.
   */
  public LibraryTree() {

    super();

    DefaultTreeCellRenderer renderer = new LibraryTreeRenderer();

    ImageIcon closedIcon = new ImageIcon(getClass().getResource("/mpipeline/icons/lpf_icon.png"));
    if (closedIcon != null) {
      renderer.setClosedIcon(closedIcon);
    }

    ImageIcon openIcon = new ImageIcon(getClass().getResource("/mpipeline/icons/lpf_icon.png"));
    if (openIcon != null) {
      renderer.setOpenIcon(openIcon);
    }

    ImageIcon leafIcon = new ImageIcon(getClass().getResource("/mpipeline/icons/testmass_icon_16x16.png"));
    if (leafIcon != null) {
      renderer.setLeafIcon(leafIcon);
    }

    this.setCellRenderer(renderer);


    ToolTipManager.sharedInstance().registerComponent(this);

    this.setExpandsSelectedPaths(true);

    this.expandRow(0);

    this.setDragEnabled(true);
    this.setTransferHandler(new AlgorithmTransfer());


  }
}