ReliaSolve / cctbx_project

Computational Crystallography Toolbox
https://cctbx.github.io
Other
0 stars 0 forks source link

Can we convert KiNG to Javascript using SwingJS? #287

Open russell-taylor opened 7 months ago

russell-taylor commented 7 months ago

Can Swing JS (https://chemapps.stolaf.edu/swingjs/site/swingjs/examples/, https://sourceforge.net/projects/swingjs/) be used to make the KiNG molecular viewer available again on the MolProbity website? When Christopher spoke with its author at a conference last year, he implied it would be simple to implement.

The problem with KiNG is, of course, that it's in Java, and Java non grata these days. SwingJS claims to do something like provide a websafe conversion to javascript.

russell-taylor commented 6 months ago

javadev is where the KiNG code lives

russell-taylor commented 6 months ago

This uses https://github.com/BobHanson/java2script to do the JavaScript creation; it builds a JavaScript implementation that handles introspection and other Java features. It adds a plug-in to the Eclipse development environment that causes it to build a JavaScript implementation alongside the Java implementation when the project is built.

The "getting started" guide is at https://github.com/BobHanson/java2script/tree/master/sources/net.sf.j2s.core/dist

russell-taylor commented 6 months ago

@chrissciwilliams can I get you to take a look at the "getting started" guide above and see if that gets you what you need to know to do the conversion? It requires a project that can be built in Eclipse (.project file) but it looks like the project is built using Ant. I don't know Java, so don't know how much work it is to produce an Eclipse project from what is there now.

russell-taylor commented 6 months ago

Using File/New/Project and selecting "Java Project from Existing Ant Build File" and then picking the build.xml file from the king directory and the "compile" choice gets us a project. It has 100 errors and 100 warnings. The errors are objects that cannot be resolved into types. When trying to run, it is missing imports (driftwood, SoftLog) has undefined methods for KingPrefs.

vbchen commented 6 months ago

Hmm, yeah. I took a quick look myself just now and had a similar problem.

I've flirted with the idea of using Eclipse as an IDE for KiNG in the past but always had problems integrating our ant build system with the way Eclipse works. The code for KiNG is split into several different javadev directories (e.g. driftwood, molikin), each with their own build.xml file for use with Ant. KiNG can't be built without those other javadev packages being built first. When you build KiNG with Ant, Ant knows to look at the build.xml file in the KiNG directory, get the dependencies, and build them first.

How familiar are you with Eclipse? Since I don't use it I don't really understand how the projects work. How do I make the KiNG project know to build the other dependencies first? Do they have to be added as their own projects?

russell-taylor commented 6 months ago

I'm not familiar with either Java or Eclipse, though I've dabbled in each. It seems like it should be possible to make an Eclipse project that builds all of the needed subprojects, or to run ant first and then tell Eclipse where the resulting files are. I don't know how that will play with the SwingJS plug-in.

It looks like SwingJS/java2script will build a JavaScript project from the same source that it builds the JVM project from. So it isn't porting it so much as transcompiling it from the same source code. It has its own bytecode interpreter that runs when you run the app.

russell-taylor commented 5 months ago

I've tried playing around by hand adding the additional packages to the same Eclipse project as subprojects of King. I'm able to get the individual projects to resolve internally with no errors but have not figured out how to then refer to them from within King. Presumably there is some Ninja move that lets you do this all from a script but I'm hoping to just see if it can work at all.

russell-taylor commented 5 months ago

Once the other projects are included as linked projects and then hand-adjusted, the only things missing are GL2 (from jogl) and some moldb2 and maybe one other thing. Still chasing.

russell-taylor commented 4 months ago

It seems unlikely that Phenix would support such an approach going forward, so putting on the back burner.