📄 mypoint.java~31~
字号:
package myshape;/** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * @author * @version 1.0 */import java.awt.*;public class MyPoint extends MyShapeAdapter{ private int x,y; //private MyCircle c; // private boolean attachToOthers=false; public MyPoint() { } public MyPoint(int x,int y){ this.x=x; this.y=y; //attachToOthers=attached; } private Color color=super.defaultColor; private Color defaultColor=super.defaultColor; public void setColor(Color c){ color=c; } public Color getColor(){ return color; } public void setDefaultColor(Color c){ defaultColor=c; } public Color getDefaultColor(){ return defaultColor; } public void paint(Graphics g){ g.setColor(color); g.fillOval(x-2,y-2,4,4); } public MyShape getShape(){ MyPoint p=(MyPoint)this.clone(); // p.moveObject(x+4,y+4); return p; } public int getX(){ return x; } public int getY(){ return y; } public boolean nearTo(MyPoint p){ int tempx=this.x-p.getX(); int tempy=this.y-p.getY(); if(tempx*tempx+tempy*tempy<4) return true; return false; } public String toString(){ String s="点 "; return s; } public void setAttach( ){ } public void moveObject(int x,int y){ this.x=x; this.y=y; } public boolean nearTo(int x,int y){ if(this.attachToOthers) return false; int tempx=this.x-x; int tempy=this.y-y; if(tempx*tempx+tempy*tempy<8) return true; return false; } public MyPoint getPoint(){ return this; }// public boolean moveFreely=true;// public boolean moveFo=true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -