可我的方法是建立一个图形抽象类,然后其它图形从该类继承。
TGlyph = class
private
FSelected: Boolean;
public
procedure Draw(Canvas: TCanvas); virtual; abstract;
procedure PtIntersect(p: TPoint); virtual; abstract;
procedure Select; virtual;
procedure UnSelect; virtual;
property Selected read FSelected write FSelected;
end;
TLine = class(TGlyph)
private
FOriginPt: TPoint;
FEndPt: TPoint;
public
constructor Create(AOriginPt, AEndPt: TPoint);
procedure Draw(Canvas: TCanvas); override;
procedure PtIntersect(p: TPoint); override;
property OriginPt: TPoint read FOrignPt write FOriginPt;
property EndPt: TPoint read FEndPt write FEndPt;
end;
TRectangle = class(TGlyph)
....
...
TCircle = class(TGlyph)
....
...
这样有什么不好的地方吗?