import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
import jalview.gui.StructureViewer.ViewerType;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.BrowserLauncher;
+import jalview.util.ImageMaker;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.dbsources.Pdb;
private static final String SPACE = " ";
- private static final String BACKSLASH = "\"";
+ private static final String QUOTE = "\"";
AppJmolBinding jmb;
// TODO: consider waiting until the structure/view is fully loaded before
// displaying
this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
+ this.invalidate();
+ this.pack();
jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
getBounds().width, getBounds().height);
if (scriptWindow == null)
jmb.setFinishedInit(true);
}
- boolean allChainsSelected = false;
-
@Override
void showSelectedChains()
{
StringBuilder fileList = new StringBuilder();
for (String s : files)
{
- fileList.append(SPACE).append(BACKSLASH)
- .append(Platform.escapeString(s)).append(BACKSLASH);
+ fileList.append(SPACE).append(QUOTE)
+ .append(Platform.escapeString(s)).append(QUOTE);
}
String filesString = fileList.toString();
} catch (Exception ex)
{
Cache.log.error("Couldn't open Jmol viewer!", ex);
+ ex.printStackTrace();
+ return;
}
}
else
new OOMWarning("When trying to add structures to the Jmol viewer!",
oomerror);
Cache.log.debug("File locations are " + filesString);
+ return;
} catch (Exception ex)
{
Cache.log.error("Couldn't add files to Jmol viewer!", ex);
+ ex.printStackTrace();
+ return;
}
}
String file = jmb.getPdbEntry(pi).getFile();
if (file == null)
{
+ // todo: extract block as method and pull up (also ChimeraViewFrame)
// retrieve the pdb and store it locally
AlignmentI pdbseq = null;
pdbid = jmb.getPdbEntry(pi).getId();
}
if (errormsgs.length() > 0)
{
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
MessageManager.formatMessage(
"label.pdb_entries_couldnt_be_retrieved", new String[]
{ errormsgs.toString() }),
return files;
}
+ /**
+ * Outputs the Jmol viewer image as an image file, after prompting the user to
+ * choose a file and (for EPS) choice of Text or Lineart character rendering
+ * (unless a preference for this is set)
+ *
+ * @param type
+ */
@Override
- public void eps_actionPerformed(ActionEvent e)
- {
- makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
- }
-
- @Override
- public void png_actionPerformed(ActionEvent e)
- {
- makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
- }
-
- void makePDBImage(jalview.util.ImageMaker.TYPE type)
+ public void makePDBImage(ImageMaker.TYPE type)
{
int width = getWidth();
int height = getHeight();
-
- jalview.util.ImageMaker im;
-
- if (type == jalview.util.ImageMaker.TYPE.PNG)
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
- width, height, null, null, null, 0, false);
- }
- else if (type == jalview.util.ImageMaker.TYPE.EPS)
+ ImageWriterI writer = new ImageWriterI()
{
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
- width, height, null, this.getTitle(), null, 0, false);
- }
- else
- {
-
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
- width, height, null, this.getTitle(), null, 0, false);
- }
-
- if (im.getGraphics() != null)
- {
- jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
- im.writeImage();
- }
+ @Override
+ public void exportImage(Graphics g) throws Exception
+ {
+ jmb.viewer.renderScreenImage(g, width, height);
+ }
+ };
+ String view = MessageManager.getString("action.view").toLowerCase();
+ ImageExporter exporter = new ImageExporter(writer,
+ jmb.getIProgressIndicator(), type, getTitle());
+ exporter.doExport(null, this, width, height, view);
}
@Override
{
try
{
- BrowserLauncher
- .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
+ BrowserLauncher // BH 2018
+ .openURL("http://wiki.jmol.org");//http://jmol.sourceforge.net/docs/JmolUserGuide/");
} catch (Exception ex)
{
}
validate();
}
+ @SuppressWarnings("serial")
class RenderPanel extends JPanel
{
final Dimension currentSize = new Dimension();
+ public RenderPanel()
+ {
+ setPreferredSize(
+ Cache.getDefaultDim(Preferences.STRUCTURE_DIMENSIONS,
+ Preferences.DEFAULT_STRUCTURE_DIMENSIONS));
+ // BH 2019.07.12 suggesting 600,600; current is something like 347 x 323
+ }
+
@Override
public void paintComponent(Graphics g)
{
getSize(currentSize);
-
+ // BH: Note that this size could be slightly different from the size set
+ // prior to packing.
if (jmb != null && jmb.hasFileLoadingError())
{
g.setColor(Color.black);