Java CAPS received Swift Certification 2009

Java CAPS, Sun’s SOA platform has been certified by Swift for 2009.  We passed the very strict Swift test suite and received the much convoyed "Financial EAI 2009" Swift label.

Java CAPS has received this certification for eleven (11) years in a row ! 

, ,

No Comments

Fun with JavaFX, how to subclass UI controls

While I was doing a JavaFX demo to a group of partners, someone asked the questions : “Does JavaFX provides more specialized UI controls, like SearchTextBox, Table etc … ?”

As of today, JavaFX 1.2 proposes this list of controls and, of course, it is relatively easy to subclass these to get the behavior you want.

But I wondered how easy it really might be, so I tried.

My goal was to create a “Search Text Box”, you know ?  These TextBoxes used in Apple’s iTunes for example to clearly indicate that this control is to search.

It has a small glass in the front of the text area and a “cancel” button appears when text is typed to allow user to reset it’s content in a click.

It took me a couple of hours to create it, here is the result on the right side.

I basically extended JavaFX 1.2 TextBox control and added two groups :

  • One is the “Cancel” button, made of gray Circle and two Rectangles
  • The other is the glass, made of one Circle and one Rectangle

I positioned these inside the TextBox, relatively to the original control’s size.

I added two callback functions to notify about possible events : new search text is available (onSearchItemAvailable) and search is reset (onResetSearch).

I finally struggled a little bit to find a way to prevent text to draw itself beneath these two icons.  It was solved using the skin’s padding-left and padding-right CSS attributes (Thanks Philippe from Sun’s Developpers Forum to point me in the right direction).

You can download the full source code here or you can start the test application directly from this page by clicking on the image below.

As usual, comments and remarks are welcome.

[UPDATE – JAVAFX 1.3]

In October 2010, Oracle released Java FX 1.3 with incompatible changes in the API.  Direct consequence is that this example is not compiling anymore.  I posted the explanation and an up-to-date version, ready for Java FX 1.3.  Have Fun !

5 Comments

21000 virtual desktops distributed at JavaONE

As every year, JavaONE attendees have access to a public set of SunRay thin clients for Internet access.

This year however, the user experience is different.  Attendees do receive access to a full, dedicated virtual machine with their OS of choice : OpenSolaris, Ubuntu or Windows Vista.

When the attendee inserts its conference card into the SunRay, he is prompted to choose a desktop, the desktop is booted in a virtual machine on one of our servers and delivered to the thin client in a couple of seconds.

When the attendee removes the smart card from the SunRay, the virtual machine is suspended and stored for later usage, the day after or later.

Each time the attendee reconnects the smart card in any of the 200 available SunRays thin clients, it receives back its very own personal virtual machine.

Wonder about the infrastructure we deployed to provide this service ?  Check out this article which goes pretty much into all the details. 

,

1 Comment

Next JUG Event : Java & Web Applications Security

The next YaJuG (the Luxembourg Java User Group) event will cover some security topics for Java developers :

  • How to  implement cryptography (encryption, key generation, signature, etc.) from within your Java applications
  • A review of the Java top-10 security breaches in your web applications.

More details and registration are available online.  Book your agendas : May, the 27th 2009

, , ,

2 Comments

JavaONE 2009

Lab 5557 : Building JavaFX clients for RESTful and JSON based web services.

I'm Speaking At JavaOne

Rich Internet Applications – RIA – do require a strong service access and data access layer located on the back-end, just as traditional or web based applications. It is therefore essential to combine desktop technologies and server technologies in order to provide fast, efficient and secure access to your data.

This lab will teach students how to combine desktop technologies, such as JavaFX™ technologies, and back-end technologies, like web services and REST based services to build state of the art desktop applications.

This lab will go through a very simple example of REST data retrieval and a Java FX graphical representation of these data.

This lab will use the following technologies :

  • RESTful web service and JSR 310 (Jersey) API on the server side
  • JavaFX on the client side

The JavaFX application will asynchronously poll RESTful web services to collect data that will be used to dynamicaly update the client rich UI.

No Comments

Patience is a vertue …. and it pays !

Since several years, Solaris x86 (and now OpenSolaris) users are complaining about the lack of a decent PDF viewer for our platform.  Surprisingly Adobe maintained up-to-date it’s SPARC version, but not the x86 version.

This is probably a sign of the OpenSolaris adoption rate : Adobe just released Acrobat Reader 9 for Solaris and OpenSolaris on x86 platforms.

Brian has the installation procedure

,

1 Comment

GlassFish Tools for Eclipse are available

