JInternalFrame z-order issues resolved
EBIFeching via server proxy as no access-control-origin:*
Temp file creation by File.createTempFile
Jmol app fixes for virtual key issues and starting to display now. Still
not dynamic, though. (No mouse action)
URL downloads now allow checking of status code (actually a hack, just
200 or 404, but we can get access to the real code.
jmolHistory(false);
if (lastCommand == null || !lastCommand.equals(command))
{
jmolHistory(false);
if (lastCommand == null || !lastCommand.equals(command))
{
- viewer.evalStringQuiet(command + "\n");
+ jmolScript(command + "\n");
}
jmolHistory(true);
lastCommand = command;
}
jmolHistory(true);
lastCommand = command;
{
if (resetLastRes.length() > 0)
{
{
if (resetLastRes.length() > 0)
{
- viewer.evalStringQuiet(resetLastRes.toString());
+ jmolScript(resetLastRes.toString());
resetLastRes.setLength(0);
}
for (AtomSpec atom : atoms)
resetLastRes.setLength(0);
}
for (AtomSpec atom : atoms)
cmd.append("spacefill 200;select none");
cmd.append("spacefill 200;select none");
- viewer.evalStringQuiet(cmd.toString());
+ jmolScript(cmd.toString());
private void jmolHistory(boolean enable)
{
private void jmolHistory(boolean enable)
{
- viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
+ jmolScript("History " + ((debug || enable) ? "on" : "off"));
}
public void loadInline(String string)
}
public void loadInline(String string)
if (!atomsPicked.contains(picked))
{
if (!atomsPicked.contains(picked))
{
- viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
+ jmolScript("select " + picked + ";label %n %r:%c");
atomsPicked.addElement(picked);
}
else
atomsPicked.addElement(picked);
}
else
// }
if (!isLoadingFromArchive())
{
// }
if (!isLoadingFromArchive())
{
- viewer.evalStringQuiet(
"model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
}
// register ourselves as a listener and notify the gui that it needs to
"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
viewer.setJmolStatusListener(this); // extends JmolCallbackListener
- console = createJmolConsole(consolePanel, buttonsToShow);
+ console = null;//createJmolConsole(consolePanel, buttonsToShow);
if (consolePanel != null)
{
consolePanel.addComponentListener(this);
if (consolePanel != null)
{
consolePanel.addComponentListener(this);
public void setBackgroundColour(java.awt.Color col)
{
jmolHistory(false);
public void setBackgroundColour(java.awt.Color col)
{
jmolHistory(false);
- viewer.evalStringQuiet("background [" + col.getRed() + ","
+ jmolScript("background [" + col.getRed() + ","
+ col.getGreen() + "," + col.getBlue() + "];");
jmolHistory(true);
}
+ col.getGreen() + "," + col.getBlue() + "];");
jmolHistory(true);
}
+ private String jmolScript(String script)
+ {
+ return viewer.scriptWait(script);
+ }
+
@Override
public int[] resizeInnerPanel(String data)
{
@Override
public int[] resizeInnerPanel(String data)
{
file.lastIndexOf("."));
String tempStructureFileStr = createNamedJvTempFile(
urlLeafName, structExt);
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();
}
format);
source = fa.getAlignFile();
}
// todo get rid of Type and use FileFormatI instead?
FileFormatI fileFormat = (pdbFileFormat == Type.PDB) ? FileFormat.PDB
: FileFormat.MMCif;
// 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)
{
fileFormat);
if (pdbAlignment != null)
{
InputStream is = new BufferedInputStream(conn.getInputStream());
if (outFile != 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;
FileOutputStream fio = new FileOutputStream(outFile);
byte[] bb = new byte[32 * 1024];
int l;
package jalview.ws.utils;
package jalview.ws.utils;
+import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
public static void download(String urlstring, String outfile)
throws IOException
{
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;
- 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)
{
} catch (IOException e)
{
- System.out.println(
- "Exception while closing download file output stream: "
- + e.getMessage());
- }
- try
+ try
+ {
+ if (fos != null)
+ {
+ fos.close();
+ }
+ } catch (IOException e)
+ 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);
+ */