About TSimpleGraph Lines and Objects

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

About TSimpleGraph Lines and Objects

Postby BlackJack » August 13th, 2008, 8:38 am

I have some questions about Lines and Objects,please help me.

with Lines:

1. I want connect Object A and Object B with a broken line,what should i do it?

2. I want add to some properties.
e.g:
TempStr : String;
TempInt : Integer;

with Objects:

1. Add new Objects
2. Modefy Objects
3. Add some new properties like String,Integer ... so on.

How to do it?Please show me the codes If possible,Thanks again.
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing

Postby Kambiz » August 13th, 2008, 1:28 pm

The first question:

Use InsertLink to link two objects, then use AddPoint method of created link object to add the break point.


The second question:

Define new object by subclassing from existing objects, then add your new properties to the published section of the new class. For example the following class defines a new object that defines a Reactangular node, which has a datetime property.

Code: Select all
TMyRectangularNode = class(TRectangularNode)
private
  fMyProperty: TDateTime;
protected
  property MyProperty: TDateTime read fMyProperty write fMyProperty;
end;


Don't forget to register your class.

Code: Select all
TSimpleGraph.Register(TMyRectangularNode);


There is another way to save/load custom data with each object. Take look at OnObjectWrite and OnObjectRead events of SimpleGraph.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby BlackJack » August 15th, 2008, 7:33 am

Thank you,Kambiz.

The first question i solved by your help,thanks again. =D>

But the second question i don't understand how to do it yet. :oops:

your mean create a descendants class of TRectangularNode,add some properties what i want,there is no problem.Next register my class.i want to know where i put the codes,in source or my file?

I use InsertNode to insert a object like this:
Code: Select all
 SimpleGraph.InsertNode(rect,Tmyobject);


Tmyobject is a descendants class of TRectangularNode.

but 'InsertNode' returns a object of TGraphNode,not Tmyobject,what should i do?

thanks again!
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing

Postby Kambiz » August 15th, 2008, 11:19 am

InsertNode always returns the new node as TGraphNode, which is base class for all node classes.

But you know that you have created a TMyObject, so you can easily typecast the returned value to TMyObject. For example:

Code: Select all
var MyNode: TMyObject;
MyNode := SimpleGraph.InsertNode(rect, TMyObject) as TMyObject;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby BlackJack » August 15th, 2008, 4:56 pm

Thanks very mach Kambiz, i know how to do it by your help,thanks again. =D>
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron