JavaFX/Webview not loading Stone web viewer

226 views
Skip to first unread message

Charles Waweru

unread,
Jul 7, 2021, 12:11:43 PM7/7/21
to Orthanc Users

Hi all,

Our team is trying to load the Stone Web Viewer via JavaFX/Webview/WebEngine. The Webview component loads the Orthanic explorer succesfully and allows us to select a patient and the target study. However, the Stone Web Viewer starts to load but does not dispaly the images. The images can be viewed successfully on regular browsers.

We have noticed that Orthanc Web Browser loads the static images successfully. I have attached snapshots of the screens that we are getting.

Can the JavaFX/Webview component work for us that way?

Thank you,

Charles

Snapshots

Stone Web Viewer loads study images from Orthanc server properly on regular browsers
Stone web browser on regular browser.jpg

Orthanc explorer loads successfully on JavaFX/Webview. The patient and studies can be selected
JavaFX Web Viewer orthanc explorer.jpg

Illustration of Orthanc Web Viewer on JavaFX/Webview
JavaFx loads Orthanc Web Viewer.jpg

Below is the snapshot of Stone Web Viewer on JavaFX/Webview
Stone Web Viewer on JavaF Webview.jpg

My Java code:
package com.afrisoftech.pacs;

//import OpenUrlInJFrameAction;
import java.awt.Toolkit;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.web.WebView;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.swing.JButton;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.SwingUtilities;

/**
 *
 * @author
 */
public class PacsViewerMain extends javax.swing.JFrame {

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("pACS Viewer");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGap(0, 833, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGap(0, 406, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
//        SwingUtilities.invokeLater(() -> {
            PacsViewerMain jFrameTest = new PacsViewerMain();
            jFrameTest.setDefaultCloseOperation(EXIT_ON_CLOSE);
            jFrameTest.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
            JFXPanel jfxPanel = new JFXPanel();
            jFrameTest.add(jfxPanel);

            Platform.runLater(() -> {
//                jFrameTest.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize());
                jFrameTest.setVisible(true);
                WebView webView = new WebView();
                jfxPanel.setScene(new Scene(webView));
                // Create a trust manager that does not validate certificate chains
                TrustManager[] trustAllCerts = new TrustManager[]{
                    new X509TrustManager() {
                        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                            return null;
                        }

                        public void checkClientTrusted(
                                java.security.cert.X509Certificate[] certs, String authType) {
                        }

                        public void checkServerTrusted(
                                java.security.cert.X509Certificate[] certs, String authType) {
                        }
                    }
                };

// Install the all-trusting trust manager
                try {
                    SSLContext sc = SSLContext.getInstance("SSL");
                    sc.init(null, trustAllCerts, new java.security.SecureRandom());
                    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
                } catch (GeneralSecurityException e) {
                }
                webView.getEngine().setJavaScriptEnabled(true);
                webView.getEngine().getCreatePopupHandler(); //setOnAlert(null);
                webView.getEngine().load("http://funsoft.systempartners.biz:8042/app/explorer.html#study?uuid=27f7126f-4f66fb14-03f4081b-f9341db2-53925988");
            });
//        });
    }

    private Scene createScene() {
        Group root = new Group();
        Scene scene = new Scene(root, Color.ALICEBLUE);
        Text text = new Text();

        text.setX(40);
        text.setY(100);
        text.setFont(new Font(25));
        text.setText("Welcome JavaFX!");

        root.getChildren().add(text);

        return (scene);
    }
    // Variables declaration - do not modify                     
    // End of variables declaration                   
}

Sébastien Jodogne

unread,
Jul 8, 2021, 1:49:57 AM7/8/21
to Orthanc Users
Hello,

From what you describe, it looks like JavaFX/WebView does *not* support WebAssembly, upon which the Stone Web viewer is built:

Get in touch with the support team of JavaFX for a confirmation.

Regards,
Sébastien-
Reply all
Reply to author
Forward
0 new messages