Just wanted to report a bug I found with GridLayout.
If there are only a few nodes on the Display and you are zoomed decently far back all the nodes collapse on a single point when you do GridLayout. The problem in GridLayout's analyzeGraphGrid(TupleSet ts) method and relates to how you set x after you set y.
int y = (int)width / 100;
if(y < 2) y = 2;
int x = ts.getTupleCount()/y + 1;
what happens is, if y is large enough and ts.getTupleCount is small enough, x ends up being 1 and in run:
double y = by + h*((i/n)/(double)(m-1));
ends up dividing by 0.
There are two ways to solve this that yield different results. One way is to add
if(y > ts.getTupleCount() ) y = ts.getTupleCount();
right before the x calculation which causes the layout to expand the nodes to take up the whole view (as opposed to spacing them 100 apart) or you can just make sure x > 2...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just wanted to report a bug I found with GridLayout.
If there are only a few nodes on the Display and you are zoomed decently far back all the nodes collapse on a single point when you do GridLayout. The problem in GridLayout's analyzeGraphGrid(TupleSet ts) method and relates to how you set x after you set y.
int y = (int)width / 100;
if(y < 2) y = 2;
int x = ts.getTupleCount()/y + 1;
what happens is, if y is large enough and ts.getTupleCount is small enough, x ends up being 1 and in run:
double y = by + h*((i/n)/(double)(m-1));
ends up dividing by 0.
There are two ways to solve this that yield different results. One way is to add
if(y > ts.getTupleCount() ) y = ts.getTupleCount();
right before the x calculation which causes the layout to expand the nodes to take up the whole view (as opposed to spacing them 100 apart) or you can just make sure x > 2...