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

📄 classify.java

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * file: Classify.java * * Last edited: Ryan Irwin * */// import necessary java libraries//import javax.swing.*;import java.awt.*;import java.util.*;import java.net.*;import java.applet.*;/**** Classify is the main driver program that extend JApplet and is the * class called when the applet is loaded, which inturn initialize all* other objects and components need to run the applet** hierarchy: JApplet->Classify**/public class Classify extends JApplet{    // *********************************************************************    //    // declare global variables and components    //    // *********************************************************************        // declare global variables    //    Vector<URL> url_vec_d = new Vector<URL>(5, 1);        // point type    //    public static final int PTYPE_INPUT = 1;    public static final int PTYPE_OUTPUT = 2;    public static final int PTYPE_SUPPORT_VECTOR = 3;    public static final int PTYPE_OUTPUT_LARGE = 4;    public static final int PTYPE_LINE = 5;    public static final double X_MAX = 2.0;    public static final double Y_MAX = 2.0;            // declare components    //    static MainMenu main_menu_d;    static ProcessBox pro_box_d = new ProcessBox();    static DataPoints input_points_d = new DataPoints();    static InputPanel input_panel_d = new InputPanel(input_points_d);    static OutputPanel output_panel_d = new OutputPanel();    static Vector<Algorithm> algo_vec_d = new Vector<Algorithm>();    static int algo_index_d = -1;        static int algo_index_svm_d = -1;    static int algo_index_pcaci_d = -1;    static int algo_index_pca2_d = -1;    static int algo_index_rvm_d = -1;    static int algo_index_ldapca1_d = -1;    //   static int algo_index_ldapca2_d = -1;    static int algo_index_pf_d = -1;    static int algo_index_kf_d = -1;    static int algo_index_lp_d = -1;        // Phil T. - Added     //    static int algo_index_ldaci_d = -1;    static int algo_index_lda2_d = -1;    static int algo_index_ed_d = -1;    static int algo_index_nn_d = -1;    static int algo_index_kmeans_d = -1;    static int algo_index_lbg_d = -1;     // *********************************************************************    //    // declare non-static variables and components    //    // *********************************************************************        JPanel content_pane_d = new JPanel();    int width_d = 0; // width of the canvas    int height_d = 0; // height of the canvas        int zero_x_d = 0; // zero position on x axis    int zero_y_d = 0; // zero position on y axis        // *********************************************************************    //    // declare class constructors    //    // *********************************************************************        /**     * Initializes variables     */    public void preInit()    {	pro_box_d = new ProcessBox();	input_points_d = new DataPoints();	input_panel_d = new InputPanel(input_points_d);	output_panel_d = new OutputPanel();	algo_vec_d = new Vector<Algorithm>();	algo_index_d = -1;	algo_index_svm_d = -1;	algo_index_pcaci_d = -1;	algo_index_pca2_d = -1;	algo_index_rvm_d = -1;	algo_index_ldapca1_d = -1;	algo_index_pf_d = -1;	algo_index_kf_d = -1;	algo_index_lp_d = -1;	// set the sizes of the input and output panels and process box	//	input_panel_d.setSize(new Dimension(30, 40));	input_panel_d.setPreferredSize(new Dimension(30, 40));	input_panel_d.setMinimumSize(new Dimension(30, 40));	input_panel_d.setMaximumSize(new Dimension(30, 40));	output_panel_d.setSize(new Dimension(30, 40));	output_panel_d.setPreferredSize(new Dimension(30, 40));	output_panel_d.setMinimumSize(new Dimension(30, 40));	output_panel_d.setMaximumSize(new Dimension(30, 40));	pro_box_d.setSize(new Dimension(50, 80));	pro_box_d.setPreferredSize(new Dimension(50, 80));	pro_box_d.setMinimumSize(new Dimension(50, 80));	pro_box_d.setMaximumSize(new Dimension(50, 80));	getRootPane().putClientProperty(					"defeatSystemEventQueueCheck",					Boolean.TRUE);    }    // *********************************************************************    //    // declare class methods    //    // *********************************************************************      /**       * main method, the entrance of the program       *        * @param   args command line arguments       */      public static void main(String[] args)      {	  	  try	  {	      // set the look and feel	      //	      //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());	  } 	  catch (Exception e)	      {}	  	  Classify frame = new Classify();	  frame.setSize(new Dimension(480, 520));	  frame.init();	  //frame.pack();	  	  //Center the window	  //	  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();	  Dimension frameSize = frame.getSize();	  if (frameSize.height > screenSize.height)	      frameSize.height = screenSize.height;	  if (frameSize.width > screenSize.width)	      frameSize.width = screenSize.width;	  frame.setLocation(			    (screenSize.width - frameSize.width) / 2,			    (screenSize.height - frameSize.height) / 2);	  frame.setVisible(true);	        }        /**     * this method is called when the applet is started     *     */    public void init()  {      super.init();      preInit();      // declare components to read the help files      //      try      {	  URL url;	  url = new URL(getCodeBase() + "doc/help_release.txt");	  url_vec_d.addElement(url);	  url = new URL(getCodeBase() + "doc/help_info_support.txt");	  url_vec_d.addElement(url);	  url = new URL(getCodeBase() + "doc/help_overview.txt");	  url_vec_d.addElement(url);	  url = new URL(getCodeBase() + "doc/tutorial.html");	  url_vec_d.addElement(url);	  url = new URL(getCodeBase() + "doc/help_plugins.txt");	  url_vec_d.addElement(url);      }       catch (MalformedURLException me)	  {}      // get the applet context      //      AppletContext context = getAppletContext();      // initialize the menu bar object      //      main_menu_d = new MainMenu(url_vec_d, context);      //main_menu_d = new MainMenu(null, null);      this.setContentPane(content_pane_d);      GridBagLayout gridbag = new GridBagLayout();      content_pane_d.setLayout(gridbag);      content_pane_d.setBorder(	      BorderFactory.createCompoundBorder(		   BorderFactory.createRaisedBevelBorder(),		   BorderFactory.createLoweredBevelBorder()));      main_menu_d.constrain(			    content_pane_d,			    main_menu_d,			    0,			    0,			    GridBagConstraints.REMAINDER,			    1,			    GridBagConstraints.BOTH,			    GridBagConstraints.NORTHWEST,			    1,			    0.1,			    2,			    2,			    2,			    2);      input_panel_d.constrain(			      content_pane_d,			      input_panel_d,			      0,			      1,			      1,			      1,			      GridBagConstraints.BOTH,			      GridBagConstraints.NORTHWEST,			      1,			      1,			      0,			      0,			      0,			      0);      output_panel_d.constrain(			       content_pane_d,			       output_panel_d,			       0,			       2,			       1,			       1,			       GridBagConstraints.BOTH,			       GridBagConstraints.NORTHWEST,			       1,			       1,			       0,			       0,			       0,			       0);      pro_box_d.constrain(			  content_pane_d,			  pro_box_d,			  1,			  1,			  GridBagConstraints.REMAINDER,			  GridBagConstraints.REMAINDER,			  GridBagConstraints.BOTH,			  GridBagConstraints.NORTHWEST,			  1,			  1,			  0,			  0,			  0,			  0);      // add the components in the respective panels      //      //pro_bar_d.add_components();      pro_box_d.add_components();      main_menu_d.add_components();      input_panel_d.add_components();      output_panel_d.add_components();      // add algorithms      //      AlgorithmSVM algo_svm = new AlgorithmSVM();      algo_vec_d.add(algo_svm);      algo_index_svm_d = 0;

⌨️ 快捷键说明

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