Note that there are some explanatory texts on larger screens.

plurals
  1. POPlotting/Working with 1million nodes
    text
    copied!<p>I am busy with an exercise to plot nodes on a pane. My first goal is to work with 1million nodes and then ramp it up to 15million. </p> <p>I have a custom Object Graph and I can add edges and nodes to this object. Each node object has an ellipse that I can call and plot and same with the edge objects. At the moment I have a function that generates a random position for the nodes.</p> <p>I am using a scroll pane at the moment to enable panning around the pane and to view all the nodes.</p> <p>What I thought was a good idea was to use a hashmap</p> <pre><code>Map&lt;String, ArrayList&lt;Node&gt;&gt; mapX = new HashMap&lt;String, ArrayList&lt;Node&gt;&gt;(); Map&lt;String, ArrayList&lt;Node&gt;&gt; mapY = new HashMap&lt;String, ArrayList&lt;Node&gt;&gt;(); </code></pre> <p>I use the following code to add nodes to the hashmap:</p> <pre><code>int tempXFloor = (int)Math.floor(tempX); ArrayList&lt;Node&gt; tempList = mapX.get(tempXFloor+""); if(tempList == null){ tempList = new ArrayList&lt;&gt;(); } tempList.add(node); mapX.put(tempXFloor+"",tempList); </code></pre> <p>Then while I am panning I get the current position, floor it and check if an entry exist in the map. if an entry exist, I add all the nodes in the ArrayList to nodesOnScreen. nodesOnScreen is an ArrayList type, and I will add the nodes to that list while I am panning and likewise the nodes that are off the screen are removed from the nodesOnScreen variable.</p> <p>I only plot the nodes that is in the ArrayList nodesOnScreen.</p> <p>I would appreciate some guidance in this matter, and how to handle such big data structures. Am I going in the right direction or am I missing an obvious "trick" to do it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload