0

I'd like to implement a maximize feature (i.e. press a button and everything—all the buttons, text, the scene—gets bigger by a defined amount). To do this, I used this method recommended on another thread to set the size of my scene equal to the screen size:

sw = stage.getWidth();
sh = stage.getHeight();
Rectangle2D screen = Screen.getPrimary().getVisualBounds();

Scale scale = new Scale(screen.getWidth()/sw, screen.getHeight()/sh, 0, 0);
scene.getRoot().getTransforms().setAll(scale);

When I do this, however, all the text in my program gets fuzzy.

Original:

original

Resized:

resized

If I go all out and transform everything by a factor of 2, though, it all appears to scale nicely:

Double Sized

doubled

Why should expanding by one factor transform components in a different way than another? Is there a way to fix this or a better way to resize an entire program?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
corpico
  • 617
  • 3
  • 16
  • 26
  • I think the reason it becomes fuzzy is because you use non-integer scaling factor, which forces nodes to be sized not in whole pixels. Basically, if you have say 12 pixel line, and you want to scale it by 1.1 you would get 13.2 pixels - but the screen obviously can't render 0.2 of a pixel, so it becomes blurry. I'm not sure if there's a simple solution, though, besides creating styles with custom-defined sizes. – Itai Jul 14 '16 at 17:08
  • I thought that might be the case and cast `screen.getWidth()/sw` and `screen.getHeight()/sh` as `int` but it didn't seem to make a difference. – corpico Jul 14 '16 at 17:43

0 Answers0