Facewizz Leverages JavaFX for Facial Surgery Planning


August 2013

Corrective jaw surgery and facial reconstruction typically require a fair amount of planning to help surgeons decide which surgical procedure is appropriate for a specific patient.

The traditional approach consists of drawing by hand the outline of bone tissue and soft tissue on tracing paper layered on top of a cephalogram, and then making alterations to the bone tissue based on complex calculations, which in turn result in changes to the soft tissue. The process is repeated for each set of changes a surgeon wants to explore; this method is quite resource intensive, and it should come with no surprise that members of the medical community have tried automating and simplifying the cephalogram analysis.

 Figure 1 - Lateral cephalogram with manual tracing

The Facewizz application allows surgeons to streamline the cephalometric analysis process by delegating all the cumbersome portions of the analysis to the software. With Facewizz, users can import a cephalogram picture, then trace and mark specific facial areas with easy to use tools in the application. The software is smart enough to warn the user when a specific change is not viable, and automates a good part of the process, helping the surgeon determine what jaw segments need to be moved or rotated to achieve the desired facial results. Facewizz will show how the patient’s lips, nose, and other soft tissue will react to specific changes in bone tissue. In order for the patient to see what their face is going to look after the surgical procedure, the Facewizz user can export the drawings to Photoshop, where they can be layered over pictures of the patient's face.

Facewizz not only provides a faster analysis process, but it's more accurate since the software does all the calculations. The application uses ratios between soft and hard tissues to give the surgeon immediate visual feedback of how soft tissue is going to react to changes in the bone tissue. Facewizz allows surgeons to spend more quality time studying the best surgical alternatives, since different analysis can be modified on the fly.

The application has now reached Beta and is in the process of being presented at multiple medical conferences. Feedback has also been requested from fellow surgeons and specialized medical staff. The final version of the application should be released within the next few months.

Developer’s Experience

An experienced surgeon, who has practiced and researched facial surgery for over twenty years, and who is interested in sharing his experience with his team and colleagues performing this type of procedure at hospitals across the world, has decided to have the development of the Facewizz application outsourced to Hansei BVBA, a consulting company located in Antwerp, Belgium. Mommaerts, the lead developer for the project, and an experienced Java developer in both Java EE and Java SE/Swing applications, has estimated the development effort to be between 3 and 4 man-months. Mommaerts started using Swing and Java 2D at first, but quickly ran into limitations managing animations and coordinates, making it quite cumbersome to update the scenes in the application.

That's when he decided to use JavaFX. He had previously read a blog highlighting some key features and benefits of this technology. Thanks in part to the use of properties and bindings in combination with the JavaFX scenegraph, he managed to rewrite his code in less than one day. The resulting code was not only faster to program, but also cleaner and easier to maintain. Based on this positive experience, he kept coding the application in JavaFX.

"With the combination of FXML and CSS, I was able to concentrate on the business logic of my application instead of wasting time on obscure layout issues", said Mommaerts, lead developer for Facewizz. "The declarative style of using the scenegraph and properties bindings were a perfect match for my problem space."

 Figure 2 - The Facewizz application 

The application makes extensive use of the JavaFX scenegraph, which allowed him to easily implement transformations, automatic updates, and bindings. Even with several thousand nodes running concurrently in this graphic-intensive application, performance was optimal. Managing complex scene arrangements didn’t prove to be an issue with Scenic View, a tool that let developers easily manipulate properties of the scenegraph without having to keep editing the application’s code. Mommaerts has mentioned that in order to smooth out the lines that users trace over the X-ray, each line is composed of PolyLine objects, which minimizes the node count in the scene, and improves control over how transitions are rendered (e.g.  StrokeLineCap). The entire drawing on top of the cephalogram is made of tens of object groups, so the scene graph helped him minimize the complexity of managing such a large number of transformations.

Facewizz is packaged as a self-contained application, i.e. a Java application that includes the JRE with JavaFX libraries, and therefore there is no need to have users install the JRE or update the JRE to the required version. Self-contained applications are installed like native applications, which is a process familiar to non-technical users. And since the JRE that comes bundled with it is not exposed to other Java applications, different applications can use different versions of Java, which greatly simplifies the maintenance of the end user systems.

Mommaerts found CSS skinning using JavaFX very straightforward, and much easier than trying to modify the look and feel of a Swing application. He believes that most application developers already have some experience with CSS, which means there is almost no learning curve using CSS in JavaFX. Mommaerts went one step further and used SASS (Syntactically Awesome Stylesheets) to generate the CSS for his application. SAAS is a stylesheet language that is interpreted into CSS; it extends CSS by providing several mechanisms found in more traditional programming languages, but that are not available to CSS3 itself.

Mommaerts cannot think of any issues he has with JavaFX at this point. He likes the documentation, which he prefers from the usual Java doc. Most, if not all of the issues he was interested in (and for which he's already  found workarounds in JDK 7 / JavaFX 2.2.x) have already been fixed or were in the process of being fixed in JDK 8 at the time of writing this article. Overall, the decision to move from Swing to JavaFX paid off. Although the application could have been developed in Swing, that approach would have involved more time and effort, and resulted in code that is harder to maintain. Using JavaFX simplified and expedited development and resulted in an easier to maintain application and codebase.