Class JmolMolecularRenderer

java.lang.Object
org.episteme.natural.ui.viewers.chemistry.backends.JmolMolecularRenderer
All Implemented Interfaces:
MolecularRenderer

public class JmolMolecularRenderer extends Object implements MolecularRenderer
Jmol-based molecular renderer backend.

Jmol is an open-source Java viewer for chemical structures in 3D. This backend wraps the Jmol API to provide advanced molecular visualization features including:

  • High-quality ray-traced rendering
  • Script-based automation
  • Support for many file formats (PDB, CIF, MOL, XYZ, etc.)
  • Advanced selection and coloring
  • Animation and measurement tools

Requires Jmol library (jmol-*.jar) on the classpath.

* @see Jmol Project
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • JmolMolecularRenderer

      public JmolMolecularRenderer()
      Creates a new Jmol-based renderer. Falls back gracefully if Jmol is not available.
  • Method Details

    • isAvailable

      public boolean isAvailable()
      Checks if Jmol is available and initialized.
    • clear

      public void clear()
      Description copied from interface: MolecularRenderer
      Clears the current view.
      Specified by:
      clear in interface MolecularRenderer
    • setStyle

      public void setStyle(RenderStyle style)
      Description copied from interface: MolecularRenderer
      Set global rendering style.
      Specified by:
      setStyle in interface MolecularRenderer
      Parameters:
      style - The style to apply.
    • drawAtom

      public void drawAtom(Atom atom)
      Description copied from interface: MolecularRenderer
      Draw a single atom.
      Specified by:
      drawAtom in interface MolecularRenderer
      Parameters:
      atom - The atom data model.
    • drawBond

      public void drawBond(Bond bond)
      Description copied from interface: MolecularRenderer
      Draw a bond between two atoms.
      Specified by:
      drawBond in interface MolecularRenderer
      Parameters:
      bond - The bond data model.
    • setBackgroundColor

      public void setBackgroundColor(javafx.scene.paint.Color color)
      Description copied from interface: MolecularRenderer
      Set background color of the viewer.
      Specified by:
      setBackgroundColor in interface MolecularRenderer
      Parameters:
      color - JavaFX Color (Implementations may convert this).
    • getViewComponent

      public Object getViewComponent()
      Description copied from interface: MolecularRenderer
      Retrieves the native component (e.g. SubScene for JavaFX, JPanel for Swing/Jmol).
      Specified by:
      getViewComponent in interface MolecularRenderer
      Returns:
      The UI component.
    • getBackend

      public MolecularBackend getBackend()
      Description copied from interface: MolecularRenderer
      Returns the backend type of this renderer.
      Specified by:
      getBackend in interface MolecularRenderer
      Returns:
      The backend enum.
    • executeScript

      public void executeScript(String script)
      Executes a Jmol script command.
      Parameters:
      script - The Jmol script to execute
    • loadFile

      public void loadFile(String filePath)
      Loads a molecular structure from a file path.
      Parameters:
      filePath - Path to structure file (PDB, CIF, MOL, XYZ, etc.)
    • loadData

      public void loadData(String data, String format)
      Loads a molecular structure from inline data.
      Parameters:
      data - Structure data (e.g., PDB format)
      format - Format identifier (e.g., "pdb", "xyz", "mol")
    • renderImage

      public String renderImage(int width, int height)
      Renders a ray-traced image of the current view.
      Parameters:
      width - Image width
      height - Image height
      Returns:
      Path to rendered image, or null if failed
    • getJmolViewer

      public Object getJmolViewer()
      Gets the Jmol viewer instance for advanced control.
      Returns:
      The JmolViewer object, or null if not initialized