Здравствуйте, впервые использую коллекции и возникло небольшое недопонимание.
Пишу простенький графический 2D редактор.
Суть: Можно рисовать точки(вершины) и соединять их линиями(ребрами). Точки можно перемещать, а линии - удалять. Динамически создаются кадры, где возможны описанные действия. Все это дело нужно уметь сохранять и загружать, в связи с чем и начал копать в сторону коллекций.
Использую FireMonkey.
Для вершин взял TSelectionPoint. С ним в принципе проблем нет.
Для линий начал было использовать TLine, но застрял на том, что у TLine явно задаётся только начальная точка в виде Pointf(X, Y), а конечной нет. Пытался играть с Height Weight и градусами поворта, но безуспешно. Как протянуть TLine из одной точки в другую?
Рисуется всё это дело на Image который создаётся для каждого кадра.
А теперь собственно проблема:

Как организовать всё это через коллекции? У меня получилась такая иерархия, но чтото мне подсказывает, что я ошибаюсь.
Код:
{TPoint Section}
TPointItem = class(TCollectionItem)
private
fPoint: TSelectionPoint;
protected
{ protected declarations }
public
{ public declarations }
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
property Point: TSelectionPoint read fPoint write fPoint;
end;
TPointsCollection = class(TCollection)
private
function GetItem(Index: Integer): TPointItem;
procedure SetItem(Index: Integer; Value: TPointItem);
public
property Items[Index: Integer]: TPointItem read GetItem write SetItem; default;
constructor Create(ItemClass: TCollectionItemClass);
function Add: TPointItem;
end;
{TLine Section}
TLineItem = class(TCollectionItem)
private
fLine: TLine;
protected
{ protected declarations }
public
{ public declarations }
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
property Point: TLine read fLine write fLine;
end;
TLinesCollection = class(TCollection)
private
function GetItem(Index: Integer): TLineItem;
procedure SetItem(Index: Integer; Value: TLineItem);
public
property Items[Index: Integer]: TLineItem read GetItem write SetItem; default;
constructor Create(ItemClass: TCollectionItemClass);
function Add: TLineItem;
end;
{TFrame Section}
TFrameItem = class(TCollectionItem)
private
fBG: TImage;
fPoints: TPointsCollection;
fLines: TLinesCollection;
protected
{ protected declarations }
public
{ public declarations }
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Show;
procedure Hide;
procedure Clear;
end;
TFramesCollection = class(TCollection)
private
function GetItem(Index: Integer): TFrameItem;
procedure SetItem(Index: Integer; Value: TFrameItem);
public
property Items[Index: Integer]: TFrameItem read GetItem write SetItem; default;
constructor Create(ItemClass: TCollectionItemClass);
function Add: TFrameItem;
end;
TFramesCon = class(TComponent)
private
fFrames: TFramesCollection;
fOwner: TComponent;
fActiveFrame: Integer;
public
destructor Destroy; override;
property Frames: TFramesCollection read fFrames write fFrames;
constructor Create(AOwner: TComponent);
function Add: TFrameItem;
end;