Thursday, January 30, 2020

TilesFX 11.30


Just found some time to update TilesFX again. Alessandro Roaro opened a pull request on github and asked for a LED tile skin. And because it was a good idea I've implemented his idea and this is what it looks like...

The LED can be switched ON/OFF by using the active property of the Tile class. The color of the LED can be set by using the activeColor property of the Tile class.

And in addition I've added another skin which is a CountdownTimerTileSkin which I thought might be useful for some people. 

Here is a little screenshot...

It shows the duration it will run and the time it will be finished. When the time is 00:00:00 it will fire an AlarmEvent that you can listen to.

When I've added the new skins to the Demo class I figured out that the RadarTileSkin and RadarNodeTileSkin did not work anymore and fixed those right away so that they are usable again...and now also support animation.

Because I'm busy and don't have a lot of time to work on TilesFX at the moment you will find the code on how to use the new skins in the Demo class that is part of the project.

As always you can find the binaries either on 

bintray or maven central

and the source on github.

That's it for keep coding...

Friday, January 17, 2020

Friday Fun LXII - Formatted text field


In the current project we had the need for a custom JavaFX text field that has the ability of formatting numbers in a specific way e.g. "0.05 EUR" or "6 years" etc.
I remembered that I did such a field long time ago and found it in on my disk. At the same time I figured out that I had never put it on here you go...

In addition there have been some special requirements like when in edit mode the units should not be visible but as soon as you leave the field they should be shown etc.

There is a gradle task to start the demo and you can execute it on the command line by typing in: 

./gradlew demo

Just make sure that you are at least on JDK 11 with OpenJFX11.

As always the code can be found on github..

That's it for keep coding...

Tuesday, December 3, 2019

Some fun with JavaFX Canvas - SpaceFX


Last weekend I decided to write a little game because I never did that before. Saturday and Sunday morning I've spend some time to create a little space game where you have to dodge asteroids or shoot them. In addition there might be enemy ships that will fire back if you are in line of sight.
To realize that game I made use of the JavaFX Canvas node which seem to be a perfect fit for games like stuff.
In the Canvas node the redraw is in your hands (more or less) but at least you can decide when to redraw and how often. So what I did was to create an AnimationTimer and simply call a draw() method as often as possible (which usually should be around 60 times per second).
In this draw method I set the coordinates of all my objects and draw them, do the collision detection and play the sounds.
For the sprites I use simple images which I've found on the internet.
Long story short, here is a little video of the game...

If you hit an asteroid or an enemy ship you will be destroyed. Also when an enemy torpedo hits you you will be destroyed. The score will always be reset to 0 when you have been destroyed and the game will start over and over I said only for the fun of it.
You can use the cursor keys to maneuver the ship and the space key to fire torpedos and that's you can see...really simple :)
If you are interested in the game you can find the source code over at github.

For those of you that are also interested in jpro (running JavaFX apps in the browser), the latest version of jpro makes it possible to also run JavaFX apps that use the Canvas node!!! Oh yeah!!!

Well after the last weekend the game now looks a bit more advanced and therefor I've created a new little video that shows the current you go...

Well that's it for keep coding...

Saturday, November 9, 2019



This morning I could not sleep and was skimming the web for new ideas where I stumbled upon a social media dashboard.
And on that dashboard I've found widgets that simply shows a social media icon with a counting number.
Well...that's an easy one I thought and quickly created a new skin for TilesFX which is the ImageCounterTileSkin.
So here is a screenshot of a little demo I quickly put together to give you an idea on what it will look like...

As you can see this tile does not show a lot but simply an image with a number and some text. Of course you can enable the title and the bottom text in the skin too but without it also looks ok.
It doesn't take a lot of code to create such a tile, here is what you need:

Tile tile = TileBuilder.create()
               .prefSize(WIDTH, HEIGHT)
               .value(0) // START VALUE
               .image(new Image("file:PATH_TO_IMAGE"))


And to make it even easier to handle it, I've added two new convenience methods to TilesFX to increase or decrease the value by a given amount.

So to increase the tiles value you simply can call


and that's it.

And because I had some time this morning I directly created a new version of TilesFX which is now 11.27 and is available here...



maven central

And with this I wish all of you a nice weekend and...keep coding...

Saturday, September 28, 2019



Back from CodeOne in San Francisco I think it's time to blog about a new skin that I've added to the library.
In my last post you saw that I was preparing a custom skin for Gluon to monitor the 1060 Raspberry Pi cluster from Oracle.
Once I saw the use case I thought it might make sense to add this skin as a regular skin to the library.
Because visualizing 1060 tiles in a dashboard was a challenge I came to the conclusion that this skin should also get the ability to reduce the details it shows when it's size goes below a given threshold (in this case 100 x 100px).
In addition I had to add several features to be able to show for example different units for the cpu/mem and temperature data.
So here are the screen shots of both modes:

