Java Shape 질문이요 !!!
한별
그림판 만들기 하고있습니다. 툴바에 3drect 라는 버튼을 만들어서 3d 사각형을 패널에 그릴 수 있습니다.
shape라는 추상클래스를 만들어서 , 각 모양들은 이 shape를 상속받아 만들어집니다.
shape class
public abstract class geshape {
protected shape myshape;
protected point startp;
public geshape(shape shape){
this.myshape = shape;
}
public void initdraw(point startp){
this.startp = startp;
}
public void setcoordinate(point currentp){
}
public shape getshape() {
return myshape;
}
}
shape class를 상속받은 rectangle class
public class gerectangle extends geshape{
public gerectangle() {
super(new rectangle());
}
public void setcoordinate(point currentp)
{
rectangle temp = (rectangle)myshape;
temp.setframe(startp.x, startp.y, currentp.x - startp.x, currentp.y - startp.y);
}
이런식으로요.
근데 rectangle 같이 하나의 모양으로만 만들어지는 것들은
getshape로 딱 리턴되서 패널에서 쉽게 그릴 수 있는데
예를들어 3d 사각형 같은경우는 사각형 2개랑 라인 4개로 그려지는거거든요 그거는
저렇게 return myshape처럼 하나의 오브젝트로 리턴할 수 없나요 ??
쉽게말해서 라인4개랑 네모2개를 하나의 shape를 합치고 싶습니다.
어떻게 해야되나요 ??