- Exploring NeXt UI and already have a lot of ideas but at this moment I'm investing a lot of time to find detailed documentation.
- For example:Wanted to save the initial coordinates of a node and discovered that nx.graphic.Topology.Node has a method called "setModel" which is called when the node is set (after initial layout). After knowing this, the solution is very simple:
(function(nx){ nx.define("ExtendedNode", nx.graphic.Topology.Node, { methods: { 'setModel': function (model) { this.inherited(model); this._floatX = model.x(); this._floatY = model.y(); }, }, }); })(nx);
- The API reference manual does not described this method neither in nx.graphic.Topology.Node nor in nx.graphic.Topology.AbstractNode. The method is on the source code (line 231 @ src/js/graphic/topology/node/AbstractNode.js)
- Investigating how to draw a grid (set of lines) on the topology, behind the nodes, but still looking how to achieve this...
First off, would highly recommend you to read our tutorial: GitHub - NeXt-UI/next-tutorials: Get Started with NeXt UI Toolkit
That will shed some light on how NeXt works.
Investigating how to draw a grid (set of lines) on the topology, behind the nodes, but still looking how to achieve this...
Do you need to draw the grid, or do you want to arrange the nodes inside the grid.
If you go for the first one, that would require you to create another layer and draw the lines on it.
Otherwise, you will need to create a data processor or a layout in order to make nodes be located just in the correct positions.
Not all the methods are documented there, being the "setModel" on the nx.graphic.Topology.Node one example of that. As for the grid, have already the element's position restricted to a grid. The idea is to keep the variables (_nonGridX, _nonGridY) as the position "without" the grid and restrict the element move to multiples of variable grid. Code below.
var grid = 32; (function(nx){ nx.define("ExtendedNode", nx.graphic.Topology.Node, { methods: { 'setModel': function (model) { this.inherited(model); this._nonGridX = model.x(); this._nonGridY = model.y(); }, "move": function(x, y){ var x_after = Math.round((x + this._nonGridX) / grid) * grid; var y_after = Math.round((y + this._nonGridY) / grid) * grid; if (this.x() != x_after || this.y() != y_after) { this.inherited(x_after - this.x(), y_after - this.y()); } this._nonGridX += x; this._nonGridY += y; }, } }); })(nx);
Looking to draw the grid, ideally behind all devices.
Comments
0 comments
Please sign in to leave a comment.