As you can see the reduced version shows the text within the bar which saves some vertical space.
In addition one can add an SVG string that will be used to visualize a button (in the lower right corner). This button could for example be used to reset a single node in case it got stuck or hangs.
The new skin can now be found under the name: ClusterMonitorTileSkin and is available since version 11.13.

The latest version can be found here:

Source github

Binary bintray

That's it for keep coding...

Sunday, September 15, 2019

Custom skins for TilesFX


Today I will tell you something about customs skins for TilesFX. This year at CodeOne in San Francisco the Oracle team created a really nice Raspberry Pi SuperComputer. And for this Pi cluster the guys from Gluon created a dashboard that monitors the cpu and memory usage and also the temperature of each Pi.
Lucky me they decided to go with TilesFX to create the dashboard but they had the problem that there was no skin that was good enough to visualize the CPU and memory usage in one Tile.
So they asked me if I could help them out with a skin and so I've created the CpuMemTileSkin which looks as follows:

If you would like to make use of the skin feel free to take the code from this gist.

To use the skin you first need to set it up as follows:

Random         rnd      = new Random();
ChartData      cpuItem  = new ChartData("CPU", Bright.RED);
ChartData      memItem  = new ChartData("MEM", Bright.BLUE);
GradientLookup gradient = new GradientLookup(Arrays.asList(
    new Stop(0.0, Bright.GREEN),
    new Stop(0.4, Bright.YELLOW),
    new Stop(0.8, Bright.RED)));

Tile cpuMemTile = TileBuilder.create()
                             .prefSize(200, 200)
                             .title("Node XY")
                             .chartData(memItem, cpuItem)
cpuMemTile.setSkin(new CpuMemTileSkin(cpuMemTile);

// Creating random values for cpu and mem
double cpu = rnd.nextDouble() * 100.0;
double mem = rnd.nextDouble() * 100.0;

// Set the cpu color related to it's value and set the value
cpuItem.setFillColor(gradient.getColorAt(cpu / 100));

// Set the mem color related to it's value and set the value
memItem.setFillColor(gradient.getColorAt(mem / 100));

So you set up two ChartData objects, one for cpu and one for mem and add them to the tiles chartData property in the TileBuilder.
Then you create a GradientLookup to change the color of each bar dependent on the current value (from green over yellow to red).
When this is done you can set the color and value of each bar by changing the value of the ChartData objects and that's all you need to do to make use of the custom TilesFX skin.

I hope this will help one or the other of you and if you have created a nice TilesFX skin please let me know...I'm always keen on seeing new stuff... :)

That's it for keep coding... :)

Monday, September 9, 2019

A new skin for TilesFX


Finally found some time to add some more features to TilesFX. This time I've added a new skin to visualize timeline data. Because our son has diabetes I would like to monitor his blood glucose values more closely using my TilesFX based dashboard at home.
So I figured out that there was no really useful skin available for TilesFX that I can use. But now there is...the TimelineTileSkin.
Here is a little screenshot of the new skin:

In principle the skin looks very similar to the SparklineTileSkin but here I simply can use time based to data. There is a ChartData class in TilesFX that has a timestamp property and so instead of using the value property of the Tile class one now simply add ChartData to the Tile.
To be able to visualize time based data I've added properties for a time period and for a max time period.
On the screenshot above the timePeriod is 3 hours which means the width of the tile represents 3 hours counting from now to 3 hours back in time. Every chartData object that you add which has a timestamp that is within the last 3 hours will be drawn. The tile will keep a max no of data defined by the maxTimePeriod property. Data that is older than 3 hours will move out of the graph on the left side and new data will be added on the right side. It is also possible to define a resolution in TimeUnits.
So if you would like to visualize the last 3 hours with a resolution of minutes you can define it by setting the timePeriodResolution with TimeUnit.MINUTES.
The smallest possible resolution is seconds, even if you set it to milliseconds or smaller it will be set back to seconds.
It is possible to use seconds, minutes, days and months. 
In addition to this I've also added a lowerThreshold with a lowerThresholdColor. The threshold and the lowerThreshold will be visualized with a dashed line that will be stroked with their given colors.
One could also define Sections with colors (the two red and one green areas on the screenshot above).
On the left side of the graph you see the minimum and maximum measured value (taken from the visible values!) In this case the highest measured value within the last 3 hours has been 349.
Like with the other charts one can define a number of stops that will be used to stroke the line when strokeWithGradient == true. Otherwise it will use the barColor to stroke the line. If you enable smoothing the line between the points will be smoothed, otherwise it will simply connect the data points.
On the right side of the chart you see the minimum and maximum value of the chart (0 and 350).
The small percentage values on the left side will show how many data points that are within the timePeriod are in each section. In the screenshot above this would mean for example that 18% of all visible data points are in the green section.

I've created the TimelineTimeSkin because I have a need for it to visualize the blood glucose values of our son, meaning to say it might not fit for your needs. So please let me know if you find some bugs or if you need something else and maybe I can help you with that.

The new skin is part of the latest version 11.6 which can be found here:

I hope this additional skin might help one or the other, so that's it for today...keep coding...