Sun is making available GlassFish Tools for Eclipse (v0.9, final version to be release soon).  This is a pre-configured package containing Eclipse 3.4.1 alongside with GlassFish v2.1 and GlassFish v3 prelude and the required Eclipse plugins to effectively manage and deploy applications to GlassFish right from the IDE.

Q: Who is the target for this offering?
A: Developers or organizations that have already standardized on or prefer Eclipse over NetBeans.

Q: Why has Sun created this offering?
A: Sun has created a strong preference for GlassFish among NetBeans users. However, a large community of developers have chosen Eclipse as their IDE of choice.  Today those developers have to download open source products from multiple locations and configure them to work together (error prone), increasing the barrier to entry. This offering creates a positive feature-rich out-of-the-box experience for Eclipse developers. In additional, developers can now leverage the open source plugins created by competitive frameworks (Spring, SEAM, Hibernate, etc) within a GlassFish-focused IDE. This bundle will also improve the relationship between the community of Eclipse developers and Sun.

Q: Is Sun moving away from Netbeans towards Eclipse?
A: No. Sun is expanding its reach by embracing not just the NetBeans developer community, but also the Eclipse community. This is a consistent with Sun’s strategy of using open source to "lower the barrier to entry" – in this case to a large developer community.

, ,

No Comments

Community ONE Conference – Northen Europe

Registration is now open for Community ONE conference in europe !

Join us for a jam-packed day of education, innovation, and exchange. Come together with fellow developers and technologists to evaluate dozens of open-source projects currently powering leading Web companies, transforming enterprise IT, and enabling next-generation computing. 

I will present a JavaFX application and demonstrate how to communicate between JavaFX and REST based web services.

Seeing you in Olso !

No Comments

JavaFX within WebSpace Portlets

I am attending a WebSpace bootcamp this week, which gives me some extra time to discover Sun’s new Identity Based Content Portal.

I couldn’t resist to try to deploy my JavaFX PieChart application in a JSR 268 portlet.

Here is the result


Here are a few caveats / things to know

  • Use NetBeans’ project properties on the JavaFX side to generate the required HTML and proper embedding of the JavaFX librairies. Choose “Run” category, then specify “Run in a browser”. This will generate the HTML for you

  • Create a Web Application / JSR 268 Portlet project and copy/paste the HTML from the previous step to the portlet view JSP

  • Deploy the WAR file using Web Space admin tool (the web based Control Panel – Plugin Installer)

  • Add the portlet to an organization / community / user page.

Be careful about the path to your JAR file, it must be downloadable from your client browser. WebSpace overwrites the main context-root “/” and redirects everything to its own pages. I was lazy and just pointed to a file:/// URL 🙁

Have Fun !


,

1 Comment

Create a reusable PieChart component with JavaFX – Part II

In my previous blog entry, I described how to build a reusable PieChart component with JavaFX.

In this blog entry, we will improve the component to make it visually more appealing :

  • we will add a small space between pieces of the pie

  • we will add a 3D like effect to the component

  • we will add behavior : when the user will move the mouse over one of the piece, it will slightly step outside the chart.

End result will be like this :

Before: After:

The 3D effect

Let’s start with the simplest modification, the 3D effect.

JavaFX does provide with many lightning effects that can be applied either to simple, individual component or to complete scene.
Many of these lightning effects create 3D like effects on the component they are applied.

To achieve the effect shown above, I just added a DistantLight effect to the component, as show below.

 public override function create(): Node {
     return Group {
        content: bind ARCS;
        effect: Lighting {
           light: DistantLight {
             azimuth: 225
              elevation: 60
           }
           surfaceScale: 3
        }
    }
 }

The three first line are taken from my previous code. It creates a subclass of Node, for which the content is an array of ARC. Please read the previous blog entry to have details about this.

I added to the group an effect attribute. This attribute contains a Lighting instance which, in turn, contains a DistantLight lighting effect.

This is as simple as this, it will create the lighting and shadow effects to create the illusion of a 3D component.

Back to your Math basics

The other changes will require some math first …

We want to move a piece of the chart outside the pie chart when the mouse is over it.

Moving an Arc is easy, JavaFX provides us with many transformations, including a simple TranslateTransformation that will move the Arc from a source coordinate (a,b) to a destination coordinate (x,y).

The source point is well known, it is the center of the PieChart component. How can we compute the destination point ?

The target point dependents on two factors : the direction where we will move the piece and the distance from the center where we want to stop.

For the direction, we will use the angle in the middle of the arc, i.e. (end angle – start angle) / 2

For the distance, we will use a percentage of the radius, 15% in this case (you might wonder how I found 15% … it was using trial and mistake approach, 15% seems to give the best result, feel free to use whatever other value you like)

