TSimpleGraph issues and suggestions
Posted: October 21st, 2005, 10:28 pm
Hi,
I have been playing with TSimpleGraph for some time and I would like to mention a few changes I have made.
1. I set "fTag: TObject;" instead of "fTag: Integer;" That way it is possible to associate graph nodes with other objects.
2. I implemented an fVAlignment property for vertical alignment of the text of a node.
3. I have made nodes "drop aware", that is, when a node is dropped over another node an event is fired and a proper event handler can be triggered.
4. There is an issue with the function TGraphNode.GetTextRect: TRect;
When zooming, at certain zoom percentages the text of a node is truncated and part of it is replaced by dots (...). I think it is related to some decimal values convetred to integers. I have quick-fixed this by setting Result.Right := MaxTextRect.Right+2; instead of conditionally calculating it.
5. There is an issue with procedure TSimpleGraph.ToggleNodesAt(const Rect: TRect; KeepOld: Boolean);
The problem is related to selecting horizontal or vertical links with a selection rectangle and the cause is the zero dy or dx, respectively. An easy workaround is to expand the bounded box of links by 1, all around.
6. Finally, I have moved some code that draws links, after code that draws nodes. That way the links are not covered by other nodes. This affects printing as well.
Thats all. I think that issues No4 and No5 affect all of us using TSimpleGraph. The other mentioned here are alterations for my own needs.
That's all. BTW, well done for this nice component.
Fotis
I have been playing with TSimpleGraph for some time and I would like to mention a few changes I have made.
1. I set "fTag: TObject;" instead of "fTag: Integer;" That way it is possible to associate graph nodes with other objects.
2. I implemented an fVAlignment property for vertical alignment of the text of a node.
3. I have made nodes "drop aware", that is, when a node is dropped over another node an event is fired and a proper event handler can be triggered.
4. There is an issue with the function TGraphNode.GetTextRect: TRect;
When zooming, at certain zoom percentages the text of a node is truncated and part of it is replaced by dots (...). I think it is related to some decimal values convetred to integers. I have quick-fixed this by setting Result.Right := MaxTextRect.Right+2; instead of conditionally calculating it.
5. There is an issue with procedure TSimpleGraph.ToggleNodesAt(const Rect: TRect; KeepOld: Boolean);
The problem is related to selecting horizontal or vertical links with a selection rectangle and the cause is the zero dy or dx, respectively. An easy workaround is to expand the bounded box of links by 1, all around.
6. Finally, I have moved some code that draws links, after code that draws nodes. That way the links are not covered by other nodes. This affects printing as well.
Thats all. I think that issues No4 and No5 affect all of us using TSimpleGraph. The other mentioned here are alterations for my own needs.
That's all. BTW, well done for this nice component.
Fotis