#190 setSize doesn't touch the initialiser

open
nobody
5
2012-08-01
2012-08-01
Anonymous
No

This line in FRLayout are in setSize

if(initialized == false) {
setInitializer(new RandomLocationTransformer<V>(size));
}

and if setSize is called a second time - for example when resizing a window - the initialiser is never reset.

WORKAROUND:

1. always reset the initialiser after a setSize

or

2. subclass FRLayout (and other Layouts like it) so that setSize will reset the initialiser every time

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-08-01

    Argh - these workarounds are dubious because setInitializer() is doing a whole load of extra stuff, like resetting this.locations. A fuller workaround will also involve overriding setInitializer and might be more effort than it is worth.

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-08-01

    Sorry, I should explain why this is an issue: let's say a Layout is created to display a Graph and the user can add/remove vertices and manipulate their locations on the screen. If the user resizes the window and then adds some vertices - the newly added vertices will appear initialized within the original window bounds. Hopefully the implementation of the layout (far below AbstractLayout) will be able to do something intelligent with the locations. (But then what is the point of having the random initialiser to begin with? The definition of this.locations is essentially defining an initialiser anyway)

    As a general comment on the Layout code - it feels like a lot of funky stuff is happening with all the setX methods. It would result in much cleaner code if all this lazy initialisation was stripped out and the getters/setters were simple. I'm not entirely convinced that any great CPU optimisations are happening, but it is making the code very hard to understand. Also, no parameter constructions would be lovely! :-)

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-08-14

    sorry, small reflection mistake, the code in that part should be

    Field max_dim_field = FRLayout.class.getDeclaredField("max_dimension");
    max_dim_field.setAccessible(true);

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-08-14

    oops, wrong issue!

     

Log in to post a comment.