So, how can we compute the x,y point as destination of the Translate movement ? This is where we need to go back to our first grade math course – or – wikipedia 🙂 .

Any point on the circumference on a circle can be expressed with the following equation :

  • x = a + r cost t
  • y = b + r sin t

where (x,y) is the destination point, (a,b) is the source point, r is the radius of the circle and t the angle to (x,y) (aka the direction where we want to go)

Should I translate these equations to our PieChart component :

  • (a,b) is the center of the component

  • r is 15% of the component’s radius

  • t is (end angle – start angle) / 2

All the values are known: x,y is easy to compute !

Apply the formula in JavaFX

Now than we know how to compute the destination point of an Arc, adding the Translate transformation is relatively easy.

Let’s first define a couple of constants

 def ANIMATION_DURATION = 0.5s;
  def ANIMATION_DISTANCE = 0.15;

The distance is expressed as a percentage of the component’s radius, while the duration is expressed in seconds.

Then, in the Arc component definition, add the onMouseEntered and onMouseExited method to apply the transformation.

def ARCS: Arc[] = bind for (angle in ANGLE_VALUES) {
   (...)
    var cos = Math.cos(Math.toRadians(0 - start - angle / 2));
    var sin = Math.sin(Math.toRadians(0 - start - angle / 2));
   Arc {
   (...)    Code to define the Arc, see full code source in previous blog entry    (...)
     onMouseEntered: function(e: MouseEvent):Void {      //pie is moved to the outside of the circle      //cfr Circle equations
     var transTransition = TranslateTransition {
        duration: ANIMATION_DURATION         node: ARCS[indexof angle]         fromX: 0         fromY: 0         toX: (radius *  ANIMATION_DISTANCE) * cos;         toY: (radius *  ANIMATION_DISTANCE) * sin;      }      transTransition.play();    }
   onMouseExited: function(e: MouseEvent):Void {
      //piece if moved back to center
      var transTransition = TranslateTransition {          duration: ANIMATION_DURATION          node: ARCS[ indexof angle]          toX: 0          toY: 0          fromX: (radius *  ANIMATION_DISTANCE) * cos;          fromY: (radius *  ANIMATION_DISTANCE) * sin;       }       transTransition.play();    }  } } 

First, we compute the cos and sin values as they will be used in multiple places. We are using the java.lang.Math package for this. Note that these methods are expecting angles expressed in radians, not in degrees, hence the required conversion.

As their names implies, the onMouseEntered and onMouseExited function are called whenever the mouse enters or exists the Node where the functions are defined.

The code in these function creates a TranslateTransition object with the following properties:

  • duration: the duration to play the animation

  • node: the graphical component it applies to, in our case, the Arc we are currently building

  • fromX, fromY: the start of the transition (aka the center of the Pie Chart when the Arc is moving out)

  • toX, toY: the end coordinate of the transition, this is where we do apply our math formula : ( radius * percentage) multiplied by cos or sin, for x and y respectively.

The last line actually starts playing the transformation.

The onMouseExited method only differs by the fact we switched the from and to coordinates.

Add a small line between the pieces

I noticed that PieCharts are prettier when individual slices are separated by a couple of pixels instead of being sticked together (if you are not convinced, check the “before” and “after” screenshots above).

I first implemented this by drawing smaller Arcs, i.e. using a start angle + 1 and an end angle – 1.  This technique gives indeed a small white line between the pieces, but the line is getting smaller and smaller towards the center of the Pie, as the center stays the same for all pieces.

To get the result I wanted, I shifted the whole piece away from the center by a couple of pixels.  Each piece needs to be shifted away in different directions.  Instead of giving x,y the coordinate of the center, I am using center + …  and this is where our math basics are needed again.

We just need to apply the same equation to compute the x,y coordinate, slightly away from the center.  I chose 1% of the original radius as a distance from the center.

//center is adjusted in the direction
//of the pie to create a gap between pieces
centerX: center + (radius * 0.01) * cos
centerY: center + (radius * 0.01) * sin

The Final Touch

Now that we added a 3D like effect and a movement in and out when the mouse is over a piece of the chart … let’s add our final touch.

We will add a gentle Glow effect on a piece when the mouse is over it.

We will add a couple of lines of code in the onMouseEntered and onMouseExited created previously.

 //very discrete glow effect
  ARCS[ indexof angle]. effect = Glow {    level: 0.1;  }

level is set to 0.1 when the mouse enters the piece and set to 0 when the mouse leaves the piece.

Full source code is provided as a NetBeans project or you can start the test application directly from this page by clicking on the image below.

3 Comments