@@ -126,30 +126,44 @@ public JmolStatusListener getStatusListener(){
126126 public void executeCmd (String rasmolScript ) {
127127 viewer .evalString (rasmolScript );
128128 }
129-
130- public void setStructure (final Structure s )
131- {
129+
130+ public void setStructure (final Structure s , boolean useMmtf ) {
131+
132132 this .structure = s ;
133- try (
134- PipedOutputStream out = new PipedOutputStream ();
135- // Viewer requires a BufferedInputStream for reflection
136- InputStream in = new BufferedInputStream (new PipedInputStream (out ));
137- ) {
138- new Thread ((Runnable )() -> {
139- try {
140- MmtfActions .writeToOutputStream (s ,out );
141- } catch (Exception e ) {
142- logger .error ("Error generating MMTF output for {}" ,
143- s .getStructureIdentifier ()==null ? s .getStructureIdentifier ().getIdentifier () : s .getName (), e );
144- }
145- }).start ();
146- viewer .openReader (null , in );
147- } catch (IOException e ) {
148- logger .error ("Error transfering {} to Jmol" ,
149- s .getStructureIdentifier ()==null ? s .getStructureIdentifier ().getIdentifier () : s .getName (), e );
133+
134+ if (useMmtf ) {
135+ try (
136+ PipedOutputStream out = new PipedOutputStream ();
137+ // Viewer requires a BufferedInputStream for reflection
138+ InputStream in = new BufferedInputStream (new PipedInputStream (out ));
139+ ) {
140+ new Thread ((Runnable )() -> {
141+ try {
142+ MmtfActions .writeToOutputStream (s ,out );
143+ } catch (Exception e ) {
144+ logger .error ("Error generating MMTF output for {}" ,
145+ s .getStructureIdentifier ()==null ? s .getStructureIdentifier ().getIdentifier () : s .getName (), e );
146+ }
147+ }).start ();
148+ viewer .openReader (null , in );
149+ } catch (IOException e ) {
150+ logger .error ("Error transfering {} to Jmol" ,
151+ s .getStructureIdentifier ()==null ? s .getStructureIdentifier ().getIdentifier () : s .getName (), e );
152+ }
153+ } else {
154+ // Use mmCIF format
155+ String serialized = s .toMMCIF ();
156+ viewer .openStringInline (serialized );
157+
150158 }
151-
159+
152160 evalString ("save STATE state_1" );
161+
162+ }
163+
164+ public void setStructure (final Structure s ) {
165+ // Set the default to MMCIF (until issue #629 is fixed)
166+ setStructure (s , false );
153167 }
154168
155169 /** assign a custom color to the Jmol chains command.
0 commit comments