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

📄 compositeobject.java~19~

📁 Java画版程序。......................要求变态。
💻 JAVA~19~
字号:
package myshape;/** * Title: * Description: * Copyright:    Copyright (c) 2002 * Company: * @author * @version 1.0 */import java.awt.*;public class CompositeObject extends MyShapeAdapter{  MyShapeAdapter first,second;  public CompositeObject() {  }  public CompositeObject(MyShape first,MyShape  second){  this.first=(MyShapeAdapter)first;  this.second=(MyShapeAdapter)second;  }  public void paint(Graphics g){    first.paint(g);    MyPoint p=second.getPoint();    first.moveObject(second,p.getX(),p.getY());    second.paint(g);  } public void setColor(Color c){  first.setColor(c);  second.setColor(c); } public MyShape getShape(){    CompositeObject o=(CompositeObject)this.clone();    o.first=(MyShapeAdapter)first.clone();    o.second=(MyShapeAdapter)second.clone();  // c.centerPoint.moveObject(centerPoint.getX()+14,centerPoint.getY()+4);  // c.endPoint.moveObject(endPoint.getX()+14,endPoint.getY()+4);   return o; } public void moveObject(int x,int y){    if(moveAll){      MyPoint p1=movedShape.getPoint();      movedShape.moveObject(x,y);      MyPoint p2=(MyPoint)second;      p2.moveObject(p2.getX()+x-p1.getX(),p2.getY()+y-p1.getY());    }    else{      first.moveObject(second,x,y);    } } private MyShape movedShape; private boolean moveAll=false; public boolean nearTo(int x,int y){ //centerPoint.attachToOthers=false;  movedShape=second;  if(second.nearTo(x,y)){     movedShape=second;     moveAll=false;     return true;  }  if(first.nearTo(x,y)){   //  centerPoint.attachToOthers=true;     movedShape=first;     moveAll=true;     return true;  }  //centerPoint.attachToOthers=true;  /*int tempx=centerPoint.getX()-x;  int tempy=centerPoint.getY()-y;  tempx=(int)(Math.sqrt(tempx*tempx+tempy*tempy)-radius);   //System.out.print("OK  "+tempx);  if(tempx<8 &&tempx>-8){     movedPoint=new MyPoint(x,y);     moveCircle=true;     return true;  }*/  return false; } public MyPoint getPoint(){   return movedShape.getPoint(); } public String toString(){   return  "CompositObjects"; }}

⌨️ 快捷键说明

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