Skip to content

Commit 5513872

Browse files
committed
Update README.md
1 parent 576297a commit 5513872

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,28 @@ Or by using the ```setAnchor``` function:
6262
-- Invert anchor status
6363
node:setAnchor( not node:isAnchor(), mouseX, mouseY )
6464
```
65+
66+
### Using custom classes for Nodes and Edges
67+
68+
If you prefer to not touch the default classes, you can simply inherit from them and tell Graphoon to use your custom classes instead.
69+
70+
```lua
71+
local GraphLibraryNode = require('lib.libfdgraph.fd').Node
72+
73+
local CustomNodeClass = {}
74+
75+
-- You can pass additional arguments to your custom class. Just make sure the
76+
-- default parameters ar in the right order.
77+
function CustomNodeClass.new( id, x, y, anchor, ... )
78+
local self = GraphLibraryNode.new( id, x, y, anchor )
79+
80+
-- ... Custom code
81+
end
82+
83+
return CustomNodeClass
84+
```
85+
86+
```lua
87+
local GraphLibrary = require('Graphoon').Graph
88+
GraphLibrary.setNodeClass( require('CustomNodeClass') )
89+
```

0 commit comments

Comments
 (0)