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

📄 decisionregion.java

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA
字号:
/** * file: DecisionRegion.java * */// import necessary java libraries//import java.awt.*;import java.util.*;//These imports are not needed - Phil T. 6-23-03//import javax.swing.border.*;//import java.awt.event.*;//import javax.swing.*;/** * class: DecisionRegion * * class that stores the point of the various decision regions computed * */public class DecisionRegion implements Cloneable {    // *********************************************************************    //    // declare global variables and components    //    // *********************************************************************    // declate a vector to hold the initial guesses - means    //    public Vector<MyPoint> guesses;    // declare a vector to hold the decision region points    //    public Vector<DataSet> decisionRegion;    // *********************************************************************    //    // declare class constructors    //    // *********************************************************************    /**     * default class constructor     *     */    DecisionRegion()     {	// initialize the objects	//	decisionRegion = new Vector<DataSet>();    }    /**     * initializes the name and points included in the data set     *          * @param   String name: name of the data set     * @param   Vector vec: points included in the decision region     */    DecisionRegion(String name, Vector<MyPoint> vec)     {		// initialize the object and add the data set	//	decisionRegion = new Vector<DataSet>();	decisionRegion.addElement(new DataSet(name, vec));    }    // *********************************************************************    //    // declare class methods    //    // *********************************************************************        /**     * get the specified decision region     *     * @param  name name of the decision region     *     * @return  decision region points     */    public Vector<MyPoint> getRegion(String name)     {	// declare local variables	//	Vector<MyPoint> vec = new Vector<MyPoint>();	// check if the decision region is already present	//	for (int i = 0; i < decisionRegion.size(); i++) 	{	    // retrieve the specified data set	    //	    DataSet dataset = (DataSet)decisionRegion.elementAt(i);	    if (name.equals(dataset.getName())) 	    {		// retrieve the decision region		//		vec = (Vector<MyPoint>)dataset.getDataSet();		return vec;	    }	}		// return an empty region if it is not present	//	return vec;    }    /**     * get the number of data sets currently stored     *     * @return  the number of data sets currently stored     */    public int getNumRegions()     {	// return the number of data sets stored	//	return (int)decisionRegion.size();    }    /**     * method retrieves a given data set based on the index     *     * @param index the index of the data set     * @return a given data set based on the index     */    public Vector<MyPoint> getRegion(int index) {		// get the required data set	//	DataSet dataset = (DataSet)decisionRegion.elementAt(index);	// return the required data set	//	return (Vector<MyPoint>)dataset.getDataSet();    }    /**     * method retrieves the initial guesses - means of the data sets     *     * @return  the initial guesses - means of the data sets     */    public Vector<MyPoint> getGuesses()     {	// return the initial guesses	//	return (Vector<MyPoint>)guesses;    }    /**     * method sets the initial guesses - means of the data sets     *     * @param  vec initial guesses     */    public void setGuesses(Vector<MyPoint> vec)     {	// set the initial guesses	//	guesses = (Vector<MyPoint>)vec;    }    /**     * add a set a decision region points     *     * @param vec decision region points     */    public void addRegion(Vector<MyPoint> vec)     {	// add the data set to the existing list	//	decisionRegion.addElement(new DataSet(vec));    }    /**     * add a set a decision region points     *     * @param vec decision region points     * @param name name of the decision region     */    public void addRegion(Vector<MyPoint> vec, String name)     {	// declare local variables	//	boolean flag = false;	// check if the decision region is already present	//	for (int i = 0; i < decisionRegion.size(); i++) 	{	    // retrieve the specified data set	    //	    DataSet dataset = (DataSet)decisionRegion.elementAt(i);	    if (name.equals(dataset.getName())) 	    {		// update the decision region if already present		//		flag = true;		dataset.loadDataSet(vec);	    }	}	// if the decision region is not present then add it	//	if (!flag) 	{	    decisionRegion.addElement(new DataSet(name, vec));	}    }    /**     * add a point to the deciosion region     *     * @param p decision region point     * @param name name of the decision region     */    public void addPoint(MyPoint p, String name)     {	// declare local variables	//	boolean flag = false;	// add the point to the decision region	//	for (int i = 0; i < decisionRegion.size(); i++) 	{	    // retrieve the specified data set	    //	    DataSet dataset = (DataSet)decisionRegion.elementAt(i);	    if (name.equals(dataset.getName())) 	    {		// add the point the data set		//		flag = true;		dataset.addPoint(p);	    }	}	// if the decision region is not present then add it	//	if (!flag) 	{	    decisionRegion.addElement(new DataSet(name, p));	}    }    /**     * clears the specified decision region     *     * @param name name of the decision region     */    public void clearRegion(String name)     {	// clear the decision region	//		for (int i = 0; i < decisionRegion.size(); i++) 	{	    	    // retrieve the specified data set	    //	    DataSet dataset = (DataSet)decisionRegion.elementAt(i);	    	    if (name.equals(dataset.getName())) 	    {				// clear all point from the decision region		//		dataset.clearDataSet();	    }	}    }        /**     * clears all decision regions     *     */    public void clearAllRegions()     {	// clear all decision region	//		for (int i = 0; i < decisionRegion.size(); i++) 	{	    // retrieve the specified data set	    //	    DataSet dataset = (DataSet)decisionRegion.elementAt(i);	    // clear the data set	    //	    dataset.clearDataSet();	}	// clear all decision regions	//	if (decisionRegion.size() > 0) 	{	    decisionRegion.removeAllElements();	}    }    public Vector<DataSet> getRegions()    {	return decisionRegion;    }    public DecisionRegion copy()    {	try 	{	    return (DecisionRegion)clone();	}	catch (CloneNotSupportedException e) 	{}		return null;	    }}

⌨️ 快捷键说明

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