📄 selectionarea.java,v
字号:
g.setColor(Color.black); // initialize the labels // String xmin = new String("" + this.xmin); String xmax = new String("" + this.xmax); String ymin = new String("" + this.ymin); String ymax = new String("" + this.ymax); // add the labels to the x-axis and y-axis // g.drawString(ymax, zeroX + 3, 12); g.drawString(ymin, zeroX + 3, height - 3); g.drawString(xmin, 3, zeroY + 12); g.drawString(xmax, width - 24, zeroY + 12); } /** * Gets the DisplayScale * * @@return DisplayScale of object * */ public DisplayScale getDisplayScale() { return new DisplayScale(xmax, xmin, ymax, ymin); } /** * Sets the DisplayScale * * @@param scale DisplayScale to set */ public void setDisplayScale(DisplayScale scale) { xmax = scale.xmax; xmin = scale.xmin; ymax = scale.ymax; ymin = scale.ymin; repaint(); }}@1.3log@Fixed javadoc comments.@text@d8 1d25 1a25 1class SelectionArea extends JPanel d62 1a62 1 Vector xi = new Vector(40, 20);@1.2log@comments changed to Java Documentation.@text@d4 2a17 2 * class: SelectionArea *d71 1a71 1 * method: SelectionAread73 1a73 5 * @@param Data d: input data samples * * @@return none * * constructor initializes the input samples to be plotteda102 1 * class: MyListenerd112 4a115 1 d183 4a186 1 d217 1a217 1 d219 2a220 8 * method: mouseDragged * * @@param MouseEvent e: mouse event that caused the action to fire * * @@return none * * listen and act on actions fired by components attached to the mouse *d222 1a222 1 public void mouseDragged(MouseEvent e) d288 3a290 9 /** * method: mouseMoved * * @@param MouseEvent e: mouse event that caused the action to fire * * @@return none * * listen and act on actions fired by components attached to the mouse *d296 1a296 1 d298 3a300 9 * method: mouseExited * * @@param MouseEvent e: mouse event that caused the action to fire * * @@return none * * listen and act on actions fired by components attached to the mouse * */d307 2a308 8 * method: mouseEntered * * @@param MouseEvent e: mouse event that caused the action to fire * * @@return none * * listen and act on actions fired by components attached to the mouse *d317 1a317 1 * method: paintComponentd319 1a319 5 * @@param Graphics g: graphics paint object * * @@return none * * method paints the selection aread375 1a375 8 * method: clear * * @@param Graphics g: graphics paint object * * @@return none * * method paints the selection area *d387 1a387 1 * method: getWidthd389 1a389 4 * @@param none * @@return none * * method returns the canvas widtha395 1d397 1a397 1 * method: getHeightd399 1a399 4 * @@param none * @@return none * * method returns the canvas heightd408 1a408 6 * method: DetermineDimensions * * @@param none * @@return none * * determine the dimensions of the selection aread425 2a426 7 * method: DrawGrid * * @@param none * @@return none * * draw the selection area grid lines * d484 1a484 3 * method: getDisplayScale * * @@param noned486 1a486 1 * @@return DisplayScaled495 1a495 5 * method: setDisplayScale * * @@param DisplayScale * * @@return noned497 1@1.1log@Initial revision@text@d1 4a4 2// file: SelectionArea.java//d15 11a25 8// class: SelectionArea//// SelectionArea extend a JPanle and is used to implements the plotting // area for the data input classes//// hierarchy: JPanel->SelectionArea//class SelectionArea extends JPanel {d61 1a61 1 Vector xi = new Vector(40, 20);d69 13a81 10 // method: SelectionArea // // arguments: // Data d: input data samples // // returns : none // // constructor initializes the input samples to be plotted // public SelectionArea(DataPoints d) {d97 1a97 1 addMouseMotionListener(myListener);d106 8a113 7 // class: MyListener // // class inplememts a mouse listener/motion listener for the input plot // // hierarchy: MouseAdapter->MyListener //d115 3a117 3 implements MouseListener,MouseMotionListener { a130 1 d136 2a137 2 mean = data.convertPoint(eventPoint, getWidth(), getHeight(), a138 1 a142 2 d147 2a148 2 MyPoint center = data.convertPoint(eventPoint, getWidth(), getHeight(),a149 1a154 2 a161 1 a162 1a164 1 d166 2a167 2 MyPoint center = data.convertPoint(eventPoint, getWidth(), getHeight(),a168 1 a173 1a178 1a179 1 a180 1d182 1a182 1 flag=1;a194 1 d198 2a199 1 //Classify.pro_box_d.appendMessage("x1=" +x_axis+" y1="+y_axis);d201 2a202 2 data.addPoint(data.convertPoint(eventPoint, getWidth(), getHeight(), d204 1a204 1 // System.out.println("haha"+data.dset1);d217 10a226 9 // method: mouseDragged // // arguments: // MouseEvent e: mouse event that caused the action to fire // // return : none // // listen and act on actions fired by components attached to the mouse //a232 1 d239 2a240 2 if(!(((Point)xi.lastElement()).x==((Point)xi.elementAt(xi.size()-2)).x))d242 1a242 1 //System.out.println(eventPoint);d246 8a253 5 // Classify.pro_box_d.appendMessage("x=" +x_axis+" y="+y_axis); data.addPoint(data.convertPoint(eventPoint, getWidth(), getHeight(), getDisplayScale())); repaint();d258 1a258 1 //System.out.println("Test");d262 6a267 3 //Classify.pro_box_d.appendMessage("x=" +x_axis+" y="+y_axis); //System.out.println(eventPoint); data.addPoint(data.convertPoint(eventPoint, getWidth(), getHeight(), a271 2 d277 2a278 1 mean = data.convertPoint(eventPoint, getWidth(), a280 1 a281 1 d292 13a304 11 // method: mouseMoved // // arguments: // MouseEvent e: mouse event that caused the action to fire // // return : none // // listen and act on actions fired by components attached to the mouse // public void mouseMoved(MouseEvent e) {d308 12a319 10 // method: mouseExited // // arguments: // MouseEvent e: mouse event that caused the action to fire // // return : none // // listen and act on actions fired by components attached to the mouse // public void mouseExited(MouseEvent e) {d323 10a332 9 // method: mouseEntered // // arguments: // MouseEvent e: mouse event that caused the action to fire // // return : none // // listen and act on actions fired by components attached to the mouse //d339 10a348 9 // method: paintComponent // // arguments: // Graphics g: graphics paint object // // return : none // // method paints the selection area //d360 5a364 2 Classify.drawPoints(g, data.convertMyPoints(data.dset1, getWidth(), getHeight(), getDisplayScale()), d366 5a370 2 Classify.drawPoints(g, data.convertMyPoints(data.dset2, getWidth(), getHeight(), getDisplayScale()), d372 5a376 2 Classify.drawPoints(g, data.convertMyPoints(data.dset3, getWidth(), getHeight(), getDisplayScale()), d378 5a382 2 Classify.drawPoints(g, data.convertMyPoints(data.dset4, getWidth(), getHeight(), getDisplayScale()), d401 10a410 9 // method: clear // // arguments: // Graphics g: graphics paint object // // return : none // // method paints the selection area //d420 9a428 7 // method: getWidth // // arguments: none // return : none // // method returns the canvas width //d434 9a442 7 // method: getHeight // // arguments: none // return : none // // method returns the canvas height //d448 9a456 7 // method: DetermineDimensions // // arguments: none // return : none // // determine the dimensions of the selection area //d470 9a478 7 // method: DrawGrid // // arguments: none // return : none // // draw the selection area grid lines // a507 1d513 1a513 1a520 1d534 8a541 7 // method: DisplayScale // // arguments: // none // // return: DisplayScale //d547 8a563 1a564 5//// end of file@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -