📄 datapoints.java,v
字号:
{ // local variables // double xmax, xmin, ymax, ymin; int maxsize = 0; double[] xval = null; double[] yval = null; BiNormal bn = new BiNormal(); // initialize variables // xmax = scale.xmax; xmin = scale.xmin; ymax = scale.ymax; ymin = scale.ymin; maxsize = 200; xval = new double[maxsize]; yval = new double[maxsize]; // generate the binormal gaussian random deviates // bn.gaussian( maxsize, xmin + (xmax - xmin) / 4.0, ymax - (ymax - ymin) / 4.0, xval, yval, ((0.133 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4), 0.0, 0.0, ((0.017 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4)); // format the point to be plotted on the screen // Vector<MyPoint> first = new Vector<MyPoint>(maxsize); for (int i = 0; i < maxsize; i++) { first.addElement(new MyPoint(xval[i], yval[i])); } // generate the binormal gaussian random deviates // bn.gaussian( maxsize, xmax - (xmax - xmin) / 4.0, ymin + (ymax - ymin) / 4.0, xval, yval, ((0.017 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4), 0.0, 0.0, ((0.133 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4)); // format the point to be plotted on the screen // Vector<MyPoint> second = new Vector<MyPoint>(maxsize); for (int i = 0; i < maxsize; i++) { second.addElement(new MyPoint(xval[i], yval[i])); } dset1 = first; dset2 = second; } /** * create a set of point that correspond to four ellipses to * be displayed on the input canvas * * @@param scale DisplayScale variable used for displaying * */ public void setFourEllipses(DisplayScale scale) { // local variables // double xmax, xmin, ymax, ymin; int maxsize = 0; double[] xval = null; double[] yval = null; BiNormal bn = new BiNormal(); // initialize variables // xmax = scale.xmax; xmin = scale.xmin; ymax = scale.ymax; ymin = scale.ymin; maxsize = 200; xval = new double[maxsize]; yval = new double[maxsize]; // generate the binormal gaussian random deviates // bn.gaussian( maxsize, xmax - (xmax - xmin) / 4.0, ymax - (ymax - ymin) / 4.0, xval, yval, ((0.133 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4), 0.0, 0.0, ((0.017 * (ymax - ymin)) / 4) * (((ymax - ymin)) / 4)); // format the point to be plotted on the screen // Vector<MyPoint> first = new Vector<MyPoint>(maxsize); for (int i = 0; i < maxsize; i++) { first.addElement(new MyPoint(xval[i], yval[i])); } // generate the binormal gaussian random deviates // bn.gaussian( maxsize, xmin + (xmax - xmin) / 4.0, ymax - (ymax - ymin) / 4.0, xval, yval, ((0.133 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4), 0.0, 0.0, ((0.017 * (ymax - ymin))/4) * (((ymax - ymin)) / 4)); // format the point to be plotted on the screen // Vector<MyPoint> second = new Vector<MyPoint>(maxsize); for (int i = 0; i < maxsize; i++) { second.addElement(new MyPoint(xval[i], yval[i])); } // generate the binormal gaussian random deviates // bn.gaussian( maxsize, xmin + (xmax - xmin) / 4.0, ymin + (ymax - ymin) / 4.0, xval, yval, ((0.133 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4), 0.0, 0.0, ((0.017 * (ymax - ymin)) / 4) * (((ymax - ymin)) / 4)); // format the point to be plotted on the screen // Vector<MyPoint> third = new Vector<MyPoint>(maxsize); for (int i = 0; i < maxsize; i++) { third.addElement(new MyPoint(xval[i], yval[i])); } // generate the binormal gaussian random deviates // bn.gaussian( maxsize, xmax - (xmax - xmin) / 4.0, ymin + (ymax - ymin) / 4.0, xval, yval, ((0.133 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4), 0.0, 0.0, ((0.017 * (ymax - ymin)) / 4) * (((ymax - ymin)) / 4)); // format the point to be plotted on the screen // Vector<MyPoint> forth = new Vector<MyPoint>(maxsize); for (int i = 0; i < maxsize; i++) { forth.addElement(new MyPoint(xval[i], yval[i])); } dset1 = first; dset2 = second; dset3 = third; dset4 = forth; } /** * create a set of point that correspond a toroidal to * be displayed on the input canvas * * @@param scale DisplayScale variable used for displaying * */ public void setToroidal(DisplayScale scale) { // declare variables // double xmax, xmin, ymax, ymin; Vector<MyPoint> torodial1; Vector<MyPoint> torodial2; int maxsize = 0; double[] xval = null; double[] yval = null; BiNormal bn = new BiNormal(); double angle = 0.0; double radius = 0.0; double x1 = 0.0; double y1 = 0.0; double ring_radius; double stddev_radius; int num_ring = 2000; // initialize variables // xmax = scale.xmax; xmin = scale.xmin; ymax = scale.ymax; ymin = scale.ymin; maxsize = 400; xval = new double[maxsize]; yval = new double[maxsize]; torodial1 = new Vector<MyPoint>(50, 10); torodial2 = new Vector<MyPoint>(50, 10); ring_radius = 1.5 * ((ymax - ymin)) / 4; stddev_radius = 0.1 * ((ymax - ymin)) / 4; // make outside ring // for (int i = 1; i <= num_ring; i++) { // the angle is linearly distributed from 0 to 2 pi // angle = MathUtil.random.nextDouble() * 2 * Math.PI; radius = MathUtil.grand(ring_radius, stddev_radius); // set points // x1 = radius * Math.cos(angle); y1 = radius * Math.sin(angle); // plot the points // torodial2.addElement(new MyPoint(x1 + xmin + (xmax-xmin)/2.0, y1 + ymin + (ymax-ymin)/2.0)); } // generate the binormal gaussian random deviates // bn.gaussian( maxsize, xmin + (xmax - xmin) / 2.0, ymin + (ymax - ymin) / 2.0, xval, yval, ((0.033 * (xmax - xmin)) / 4) * (((xmax - xmin)) / 4), 0.0, 0.0, ((0.033 * (xmax - xmin)) / 4) * ((xmax - xmin) / 4)); // format the point to be plotted on the screen // for (int i = 0; i < maxsize; i++) { torodial1.addElement(new MyPoint(xval[i], yval[i])); } // initialize each torodial to each set // dset1 = torodial1; dset2 = torodial2; } /** * create a set of point that correspond a yin and yang symbol to * be displayed on the input canvas * * @@param scale DisplayScale variable used for viewing * */ public void setYinYang(DisplayScale scale) { // declare variables // double xmax, xmin, ymax, ymin; Vector<MyPoint> Yin; Vector<MyPoint> Yang; double xpt = 0.0; double ypt = 0.0; double currPoints = 0; double maxPoints = 1000; double distance1 = 0.0; double distance2 = 0.0; double distance3 = 0.0; double radius1 = 0.0; double radius2 = 0.0; double stddev_center; // initialize variables // xmax = scale.xmax; xmin = scale.xmin; ymax = scale.ymax; ymin = scale.ymin; stddev_center = 1.5 * (xmax - xmin) / 2; Yin = new Vector<MyPoint>(50, 10); Yang = new Vector<MyPoint>(50, 10); radius1 = 1.5 * (((xmax - xmin))/4); radius2 = 0.75 * (((xmax - xmin))/4); while (currPoints < maxPoints) { // generate points // xpt = MathUtil.grand(xmin + (xmax-xmin)/2.0, stddev_center); ypt = MathUtil.grand(ymin + (ymax-ymin)/2.0, stddev_center); // calculate radius for each generated point // distance1 = Math.sqrt( (xpt) * (xpt) + (ypt) * (ypt)); distance2 = Math.sqrt( (xpt) * (xpt) + (ypt + radius2) * (ypt + radius2)); distance3 = Math.sqrt( (xpt) * (xpt) + (ypt - radius2) * (ypt - radius2)); // decide where to plot each point // if (distance1 <= radius1) { if (xpt >= (0.0 - radius1) && xpt <= 0.0) { if ((distance1 <= radius1 || distance2 <= radius2) && distance3 > radius2) { Yin.addElement(new MyPoint(xpt, ypt)); currPoints++; } else { Yang.addElement(new MyPoint(xpt, ypt)); } } if (xpt > 0.0 && xpt <= radius1) { if ((distance1 <= radius1 || distance3 <= radius2) && distance2 > radius2) { Yang.addElement(new MyPoint(xpt, ypt)); currPoints++; } else { Yin.addElement(new MyPoint(xpt, ypt)); } } } } // set yin and yang to each set dset1 = Yang; dset2 = Yin; } /** * Converts an instance of Point to an instance of MyPoint containing the * cartesian x-y values * * @@param jpoint Point variable used to set MyPoint * @@param panelWidth Width of viewing panel * @@param panelHeight Height of viewing panel * @@param scale DisplayScale variable used for viewing * * @@return MyPoint convertion * */ static public MyPoint convertPoint(Point jpoint, int panelWidth, int panelHeight, DisplayScale scale) { double xmax, xmin, ymax, ymin; xmax = scale.xmax; xmin = scale.xmin; ymax = scale.ymax; ymin = scale.ymin; return new MyPoint( MathUtil.SetDecimal((((double)jpoint.x/panelWidth) * (xmax-xmin)) + xmin, 8), MathUtil.SetDecimal((((panelHeight-(double)jpoint.y)/panelHeight) * (ymax-ymin)) + ymin, 8)); } /** * Converts a vector of Points to a vector of MyPoints containing the * cartesian x-y values * * @@param jset Vector of points to be converted * @@param panelWidth Width of viewing panel * @@param panelHeight Height of viewing panel * @@return Vector of MyPoints converted * */ static public Vector<MyPoint> convertPoints(Vector<Point> jset, int panelWidth, int panelHeight, DisplayScale scale) { Vector<MyPoint> dset = new Vector<MyPoint>(); for (int i = 1; i <= jset.size(); i++) { dset.addElement(convertPoint((Point)jset.elementAt(i), panelWidth, panelHeight, scale)); } return dset; } /** * Converts an instance of MyPoint to an instance of Point * * @@param dpoint MyPoint to be converted * @@param panelWidth Width of panel for viewing * @@param panelHeight Width of panel for viewing * @@return Point type converted from MyPoint type * */ static public Point convertMyPoint(MyPoint dpoint, int panelWidth, int panelHeight, DisplayScale scale) { double xmax, xmin, ymax, ymin; double xpt,ypt; Point jpoint; xmax = scale.xmax; xmin = scale.xmin; ymax = scale.ymax; ymin = scale.ymin; xpt = (panelWidth * (dpoint.x - xmin))/(xmax - xmin); ypt = panelHeight - (((dpoint.y-ymin) * panelHeight)/(ymax - ymin)); jpoint = new Point((int)xpt, (int)ypt); return jpoint; } /** * Converts a Vector of MyPoints to a Vector of points that correspond to * Java coordinates. * * @@param dset Vector of MyPoints to be converted to Vector of Points * @@param panelWidth Width of panel for viewing * @@param panelHeight Height of panel for viewing * @@return Vector of Points converted from MyPoints * */ static public Vector<Point> convertMyPoints (Vector<MyPoint> dset, int panelWidth, int panelHeight, DisplayScale scale) { double xpt, ypt; Vector<Point> jset = new Vector<Point>(); MyPoint dpoint = new MyPoint(); for (int i = 0; i < dset.size(); i++) { jset.addElement(convertMyPoint((MyPoint)dset.elementAt(i), panelWidth, panelHeight, scale)); } return jset; } /** * sets the gaussian values * * @@param points number of points * @@param cov11 double value of covariance11 * @@param cov12 double value of covariance12 * @@param cov21 double value of covariance21 * @@param cov22 double value of covariance22 * */ public void setDrawGaussValues(int points, double cov11, double cov12, double cov21, double cov22) { this.points = points; this.cov11 = cov11; this.cov12 = cov12; this.cov21 = cov21; this.cov22 = cov22; } /** * sets the gaussian values * * @@param color_dset1 color for data set 1 * @@param color_dset2 color for data set 2 * @@param color_dset3 color for data set 3 * @@param color_dset4 color for data set 4 */ public void setColors(Color color_dset1, Color color_dset2, Color color_dset3, Color color_dset4) { this.color_dset1 = color_dset1; this.color_dset2 = color_dset2; this.color_dset3 = color_dset3; this.color_dset4 = color_dset4; } }@1.3log@fixed javadoc syntax.@text@d6 1d23 1a23 1class DataPointsd46 4a49 4 Vector dset1; Vector dset2; Vector dset3; Vector dset4;d104 4a107 4 dset1 = new Vector(40, 20); dset2 = new Vector(40, 20); dset3 = new Vector(40, 20); dset4 = new Vector(40, 20);a112 5 * method: isDataValid * * @@param none * @@return boolean value *d115 1d181 1a181 1 * @@param Point p point to be added to the input data classd212 4a215 3 * @@param double point * @@param double point * @@param scale DisplayScale variable used for displayingd275 1a275 1 Vector samp = new Vector(points);d353 1a353 1 Vector first = new Vector(maxsize);d374 1a374 1 Vector second = new Vector(maxsize);d380 2a381 2 dset1 = (Vector)first.clone(); dset2 = (Vector)second.clone();d428 1a428 1 Vector first = new Vector(maxsize);d449 1a449 1 Vector second = new Vector(maxsize);d470 1a470 1 Vector third = new Vector(maxsize);d491 1a491 1 Vector forth = new Vector(maxsize);d497 4a500 4 dset1 = (Vector)first.clone(); dset2 = (Vector)second.clone(); dset3 = (Vector)third.clone(); dset4 = (Vector)forth.clone();d546 1a546 1 Vector first = new Vector(maxsize);d567 1a567 1 Vector second = new Vector(maxsize);d573 2a574 2 dset1 = (Vector)first.clone(); dset2 = (Vector)second.clone();d619 1a619 1 Vector first = new Vector(maxsize);d640 1a640 1 Vector second = new Vector(maxsize);d646 2a647 2 dset1 = (Vector)first.clone(); dset2 = (Vector)second.clone();d692 1a692 1 Vector first = new Vector(maxsize);d713 1a713 1 Vector second = new Vector(maxsize);d719 2a720 2 dset1 = (Vector)first.clone(); dset2 = (Vector)second.clone();d766 1a766 1 Vector first = new Vector(maxsize);d787 1a787 1 Vector second = new Vector(maxsize);d808 1a808 1 Vector third = new Vector(maxsize);d829 1a829 1 Vector forth = new Vector(maxsize);d835 4a838 4 dset1 = (Vector)first.clone(); dset2 = (Vector)second.clone(); dset3 = (Vector)third.clone(); dset4 = (Vector)forth.clone();d854 2a855 2 Vector torodial1; Vector torodial2;d877 2a878 2 torodial1 = new Vector(50, 10); torodial2 = new Vector(50, 10);d924 2a925 2 dset1 = (Vector)torodial1.clone(); dset2 = (Vector)torodial2.clone();d941 2a942 2 Vector Yin; Vector Yang;d961 2a962 2 Yin = new Vector(50, 10); Yang = new Vector(50, 10);d1029 2a1030 3 // dset1 = (Vector)Yang.clone(); dset2 = (Vector)Yin.clone();d1072 1a1072 2 static public Vector convertPoints(Vector jset, int panelWidth, int panelHeight, DisplayScale scale)d1074 1a1074 1 Vector dset = new Vector();d1078 1a1078 2 dset.addElement(convertPoint((Point)jset.elementAt(i), panelWidth, panelHeight, scale));d1122 1a1122 2 static public Vector convertMyPoints (Vector dset, int panelWidth, int panelHeight, DisplayScale scale)d1125 1a1125 1 Vector jset = new Vector();d1159 1a1159 1 * method: setColorsa1164 4 * @@return none * * sets the gaussian values *@1.2log
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -