As stated in my last article, I tried to render the writing part off screen to create an image off of it and then deform that.
This is the follow up of the previous article on resize with JavaFX. In this article I will show you how I created a Layout manager that has top and left insets which stay constant when the window is resized to a size larger than the original, but reduce proportionally if the size becomes smaller. The second point addressed here are resizable images.
From web pages this is a well known issue: You have an image gallery with many rows of pictures. Only part of them are visible in the browser. So the first images that should be loaded are the ones that are visible. With the browser technology this is not a big deal, as each resource (image) is loaded in a separate request, so the images at the top are requested first and you can start looking at the images and, when you scroll down the ones below will be loaded already.
With a desktop application this is a bit different, as you have to do something to achieve reasonable loading times. With a desktop application the the user interface is completely defined before displaying. Imagine you have loads of images that are to be loaded: The loading from your drive takes time and consumes memory. The first issue can be resolved by loading the images asynchronously, so the UI is not blocked while the images are loaded. However you might also save memory by only keep the images that are displayed in memory. This article shows how I achieved this:
For my game project OpenPatrician I use rendered image which I created using the 3D software Blender. As it is the nature of things there are many different users out there and everyone has its own screen with its own resolution. Therefor the challenge lies therein to create a game screen that uses the available space on the screen in an optimal way.
The game has some informational parts which are constant in size, but the main screen – where the actual game is happening can vary in size. Therefor it is important to be able to use an image as optimal as possible.
After serveral tries to combine Java Advanced Imaging (JAI) with a Maven project I finally succeeded. The main problem as it is often in such cases is that there is not enough documentation on the subject in the web. I am sure that countless programmer had the same problem, but after they solved the problem they did not document it or if they did their solution is unsatisfactory for an open source project (e.g. installing the JAI dependencies in your local repository). Therefore here is my solution: