jmolHistory(false);
if (lastCommand == null || !lastCommand.equals(command))
{
- viewer.evalStringQuiet(command + "\n");
+ jmolScript(command + "\n");
}
jmolHistory(true);
lastCommand = command;
{
if (resetLastRes.length() > 0)
{
- viewer.evalStringQuiet(resetLastRes.toString());
+ jmolScript(resetLastRes.toString());
resetLastRes.setLength(0);
}
for (AtomSpec atom : atoms)
cmd.append("spacefill 200;select none");
- viewer.evalStringQuiet(cmd.toString());
+ jmolScript(cmd.toString());
jmolHistory(true);
}
private void jmolHistory(boolean enable)
{
- viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
+ jmolScript("History " + ((debug || enable) ? "on" : "off"));
}
public void loadInline(String string)
if (!atomsPicked.contains(picked))
{
- viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
+ jmolScript("select " + picked + ";label %n %r:%c");
atomsPicked.addElement(picked);
}
else
// }
if (!isLoadingFromArchive())
{
- viewer.evalStringQuiet(
+ jmolScript(
"model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
}
// register ourselves as a listener and notify the gui that it needs to
viewer.setJmolStatusListener(this); // extends JmolCallbackListener
- console = createJmolConsole(consolePanel, buttonsToShow);
+ console = null;//createJmolConsole(consolePanel, buttonsToShow);
if (consolePanel != null)
{
consolePanel.addComponentListener(this);
public void setBackgroundColour(java.awt.Color col)
{
jmolHistory(false);
- viewer.evalStringQuiet("background [" + col.getRed() + ","
+ jmolScript("background [" + col.getRed() + ","
+ col.getGreen() + "," + col.getBlue() + "];");
jmolHistory(true);
}
+ private String jmolScript(String script)
+ {
+ return viewer.scriptWait(script);
+ }
+
@Override
public int[] resizeInnerPanel(String data)
{
file.lastIndexOf("."));
String tempStructureFileStr = createNamedJvTempFile(
urlLeafName, structExt);
- UrlDownloadClient.download(file, tempStructureFileStr);
- al = fa.readFile(tempStructureFileStr, DataSourceType.FILE,
+
+ // BH - switching to File object here so as to hold
+ // ._bytes array directly
+ File tempFile = new File(tempStructureFileStr);
+ UrlDownloadClient.download(file, tempFile);
+
+ al = fa.readFile(tempFile, DataSourceType.FILE,
format);
source = fa.getAlignFile();
}
// todo get rid of Type and use FileFormatI instead?
FileFormatI fileFormat = (pdbFileFormat == Type.PDB) ? FileFormat.PDB
: FileFormat.MMCif;
- pdbAlignment = new FormatAdapter().readFile(file, DataSourceType.FILE,
+ pdbAlignment = new FormatAdapter().readFile(tmpFile, DataSourceType.FILE,
fileFormat);
if (pdbAlignment != null)
{
InputStream is = new BufferedInputStream(conn.getInputStream());
if (outFile != null)
{
+ /**@j2sNative
+ * if (outFile._isTemp) {
+ * outFile._bytes = is.$in.$in.buf;
+ * return null;
+ * }
+ */
FileOutputStream fio = new FileOutputStream(outFile);
byte[] bb = new byte[32 * 1024];
int l;
package jalview.ws.utils;
+import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
public static void download(String urlstring, String outfile)
throws IOException
{
- FileOutputStream fos = null;
- ReadableByteChannel rbc = null;
- Path temp = null;
- try
- {
- temp = Files.createTempFile(".jalview_", ".tmp");
- URL url = new URL(urlstring);
- rbc = Channels.newChannel(url.openStream());
- fos = new FileOutputStream(temp.toString());
- fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
-
- // copy tempfile to outfile once our download completes
- // incase something goes wrong
- Files.copy(temp, Paths.get(outfile),
- StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException e)
- {
- throw e;
- } finally
- {
+ FileOutputStream fos = null;
+ ReadableByteChannel rbc = null;
+ Path temp = null;
try
{
- if (fos != null)
- {
- fos.close();
- }
+ temp = Files.createTempFile(".jalview_", ".tmp");
+
+ URL url = new URL(urlstring);
+ rbc = Channels.newChannel(url.openStream());
+ fos = new FileOutputStream(temp.toString());
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+
+ // copy tempfile to outfile once our download completes
+ // incase something goes wrong
+ Files.copy(temp, Paths.get(outfile),
+ StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e)
{
- System.out.println(
- "Exception while closing download file output stream: "
- + e.getMessage());
- }
- try
+ throw e;
+ } finally
{
- if (rbc != null)
+ try
+ {
+ if (fos != null)
+ {
+ fos.close();
+ }
+ } catch (IOException e)
{
- rbc.close();
+ System.out.println(
+ "Exception while closing download file output stream: "
+ + e.getMessage());
}
- } catch (IOException e)
- {
- System.out.println("Exception while closing download channel: "
- + e.getMessage());
- }
- try
- {
- if (temp != null)
+ try
+ {
+ if (rbc != null)
+ {
+ rbc.close();
+ }
+ } catch (IOException e)
{
- Files.deleteIfExists(temp);
+ System.out.println("Exception while closing download channel: "
+ + e.getMessage());
+ }
+ try
+ {
+ if (temp != null)
+ {
+ Files.deleteIfExists(temp);
+ }
+ } catch (IOException e)
+ {
+ System.out.println("Exception while deleting download temp file: "
+ + e.getMessage());
}
- } catch (IOException e)
- {
- System.out.println("Exception while deleting download temp file: "
- + e.getMessage());
}
+
+ }
+
+ public static void download(String urlstring, File tempFile) throws IOException
+ {
+ if (/** @j2sNative 1?false: */true) {
+ download(urlstring, tempFile.toString());
}
+ // JavaScript only
+
+ /** @j2sNative
+ * tempFile._bytes = swingjs.JSUtil.getFileAsBytes(urlstring);
+ */
}
}
-20180822094549
+20180824015733
-20180822094549
+20180824015733