Search This Blog

Showing posts with label nifti. Show all posts
Showing posts with label nifti. Show all posts

Make Papaya Javascript DICOM viewer work in JavaFX WebView

When loading Papaya Javascript DICOM/NIFTI Viewer in a JavaFX WebView, it failed with error message:
Papaya requires Safari version 6 or higher.
So I checked WebKit version of JavaFX 8 using the following code:
WebView web = new WebView();
System.out.println(web.getEngine().getUserAgent());
it shows the JavaFX 8 WebKit UserAgent information:
Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.19 (KHTML, like Gecko) JavaFX/8.0 Safari/538.19
According to Safari version history, Safari 6.0 is based on WebKit 536.25, while Webkit in JavaFX 8 is 538.19. WebKit in JavaFX 8 is above Safari 6.0. The problem is the browser detection in Papaya could not detect the version. So the work around is to modify the Papaya source code to accept JavaFX 8 WebKit agent.
  1. Check out Papaya js:
    git clone https://github.com/rii-mango/Papaya.git
  2. Edit src/js/utilities/platform-utils.js, insert the following code:
    papaya.utilities.PlatformUtils.checkForBrowserCompatibility = function () {
        if (navigator.userAgent.indexOf('JavaFX')>=0) {
            return null;
        }
       ... ... ...
    }
    
  3. Download and build Papaya-builder, then install it into Papaya/lib/:
    git clone https://github.com/rii-mango/Papaya-Builder.git
    cd Papaya-Builder
    ant
    cp build/papaya-builder.jar ../Papaya/lib/
    
  4. Build Papaya:
    cd Papaya
    ./papaya-builder.sh
    ls build/