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

📄 classify.java,v

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA,V
📖 第 1 页 / 共 3 页
字号:
head	1.7;access;symbols;locks	rirwin:1.7; strict;comment	@# @;1.7date	2005.06.10.18.32.23;	author rirwin;	state Exp;branches;next	1.6;1.6date	2005.05.23.21.01.41;	author rirwin;	state Exp;branches;next	1.5;1.5date	2005.03.15.19.11.16;	author patil;	state Exp;branches;next	1.4;1.4date	2005.03.09.21.07.47;	author patil;	state Exp;branches;next	1.3;1.3date	2005.01.05.19.19.59;	author patil;	state Exp;branches;next	1.2;1.2date	2004.12.31.23.52.13;	author patil;	state Exp;branches;next	1.1;1.1date	2004.12.28.00.04.32;	author patil;	state Exp;branches;next	;desc@Major Changes made. Refer the email by Dr. Picone. 12/23/2004 4:00 pm@1.7log@Establishing RCS version./@text@/** * 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_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_ldapca2_d = -1;	algo_index_pf_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;      AlgorithmPCA algo_pca = new AlgorithmPCA();      algo_vec_d.add(algo_pca);      algo_index_pcaci_d = 1;      AlgorithmRVM algo_rvm = new AlgorithmRVM();      algo_vec_d.add(algo_rvm);      algo_index_rvm_d = 2;      AlgorithmPCA2 algo_pca2 = new AlgorithmPCA2();      algo_vec_d.add(algo_pca2);      algo_index_pca2_d = 3;      // Added By Phil Trasatti - 7/10/03      AlgorithmLDA algo_lda = new AlgorithmLDA();      algo_vec_d.add(algo_lda);      algo_index_ldaci_d = 4;      // Added By Phil Trasatti - 7/10/03      AlgorithmLDA2 algo_lda2 = new AlgorithmLDA2();      algo_vec_d.add(algo_lda2);      algo_index_lda2_d = 5;      // Added By Phil Trasatti - 7/10/03      AlgorithmLBG algo_lbg = new AlgorithmLBG();      algo_vec_d.add(algo_lbg);      algo_index_lbg_d = 6;      // Added By Phil Trasatti - 7/10/03      AlgorithmKMeans algo_kmeans = new AlgorithmKMeans();      algo_vec_d.add(algo_kmeans);      algo_index_kmeans_d = 7;      // Added By Phil Trasatti - 7/10/03      AlgorithmNN algo_nn = new AlgorithmNN();    algo_vec_d.add(algo_nn);    algo_index_nn_d = 8;   // Added By Phil Trasatti - 7/10/03    AlgorithmED algo_ed = new AlgorithmED();    algo_vec_d.add(algo_ed);    algo_index_ed_d = 9;        // Added By Jun-Won Suh - 27/10/04     AlgorithmLDAPCA algo_ldapca = new AlgorithmLDAPCA();     algo_vec_d.add(algo_ldapca);     algo_index_ldapca1_d = 10;     // Added By Jun-Won Suh - 27/10/04     // AlgorithmLDAPCA2 algo_ldapca2 = new AlgorithmLDAPCA2();     // algo_vec_d.add(algo_ldapca2);     // algo_index_ldapca2_d = 11;          // Added By Jun-Won Suh - 27/10/04     // AlgorithmPARTICLE algo_particle = new AlgorithmPARTICLE();     // algo_vec_d.add(algo_particle);     // algo_index_particle_d = 12;          // Added By Jun-Won Suh - 27/10/04     AlgorithmLP algo_lp = new AlgorithmLP();     algo_vec_d.add(algo_lp);     algo_index_lp_d = 11;     AlgorithmPF algo_pf = new AlgorithmPF();     algo_vec_d.add(algo_pf);     algo_index_pf_d = 12;          // set the default algo     algo_index_d = algo_index_pcaci_d;       }        /**     * determines the dimensions of the selection area     *     */    public void DetermineDimensions()    {		Dimension dimen = this.getSize();	width_d = dimen.width;	height_d = dimen.height;		// divide by 2	//	zero_x_d = width_d >> 1;	zero_y_d = height_d >> 1;    }    /**     * determine the current algorithm and returns an object for it     *     * @@return Object of current algorithm     *     */    static public Object getCurrAlgo()    {	// Debug	//	//	System.out.println("Classify : getCurrAlgo()");		//algo_index_d = 0 ;	return algo_vec_d.get(algo_index_d);    }        /**     * determine the dimensions of the selection area     *     * @@param    algo_a The algorithm to he initialized     * @@return   true     *     */    static public boolean initializeAlgo(Algorithm algo_a)    {		// initialize i/o compoents	//	algo_a.setDataPoints(input_points_d);	//algo_a.setInputPanel(input_panel_d);	algo_a.setOutputPanel(output_panel_d);	algo_a.setProcessBox(pro_box_d);

⌨️ 快捷键说明

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