/**
   * Constructs the button with the given node type and image prefix. If the node type is "Select",
   * constructs a button that allows nodes to be selected and moved. If the node type is "Edge",
   * constructs a button that allows edges to be drawn. For other node types, constructs buttons
   * that allow those type of nodes to be added to the workbench. If a non-null image prefix is
   * provided, images for <prefix>Up.gif, <prefix>Down.gif, <prefix>Off.gif and <prefix>Roll.gif are
   * loaded from the /images directory relative to this compiled class and used to provide up, down,
   * off, and rollover images for the constructed button. On construction, nodes are mapped to their
   * node types in the Map, <code>nodeTypes</code>. Listeners are added to the node.
   *
   * @param buttonInfo contains the info needed to construct the button.
   */
  private JToggleButton constructButton(ButtonInfo buttonInfo) {
    String imagePrefix = buttonInfo.getImagePrefix();

    if (imagePrefix == null) {
      throw new NullPointerException("Image prefix must not be null.");
    }

    JToggleButton button = new JToggleButton();

    button.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            setShiftDown(e.isShiftDown());
            //                setControlDown(e.isControlDown());
          }
        });

    if ("Select".equals(buttonInfo.getNodeTypeName())) {
      button.setIcon(new ImageIcon(ImageUtils.getImage(this, "move.gif")));
    } else if ("Edge".equals(buttonInfo.getNodeTypeName())) {
      button.setIcon(new ImageIcon(ImageUtils.getImage(this, "flow.gif")));
    } else {
      button.setName(buttonInfo.getNodeTypeName());
      button.setText("<html><center>" + buttonInfo.getDisplayName() + "</center></html>");
    }

    button.setMaximumSize(new Dimension(110, 40)); // For a vertical box.
    button.setToolTipText(buttonInfo.getToolTipText());
    this.nodeTypes.put(button, buttonInfo.getNodeTypeName());

    return button;
  }