📄 mycircleaction.java~34~
字号:
package myshapeaction;/** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * @author * @version 1.0 */import java.awt.event.*;//import java.util.*;//import myframe.*;import myshape.*;import java.math.*;import java.util.*;public class MyCircleAction extends MyActionAdapter{ // private boolean canDragged=false; private MyPoint centerPoint; private MyPoint endPoint=null; private MyCirlce circle; private boolean isSecondPoint=false; public MyCircleAction() { } public boolean mousePressed(MouseEvent e,Object o){ // System.out.print("lkdflskfd"); LinkedList l=(LinkedList)o; // if(startPoint==null) endPoint=centerPoint; if(l.isEmpty()){ centerPoint=new MyPoint(e.getX(),e.getY()); } else{ centerPoint=((MyShape)l.getFirst()).getPoint(); } centerPoint.setDefaultColor(MyShape.controlColor); centerPoint.setColor(startPoint.getDefaultColor()); drawedItemList.add(centerPoint); if(!useDragged){ if(isSecondPoint){ circle=new MyCircle(endPoint,centerPoint); drawedItemList.add(circle); isSecondPoint=false; } else{ isSecondPoint=true; } } return true; } public boolean mouseDragged(MouseEvent e,Object o){ if(useDragged &¢erPoint!=null){ endPoint=new MyPoint(e.getX(),e.getY()); endPoint.setDefaultColor(MyShape.controlColor); endPoint.setColor(endPoint.getDefaultColor()); if(!endPoint.nearTo(startPoint)) { if(line!=null){ drawedItemList.removeLast(); drawedItemList.removeLast(); } Circle=new MyCircle(startPoint,endPoint); drawedItemList.add(endPoint); drawedItemList.add(circle); } } return true; } public boolean mouseReleased(MouseEvent e,Object o){ // System.out.print("lkdflskfd"); if(startPoint!=null ){ /* if(endPoint==null){ drawedItemList.removeLast(); } else if(endPoint.nearTo(centerPoint)){ drawedItemList.removeLast(); }*/ if(useDragged){ centerPoint=null; endPoint=null; } circle=null; // isSecondPoint=false; } return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -