⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maintoolbar.java

📁 一个用java写的地震分析软件(无源码)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package org.trinet.jiggle;

/**
 * This is the Main tool bar that will be visible in the frame at all times.<p>
 *
 * Images for button icons are loaded using the IconImage class to insure
 * transportablility. They must reside in the "/images" directory of the
 * CLASSPATH or the .jar file. (Ex: <classpath>/images/zagscroll.gif)

 *@see: IconImage */
// see:  http://java.sun.com/docs/books/tutorial/ui/swing/toolbar.html

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.border.TitledBorder;

import org.trinet.jasi.*;
import org.trinet.util.gazetteer.*;

public class MainToolBar extends JToolBar {

// panel components

    /** Panel containing event specific components; eventTypeChooser and
        solutionListComboBox*/
     SolutionPanel solPanel;

//    Box solPanelBox = Box.createHorizontalBox();

    // buttons that can be disabled
    JButton deleteButton;
    JButton finalButton;
    JButton saveButton;
    JButton saveAllButton;
    JButton nextButton;
    JButton locateButton;
    JButton mlButton;
    JButton mcButton;
    JButton newSolButton;
//    FixDepthButton fixDepthButton = new FixDepthButton();

    JToggleButton unpickButton;

    // must keep references to these so we can remove them as observers
//    SolutionListComboBox solCombo = new SolutionListComboBox();
//    EventTypeChooser typeChooser  = new EventTypeChooser();

    // one handler for all buttons
    ButtonHandler buttonHandler = new ButtonHandler();
//    FixButtonHandler fixButtonHandler = new FixButtonHandler();

// event handling stuff
    private Object objSelected;     // the menu, list or button item selected
    private String EventName;	    // String label of the event (e.g. "Exit")
    private String ItemName;

    MasterView mv;
    Jiggle mainFrame;		// the main frame buttons act on

/**
 * Event Handling: Local events come from the Buttons and the ID list. Button
 * events are are handled by HandleEvent and the list is handled HandleList. If
 * a menu is ever added to this panel we would handle it in HandleEvent
 * also. <p> The Menu is a component of MainFrame and not this panel. However,
 * we want to change a label on the panel in response to a menu selection in
 * MainFrame. Therefore, the lable object is public static allowing MinFrame to
 * change it.  */
public MainToolBar (Jiggle frm)
    {
      setMainFrame(frm);
      makeToolBar();
    }

public MainToolBar ()		    // constructor
    {
      makeToolBar();
    }

/**
 * Create the button panel
 */
 public void makeToolBar ()
    {

      setFloatable(true);	// allow user to move toolbar

      // Removed 4/19/00 does not work
      //      add(makeButton("File","dirtree.gif",
      //		     "Open file chooser", 'f'));

      addSeparator();

      add(makeButton("Catalog", "zagscroll.gif",
		     "Return to catalog listing", 'c'));

      addSeparator();

      deleteButton = makeButton("Delete", "dynamite.gif",
	        "Delete current solution", 'd');
      add(deleteButton);

      addSeparator();
      /*
      add(makeButton("Sort","assemble.gif",
	"Sort waveforms by distance from current origin", 's'));
      */
      addSeparator();


      locateButton = makeButton("Locate", "bullseye.gif",
		     "Calculate location & magnitude", 'l');
      add(locateButton);

      addSeparator();

      mlButton = makeButton("ML", "ML_32.gif",
		     "Calculate magnitude", 'm');
      add(mlButton);


      mcButton = makeButton("MC", "MC_32.gif",
		     "Calculate magnitude", 'c');
      add(mcButton);


      addSeparator();

      saveButton = makeButton("Save",  "save.gif",
		     "Save the current event", 's');
      add(saveButton);

      addSeparator();

      saveAllButton = makeButton("Save All", "saveall.gif",
		     "Save the all events", 'a');
      add(saveAllButton);

      addSeparator();

      finalButton = makeButton("Final",  "gavel.gif",
		     "Save the current event", 'f');
      add(finalButton);

      addSeparator();

      nextButton = makeButton("Next", "forward.gif",
		     "Get the next event", 'n');
      add(nextButton);

      addSeparator();

      // Unpicking mode toggle button
      /*
      JToggleButton unpickButton =
	  new JToggleButton ("Unpick", new ImageIcon(IconImage.getImage("/images/mop.gif")));
      unpickButton.setAlignmentY(CENTER_ALIGNMENT);
      unpickButton.setHorizontalTextPosition(AbstractButton.CENTER);
      unpickButton.setVerticalTextPosition(AbstractButton.BOTTOM);
      unpickButton.setToolTipText("Delete picks");
      unpickButton.setMnemonic('u');
      */

      unpickButton = makeToggleButton("Unpick", "mop.gif",
			   "Delete picks",  'u');
  
      unpickButton.addItemListener (new ItemListener () {

	  public void itemStateChanged(ItemEvent e) {
	      int state = e.getStateChange();
	      if (state == ItemEvent.SELECTED) {
		  mainFrame.setUnpickMode(true);
	      } else {
		  mainFrame.setUnpickMode(false);
	      }
	  }
      });

      add(unpickButton);

      addSeparator();

      // add (empty) solPanel - can't create until there's a masterView
/*
      solPanel.setBorder( new TitledBorder("Selected Solution") );
      // event type chooser


      typeChooser = new EventTypeChooser();
      typeChooser.addActionListener(new EventTypeComboHandler());
      typeChooser.setEnabled(false);

      solCombo = new SolutionListComboBox ()
      solPanelBox.add(new SolutionListComboBox ());	// empty chooser
      solPanelBox.add(Box.createHorizontalStrut(10));
      solPanelBox.add(typeChooser);
      // need JPanel for TitledBorder and Box for better control
*/

      solPanel = new SolutionPanel(mainFrame);
//      solPanel.add(solPanel);
      add(solPanel);

      addSeparator();
      newSolButton = makeButton("New Sol", "new0b.gif",
		     "Create a new, blank solution", 'n');

      add(newSolButton);

      addSeparator();
  
      add(makeButton("Repaint", "glue.gif",

		     "Repaint the screen", 'r'));
      // at start up there's no selected solution so...
      setEventEnabled(false);

    } // end of makeToolBar

/**
 * Method to stream line adding of buttons. Makes sure all buttons have the same
 * action handler.
 */
    JButton makeButton (String label, String iconFile) {
    // this handles finding the icons in the path
      Image image = IconImage.getImage(iconFile);

      JButton btn;

      if (image == null) {
	  btn = new JButton(label);
      } else {
	  btn = new JButton(label, new ImageIcon(image));
      }

      btn.addActionListener (buttonHandler);
      btn.setAlignmentY(CENTER_ALIGNMENT);
      btn.setHorizontalTextPosition(AbstractButton.CENTER);
      btn.setVerticalTextPosition(AbstractButton.BOTTOM);

      return btn;
    }

    JButton makeButton (String label, String iconFile, String tip)
    {
      JButton btn = makeButton(label, iconFile);
      btn.setToolTipText(tip);
      return btn;
    }

    JButton makeButton (String label, String iconFile, String tip, char mnem)
    {
      JButton btn = makeButton(label, iconFile, tip);
      btn.setMnemonic(mnem);	 // doesn't work, needs more support for focus, actions?
      return btn;
    }

/**
 * Method to stream line adding of buttons. Makes sure all buttons have the same
 * action handler.
 */
    JToggleButton makeToggleButton (String label, String iconFile)
    {
      Image image = IconImage.getImage(iconFile);

      JToggleButton btn;

      if (image == null) {
	  btn = new JToggleButton(label);
      } else {
	  btn = new JToggleButton(label, new ImageIcon(image));
      }

      //      btn.addActionListener (new ButtonHandler());
      btn.setAlignmentY(CENTER_ALIGNMENT);
      btn.setHorizontalTextPosition(AbstractButton.CENTER);
      btn.setVerticalTextPosition(AbstractButton.BOTTOM);

      return btn;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -