classify.java,v
来自「包含了模式识别中常用的一些分类器设计算法」· JAVA,V 代码 · 共 1,436 行 · 第 1/3 页
JAVA,V
1,436 行
frame.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true);d224 3a226 1 }d228 4a231 9 // method: init // // arguments: none // return : none // // this method is called when the applet is started // public void init() {d233 68a300 1 super.init();d302 7a308 1 preInit();d310 37a346 21 // 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();d348 2a349 122 // 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();d363 11a373 11 // 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/04d377 4a380 4 // set the default algo algo_index_d = algo_index_pcaci_d;d382 22d405 11a415 29 // method: DetermineDimensions // // arguments: none // return : none // // determine 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; } // method: getCurrAlgo // // arguments: none // return : none // // determine the dimensions of the selection area // static public Object getCurrAlgo() {d417 29a445 2 // // System.out.println("Classify : getCurrAlgo()");d447 1a447 24 //algo_index_d = 0 ; return algo_vec_d.get(algo_index_d); } // method: initializeAlgo // // arguments: none // return : none // // determine the dimensions of the selection area // 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); // init the algorithm // return true;d449 13a461 12 } // method: initializeAlgo // // arguments: none // return : none // // determine the dimensions of the selection area // actually this draws a line of width 3 pixels in either directions // in way, this draws a + sign.. // 3 pixels because, -3 /2 and + 3 / 2 on either side. //d463 50a512 9 Graphics device_a, Point point_a, int type_a, Color color_a) { int X, Y; Color curr_color = device_a.getColor(); device_a.setColor(color_a);d514 15a528 6 X = (int)point_a.x; Y = (int)point_a.y; // draw different point // switch (type_a)a529 20 case PTYPE_INPUT : device_a.drawLine(X - 3 / 2, Y, X + 3 / 2, Y); device_a.drawLine(X, Y - 3 / 2, X, Y + 3 / 2); device_a.setColor(curr_color); break; case PTYPE_OUTPUT : break; case PTYPE_SUPPORT_VECTOR : device_a.setColor(color_a); device_a.drawOval(X - 5 / 2, Y - 5 / 2, 5, 5); device_a.setColor(curr_color); break; case PTYPE_OUTPUT_LARGE : device_a.setColor(color_a); device_a.fillOval(X - 5 / 2, Y - 5 / 2, 5, 5); device_a.setColor(curr_color); break;d531 16a546 2 default : break;d548 11a558 42 // reset the color // device_a.setColor(curr_color); // init the algorithm // return true; } // method: initializeAlgo // // arguments: none // return : none // // determine the dimensions of the selection area // static public boolean drawPoints( Graphics device_a, Vector points_a, int type_a, Color color_a) { // put the code here for drawing lines.. if (type_a == PTYPE_LINE) { putLines(device_a, points_a, type_a, color_a); } if (type_a != PTYPE_LINE) { for (int i = 0; i < points_a.size(); i++) { drawPoint(device_a, (Point)points_a.get(i), type_a, color_a); } } // init the algorithm // return true; }d560 4a563 4 Graphics device_a, Vector points_a, int type_a, Color color_a)d573 11a583 1d585 4a588 4 Graphics device_a, Point first_pt_a, Point second_pt_a, Color color_a)d609 1a609 1d611 1a611 3 } // end of drawing lines a613 3// // end of file@1.2log@Made the modification in drawPoints method. Added two methodsto it to draw line if the option is asked for.@text@a467 2 // statement commented are ones by sanjay // changes made on 12/30, sanjaya469 2 // device_a.drawLine(X - 1 / 2, Y, X + 1 / 2, Y); //device_a.drawLine(X, Y - 1 / 2, X, Y + 1/ 2);a477 1 // changes made on 12/30/04, sanjaya478 1 // device_a.drawOval(X - 3 / 2, Y - 3 / 2, 3, 3); // statement by sanjay.a483 1 // changes made on 12/30/2004, sanjay now commenteda484 1 //device_a.fillOval(X - 3 / 2, Y - 3 / 2, 3, 3);d517 1d519 4a522 1 else // draw each point..d527 1a527 1d541 1d543 1a543 1d557 4a560 1 int X1, X2, Y1, Y2;d562 4a565 4 X1 = (int)first_pt_a.x; X2 = (int)second_pt_a.x; Y1 = (int)first_pt_a.y; Y2 = (int)second_pt_a.y;@1.1log@Initial revision@text@d27 20a46 19 // ********************************************************************* // // declare global variables and components // // ********************************************************************* // declare global variables // Vector url_vec_d = new Vector(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 double X_MAX = 2.0; public static final double Y_MAX = 2.0;d445 4a448 1 //d468 2d472 2d482 1d484 1d490 3a492 1 device_a.fillOval(X - 5 / 2, Y - 5 / 2, 5, 5);a497 1a521 4 // draw each point // for (int i = 0; i < points_a.size(); i++) {d523 8a530 3 drawPoint(device_a, (Point)points_a.get(i), type_a, color_a); }d536 42@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?