Friday, September 24, 2010

The JavaFX 2.0 Roadmap

Apparently some major changes are waiting around the corner regarding JavaFX with the up and coming version 2.0. Had a look at the roadmap today and have been checking out various blogs about the topic.

My (noobish but still) impression is that things definitely are going in the right direction. One problem though with the road map is that it promises loads of exciting things but not so much in there about how all these goals are going to be accomplished. It is kind of like my wishlist for Christmas when I was smaller, loads of great stuff on it and marvelous plans in my head about what I would do with all my presents. But then much to often I ended up sitting there with a new pair of socks, another silver spoon for the collection and finally some crayons with accompanied drawing-papers. The paper was always the gray cheap one made from recycled newspapers or something.

Guess my personal roadmap must be revised a little now. Probably going to focus more now on filling up some of the many gaps in my Java-knowledge while waiting for Oracle to deliver that remote controlled super fast airplane that will change my world to a much better place.

Wednesday, August 18, 2010

First real application

Have finished and published my first real JavaFX program. My previous work have only been small projects to test things in JavaFX. But now I also have produced a small application that actually serves a purpose.

The application can be tested here.

The application is a tool used for improving your poker playing skills. Lets start out with a picture of the application.

The type of poker game is Texas Hold'em. In this game every player gets two starting cards. These two cards can form 169 different starting hands that all are represented in the grid in the picture. A3s for example means an ace and a three in the same suite (both being hearts or spades for example). A3 with out a trailing s means ace and three of different suites.

Below the grid of hands we have a slider. The slider controls the number of hands selected going from 0 to 100% of the hands. Starting out by choosing top hands (according to another software called Poker Stove) and then including worse and worse hands.

In the example above the top 17.9 percent of the starting hands are selected and hence displayed in black.

It is common to use special poker trackers that store information about opponents playing style when playing poker on line. These trackers for example present information of which percentage a player opens with a bet in certain situations. This percentage of hands can be chosen with the slider in application. And the range of hands that equals this percentage is then visualized.

Have tested to access the application on the web site from a couple of different computers and it seems to take about ten seconds or so to load which I find acceptable.

Monday, July 26, 2010

Animations test

Tried out some animation concepts. Nothing fancy but hey must start somewhere.

Used the JavaFX Composer in NetBeans. Have a text that says Berra (my nick name) and a button. There are then two states. In the start state things look like this.

Pressing the button causes the text to fall down rapidly. The fall stops when the bottom is almost reached.

The first button is replaced with another button that makes the text go up but with less speed than it went down. Once the text is up again the original button comes back and things start over.

Complete source code here.

Thursday, July 1, 2010

Project Poker Part 6

Moving on a little with my poker application.

One thing missing is a panel used to display information about a player. The minimal compulsory set of player data is made up of the name which identifies a player and the number of chips the player has. Have now designed a panel that can be used to display this set of data.

The name of the player is displayed with the use of a Label, that is centered by the use of a Stack layout. Should a player have a too long name so will it be cut and ended off with a ellipsis.

The chip count is also represented with the us of a Label. This means that if a player should have a really large amount of chips so will the number of chips be cut off like for the name of the player. This is not the desired behavior. Will have to fix this later, but not really a prioritized thing right now since there are loads of other things to do.

Saturday, June 26, 2010


Have been playing around a bit with the JavaFX slider control. Used two sliders in the following example. There is a text that is lighted by a red light source. The azimuth and elevation of the light is controlled by the two sliders.

The source code for the example can be found here.

Noted that the right pointing arrow key on the keyboard will change the focus form the vertical slider to the horizontal slider. The arrow key that points upward will set focus on the vertical slider. The left and down arrows will however strangely enough not have this effect.

Another strange thing is that markings on the vertical slider seems to be reversed. The starting position of the vertical slider is set to 135 in the code, but the markers indicates that it is set to 45 when running the code. I do not think that the bug is in my code. It is probably instead a resident somewhere in javafx.scene.control.Slider package.

Saturday, June 19, 2010

Project Poker Part 5

Moving on today working a little bit on my poker table. Had already done a frame for the table. Added a background filled with a bluish gradient, trying to match the color of the frame. Finally placed five cards on the table, like there will be when playing Omaha for example.

Starting to get a little collections of parts that can be combined in different ways now. Must start documenting and place my code in a library, not as fun as developing new things but must be done - sigh.

Friday, June 18, 2010

Project Poker Part 4

The progress do fare with my poker software is that it now exists a set of cards. Time to make a table to have somewhere to place the cards.

Lets seek some inspiration from the giant of on line poker - PokerStars. One of the layouts available on PokerStars looks like this.

Now knowing kind of what I want its time to go to work. Lets start by coding the frame around the table. This would on a real poker table consist of padded oval where the players can rest their arms. So what is needed is some kind of an ellipse. It should also have some effect applied to it to make it look cuddly and filled with padding.

Probably many ways to code the frame but one solution is to do it in four steps like this:

1. Start out with a rectangle with very rounded corners.

def outerTableFrame = Rectangle {
            x: 10, y: 10
            width: 500, height: 250
            arcWidth: 250, arcHeight: 250
            fill: Color.GREEN

2. Then take another smaller rectangle and place it on the first rectangle

def innerTableFrame = Rectangle {
            x: 25, y: 25
            width: 470, height: 220
            arcWidth: 220, arcHeight: 220
            fill: Color.PINK

3. Make a new shape by using ShapeSubtract. The pink parts will be "subtracted" from the green parts which will result in a new shape consisting of the green rectangle not covered by the pink rectangle. (Note that the color also changes, probably because black i set to default color in the ShapeSubtract class)

var tableFrame: Shape = ShapeSubtract {
            a: outerTableFrame
            b: innerTableFrame

4. Make the frame look padded by applying a Ligthning effect. Finally choose a color, in this case blue since it seems to be the color of JavaFX

var tableFrame: Shape = ShapeSubtract {
            a: outerTableFrame
            b: innerTableFrame
            effect: Lighting {
                diffuseConstant: 1.0
                specularConstant: 1.0
                specularExponent: 20
                surfaceScale: 1.5
            fill: Color.DARKBLUE

See the complete source code here.