/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.gui;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.io.FileLoader;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.jbgui.GSplitFrame;
+import jalview.jbgui.GStructureViewer;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.ImageMaker;
import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.ParamManager;
import java.awt.BorderLayout;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
-import javax.swing.event.HyperlinkEvent.EventType;
/**
* Jalview Desktop
*/
private BlogReader jvnews = null;
+ private File projectFile;
+
/**
* @param listener
* @see jalview.gui.JalviewChangeSupport#addJalviewPropertyChangeListener(java.beans.PropertyChangeListener)
static final int yOffset = 30;
+ private static final int THREE = 3;
+
+ private static AlignFrame currentAlignFrame;
+
public static jalview.ws.jws1.Discoverer discoverer;
public static Object[] jalviewClipboard;
instance = this;
doVamsasClientCheck();
doGroovyCheck();
-
+ doConfigureStructurePrefs();
setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",
else
{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- setBounds((int) (screenSize.width - 900) / 2,
- (int) (screenSize.height - 650) / 2, 900, 650);
+ setBounds((screenSize.width - 900) / 2,
+ (screenSize.height - 650) / 2, 900, 650);
}
jconsole = new Console(this, showjconsole);
// add essential build information
- jconsole.setHeader("Jalview Desktop "
+ jconsole.setHeader("Jalview Version: "
+ jalview.bin.Cache.getProperty("VERSION") + "\n"
- + "Build Date: "
+ + "Jalview Installation: "
+ + jalview.bin.Cache.getDefault("INSTALLATION", "unknown")
+ + "\n" + "Build Date: "
+ jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + "\n"
+ "Java version: " + System.getProperty("java.version") + "\n"
+ System.getProperty("os.arch") + " "
});
}
+ public void doConfigureStructurePrefs()
+ {
+ // configure services
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(this);
+ if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
+ {
+ ssm.setAddTempFacAnnot(jalview.bin.Cache.getDefault(
+ Preferences.ADD_TEMPFACT_ANN, true));
+ ssm.setProcessSecondaryStructure(jalview.bin.Cache.getDefault(
+ Preferences.STRUCT_FROM_PDB, true));
+ ssm.setSecStructServices(jalview.bin.Cache.getDefault(
+ Preferences.USE_RNAVIEW, true));
+ }
+ else
+ {
+ ssm.setAddTempFacAnnot(false);
+ ssm.setProcessSecondaryStructure(false);
+ ssm.setSecStructServices(false);
+ }
+ }
+
public void checkForNews()
{
final Desktop me = this;
public void run()
{
long instance = System.currentTimeMillis();
- Desktop.instance.setProgressBar("Refreshing news", instance);
+ Desktop.instance.setProgressBar(
+ MessageManager.getString("status.refreshing_news"),
+ instance);
jvnews.refreshNews();
Desktop.instance.setProgressBar(null, instance);
jvnews.showNews();
* Adds and opens the given frame to the desktop
*
* @param frame
- * DOCUMENT ME!
+ * Frame to show
* @param title
- * DOCUMENT ME!
+ * Visible Title
* @param w
- * DOCUMENT ME!
+ * width
* @param h
- * DOCUMENT ME!
+ * height
*/
public static synchronized void addInternalFrame(
final JInternalFrame frame, String title, int w, int h)
{
- addInternalFrame(frame, title, w, h, true);
+ addInternalFrame(frame, title, true, w, h, true);
}
/**
- * DOCUMENT ME!
+ * Add an internal frame to the Jalview desktop
*
* @param frame
- * DOCUMENT ME!
+ * Frame to show
* @param title
- * DOCUMENT ME!
+ * Visible Title
+ * @param makeVisible
+ * When true, display frame immediately, otherwise, caller must call
+ * setVisible themselves.
* @param w
- * DOCUMENT ME!
+ * width
* @param h
- * DOCUMENT ME!
+ * height
+ */
+ public static synchronized void addInternalFrame(
+ final JInternalFrame frame, String title, boolean makeVisible,
+ int w, int h)
+ {
+ addInternalFrame(frame, title, makeVisible, w, h, true);
+ }
+
+ /**
+ * Add an internal frame to the Jalview desktop and make it visible
+ *
+ * @param frame
+ * Frame to show
+ * @param title
+ * Visible Title
+ * @param w
+ * width
+ * @param h
+ * height
* @param resizable
- * DOCUMENT ME!
+ * Allow resize
*/
public static synchronized void addInternalFrame(
final JInternalFrame frame, String title, int w, int h,
boolean resizable)
{
+ addInternalFrame(frame, title, true, w, h, resizable);
+ }
+
+ /**
+ * Add an internal frame to the Jalview desktop
+ *
+ * @param frame
+ * Frame to show
+ * @param title
+ * Visible Title
+ * @param makeVisible
+ * When true, display frame immediately, otherwise, caller must call
+ * setVisible themselves.
+ * @param w
+ * width
+ * @param h
+ * height
+ * @param resizable
+ * Allow resize
+ */
+ public static synchronized void addInternalFrame(
+ final JInternalFrame frame, String title, boolean makeVisible,
+ int w, int h, boolean resizable)
+ {
// TODO: allow callers to determine X and Y position of frame (eg. via
// bounds object).
openFrameCount++;
- frame.setVisible(true);
+ frame.setVisible(makeVisible);
frame.setClosable(true);
frame.setResizable(resizable);
frame.setMaximizable(resizable);
{
new FileLoader().LoadFile(viewport, choice, FormatAdapter.FILE,
format);
+ // viewport.setShowSequenceFeatures(JSONFile.isSeqFeaturesEnabled());
+ // AlignFrame af = viewport.getAlignPanel().alignFrame;
+ // if (af != null)
+ // {
+ // af.changeColour(JSONFile.getColourScheme());
+ // af.setMenusForViewport();
+ // }
}
else
{
if (format.equals("URL NOT FOUND"))
{
JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Couldn't locate " + url, "URL not found",
+ MessageManager.formatMessage("label.couldnt_locate",
+ new Object[]
+ { url }), MessageManager
+ .getString("label.url_not_found"),
JOptionPane.WARNING_MESSAGE);
return;
public void inputTextboxMenuItem_actionPerformed(AlignViewport viewport)
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
- cap.setForInput(viewport);
- Desktop.addInternalFrame(cap, "Cut & Paste Alignment File", 600, 500);
+// cap.setForInput(viewport.getAlignPanel());
+ cap.setForInput(null);
+ Desktop.addInternalFrame(cap,
+ MessageManager.getString("label.cut_paste_alignmen_file"),
+ true, 600, 500);
}
/*
{
dialogExecutor.shutdownNow();
}
-
+ closeAll_actionPerformed(null);
System.exit(0);
}
if (shortv)
{
message.append("<h1><strong>Version: "
- + jalview.bin.Cache.getProperty("VERSION")
- + "</strong></h1>");
+ + jalview.bin.Cache.getProperty("VERSION") + "</strong></h1>");
message.append("<strong>Last Updated: <em>"
+ jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")
+ "</em></strong>");
}
message.append("<br>Authors: "
+ jalview.bin.Cache
- .getDefault(
- "AUTHORFNAMES",
+ .getDefault("AUTHORFNAMES",
"The Jalview Authors (See AUTHORS file for current list)")
+ "<br><br>Development managed by The Barton Group, University of Dundee, Scotland, UK.<br>"
+ "<br><br>For help, see the FAQ at <a href=\"http://www.jalview.org/faq\">www.jalview.org/faq</a> and/or join the jalview-discuss@jalview.org mailing list"
{
try
{
- ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
- java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
- javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
-
- javax.help.HelpBroker hb = hs.createHelpBroker();
- hb.setCurrentID("home");
- hb.setDisplayed(true);
+ Help.showHelpWindow();
} catch (Exception ex)
{
}
return;
}
- AlignViewport source = null, target = null;
+ AlignmentViewport source = null, target = null;
if (frames[0] instanceof AlignFrame)
{
source = ((AlignFrame) frames[0]).getCurrentView();
{ "Jalview Project" }, "Jalview Project");
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Save State");
+ chooser.setDialogTitle(MessageManager.getString("label.save_state"));
int value = chooser.showSaveDialog(this);
{
final Desktop me = this;
final java.io.File choice = chooser.getSelectedFile();
+ setProjectFile(choice);
+
new Thread(new Runnable()
{
public void run()
{
- setProgressBar("Saving jalview project " + choice.getName(),
- choice.hashCode());
+ setProgressBar(MessageManager.formatMessage(
+ "label.saving_jalview_project", new Object[]
+ { choice.getName() }), choice.hashCode());
jalview.bin.Cache.setProperty("LAST_DIRECTORY",
choice.getParent());
// TODO catch and handle errors for savestate
// TODO prevent user from messing with the Desktop whilst we're saving
try
{
- new Jalview2XML().SaveState(choice);
+ new Jalview2XML().saveState(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst saving current state to "
Cache.log.error(
"Problems whilst trying to save to " + choice.getName(),
ex);
- JOptionPane.showMessageDialog(
- me,
- "Error whilst saving current state to "
- + choice.getName(), "Couldn't save project",
+ JOptionPane.showMessageDialog(me, MessageManager.formatMessage(
+ "label.error_whilst_saving_current_state_to",
+ new Object[]
+ { choice.getName() }), MessageManager
+ .getString("label.couldnt_save_project"),
JOptionPane.WARNING_MESSAGE);
}
setProgressBar(null, choice.hashCode());
}
}
+ private void setProjectFile(File choice)
+ {
+ this.projectFile = choice;
+ }
+
+ public File getProjectFile()
+ {
+ return this.projectFile;
+ }
+
/**
* DOCUMENT ME!
*
{ "Jalview Project", "Jalview Project (old)" },
"Jalview Project");
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Restore state");
+ chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
int value = chooser.showOpenDialog(this);
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- final String choice = chooser.getSelectedFile().getAbsolutePath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
- .getSelectedFile().getParent());
+ final File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ final String choice = selectedFile.getAbsolutePath();
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY",
+ selectedFile.getParent());
new Thread(new Runnable()
{
public void run()
{
- setProgressBar("loading jalview project " + choice,
- choice.hashCode());
+ setProgressBar(MessageManager.formatMessage(
+ "label.loading_jalview_project", new Object[]
+ { choice }), choice.hashCode());
try
{
- new Jalview2XML().LoadJalviewAlign(choice);
+ new Jalview2XML().loadJalviewAlign(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst loading project from " + choice, oom);
{
Cache.log.error("Problems whilst loading project from "
+ choice, ex);
- JOptionPane.showMessageDialog(Desktop.desktop,
- "Error whilst loading project from " + choice,
- "Couldn't load project", JOptionPane.WARNING_MESSAGE);
+ JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+ .formatMessage(
+ "label.error_whilst_loading_project_from",
+ new Object[]
+ { choice }), MessageManager
+ .getString("label.couldnt_load_project"),
+ JOptionPane.WARNING_MESSAGE);
}
setProgressBar(null, choice.hashCode());
}
{
if (fileLoadingCount == 0)
{
- fileLoadingPanels.add(addProgressPanel("Loading File: " + fileName
- + " "));
+ fileLoadingPanels.add(addProgressPanel(MessageManager.formatMessage(
+ "label.loading_file", new Object[]
+ { fileName })));
}
fileLoadingCount++;
}
public static int getViewCount(String alignmentId)
{
- AlignViewport[] aps = getViewports(alignmentId);
+ AlignmentViewport[] aps = getViewports(alignmentId);
return (aps == null) ? 0 : aps.length;
}
/**
*
* @param alignmentId
+ * - if null, all sets are returned
* @return all AlignmentPanels concerning the alignmentId sequence set
*/
public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
{
- int count = 0;
if (Desktop.desktop == null)
{
// no frames created and in headless mode
// TODO: verify that frames are recoverable when in headless mode
return null;
}
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
- ArrayList aps = new ArrayList();
- for (int t = 0; t < frames.length; t++)
+ List<AlignmentPanel> aps = new ArrayList<AlignmentPanel>();
+ AlignFrame[] frames = getAlignFrames();
+ if (frames == null)
+ {
+ return null;
+ }
+ for (AlignFrame af : frames)
{
- if (frames[t] instanceof AlignFrame)
+ for (AlignmentPanel ap : af.alignPanels)
{
- AlignFrame af = (AlignFrame) frames[t];
- for (int a = 0; a < af.alignPanels.size(); a++)
+ if (alignmentId==null || alignmentId.equals(ap.av.getSequenceSetId()))
{
- if (alignmentId.equals(((AlignmentPanel) af.alignPanels
- .elementAt(a)).av.getSequenceSetId()))
- {
- aps.add(af.alignPanels.elementAt(a));
- }
+ aps.add(ap);
}
}
}
{
return null;
}
- AlignmentPanel[] vap = new AlignmentPanel[aps.size()];
- for (int t = 0; t < vap.length; t++)
- {
- vap[t] = (AlignmentPanel) aps.get(t);
- }
+ AlignmentPanel[] vap = aps.toArray(new AlignmentPanel[aps.size()]);
return vap;
}
* get all the viewports on an alignment.
*
* @param sequenceSetId
- * unique alignment id
+ * unique alignment id (may be null - all viewports returned in that
+ * case)
* @return all viewports on the alignment bound to sequenceSetId
*/
- public static AlignViewport[] getViewports(String sequenceSetId)
+ public static AlignmentViewport[] getViewports(String sequenceSetId)
{
- Vector viewp = new Vector();
+ List<AlignmentViewport> viewp = new ArrayList<AlignmentViewport>();
if (desktop != null)
{
- javax.swing.JInternalFrame[] frames = instance.getAllFrames();
+ AlignFrame[] frames = Desktop.getAlignFrames();
- for (int t = 0; t < frames.length; t++)
+ for (AlignFrame afr : frames)
{
- if (frames[t] instanceof AlignFrame)
+ if (sequenceSetId==null || afr.getViewport().getSequenceSetId().equals(sequenceSetId))
{
- AlignFrame afr = ((AlignFrame) frames[t]);
- if (afr.getViewport().getSequenceSetId().equals(sequenceSetId))
+ if (afr.alignPanels != null)
{
- if (afr.alignPanels != null)
+ for (AlignmentPanel ap : afr.alignPanels)
{
- for (int a = 0; a < afr.alignPanels.size(); a++)
+ if (sequenceSetId == null
+ || sequenceSetId.equals(ap.av.getSequenceSetId()))
{
- if (sequenceSetId.equals(((AlignmentPanel) afr.alignPanels
- .elementAt(a)).av.getSequenceSetId()))
- {
- viewp.addElement(((AlignmentPanel) afr.alignPanels
- .elementAt(a)).av);
- }
+ viewp.add(ap.av);
}
}
- else
- {
- viewp.addElement(((AlignFrame) frames[t]).getViewport());
- }
+ }
+ else
+ {
+ viewp.add(afr.getViewport());
}
}
}
if (viewp.size() > 0)
{
- AlignViewport[] vp = new AlignViewport[viewp.size()];
- viewp.copyInto(vp);
- return vp;
+ return viewp.toArray(new AlignmentViewport[viewp.size()]);
}
}
return null;
}
+ /**
+ * Explode the views in the given frame into separate AlignFrame
+ *
+ * @param af
+ */
public void explodeViews(AlignFrame af)
{
int size = af.alignPanels.size();
for (int i = 0; i < size; i++)
{
- AlignmentPanel ap = (AlignmentPanel) af.alignPanels.elementAt(i);
+ AlignmentPanel ap = af.alignPanels.get(i);
AlignFrame newaf = new AlignFrame(ap);
- if (ap.av.explodedPosition != null
- && !ap.av.explodedPosition.equals(af.getBounds()))
+
+ /*
+ * Restore the view's last exploded frame geometry if known. Multiple
+ * views from one exploded frame share and restore the same (frame)
+ * position and size.
+ */
+ Rectangle geometry = ap.av.getExplodedGeometry();
+ if (geometry != null)
{
- newaf.setBounds(ap.av.explodedPosition);
+ newaf.setBounds(geometry);
}
- ap.av.gatherViewsHere = false;
+ ap.av.setGatherViewsHere(false);
addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
}
+ /**
+ * Gather expanded views (separate AlignFrame's) with the same sequence set
+ * identifier back in to this frame as additional views, and close the
+ * expanded views. Note the expanded frames may themselves have multiple
+ * views. We take the lot.
+ *
+ * @param source
+ */
public void gatherViews(AlignFrame source)
{
- source.viewport.gatherViewsHere = true;
- source.viewport.explodedPosition = source.getBounds();
+ source.viewport.setGatherViewsHere(true);
+ source.viewport.setExplodedGeometry(source.getBounds());
JInternalFrame[] frames = desktop.getAllFrames();
String viewId = source.viewport.getSequenceSetId();
boolean gatherThis = false;
for (int a = 0; a < af.alignPanels.size(); a++)
{
- AlignmentPanel ap = (AlignmentPanel) af.alignPanels.elementAt(a);
+ AlignmentPanel ap = af.alignPanels.get(a);
if (viewId.equals(ap.av.getSequenceSetId()))
{
gatherThis = true;
- ap.av.gatherViewsHere = false;
- ap.av.explodedPosition = af.getBounds();
+ ap.av.setGatherViewsHere(false);
+ ap.av.setExplodedGeometry(af.getBounds());
source.addAlignmentPanel(ap, false);
}
}
jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Open a saved VAMSAS session");
+ chooser.setDialogTitle(MessageManager
+ .getString("label.open_saved_vamsas_session"));
chooser.setToolTipText(MessageManager
.getString("label.select_vamsas_session_opened_as_new_vamsas_session"));
Desktop.desktop,
MessageManager.formatMessage(
"label.couldnt_import_as_vamsas_session",
- new String[]
+ new Object[]
{ fle }),
MessageManager
.getString("label.vamsas_document_import_failed"),
return false;
}
- setProgressBar("Importing VAMSAS session from " + file.getName(),
- file.hashCode());
+ setProgressBar(MessageManager.formatMessage(
+ "status.importing_vamsas_session_from", new Object[]
+ { file.getName() }), file.hashCode());
try
{
v_client = new jalview.gui.VamsasApplication(this, file, null);
} catch (Exception ex)
{
- setProgressBar("Importing VAMSAS session from " + file.getName(),
- file.hashCode());
+ setProgressBar(MessageManager.formatMessage(
+ "status.importing_vamsas_session_from", new Object[]
+ { file.getName() }), file.hashCode());
jalview.bin.Cache.log.error(
"New vamsas session from existing session file failed:", ex);
return false;
}
setupVamsasConnectedGui();
v_client.initial_update(); // TODO: thread ?
- setProgressBar("Importing VAMSAS session from " + file.getName(),
- file.hashCode());
+ setProgressBar(MessageManager.formatMessage(
+ "status.importing_vamsas_session_from", new Object[]
+ { file.getName() }), file.hashCode());
return v_client.inSession();
}
if (v_client != null)
{
throw new Error(
- "Trying to join a vamsas session when another is already connected.");
+ MessageManager
+ .getString("error.try_join_vamsas_session_another"));
}
if (mysesid == null)
{
- throw new Error("Invalid vamsas session id.");
+ throw new Error(
+ MessageManager.getString("error.invalid_vamsas_session_id"));
}
v_client = new VamsasApplication(this, mysesid);
setupVamsasConnectedGui();
JMenuItem sessit = new JMenuItem();
sessit.setText(sess[i]);
sessit.setToolTipText(MessageManager.formatMessage(
- "label.connect_to_session", new String[]
+ "label.connect_to_session", new Object[]
{ sess[i] }));
final Desktop dsktp = this;
final String mysesid = sess[i];
{ "Vamsas Document" }, "Vamsas Document");
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Save Vamsas Document Archive");
+ chooser.setDialogTitle(MessageManager
+ .getString("label.save_vamsas_document_archive"));
int value = chooser.showSaveDialog(this);
if (value == JalviewFileChooser.APPROVE_OPTION)
{
java.io.File choice = chooser.getSelectedFile();
- JPanel progpanel = addProgressPanel("Saving VAMSAS Document to "
- + choice.getName());
+ JPanel progpanel = addProgressPanel(MessageManager.formatMessage(
+ "label.saving_vamsas_doc", new Object[]
+ { choice.getName() }));
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
String warnmsg = null;
String warnttl = null;
}
if (b)
{
- vamUpdate = this.addProgressPanel("Updating vamsas session");
+ vamUpdate = this.addProgressPanel(MessageManager
+ .getString("label.updating_vamsas_session"));
}
vamsasStart.setVisible(!b);
vamsasStop.setVisible(!b);
public class MyDesktopPane extends JDesktopPane implements Runnable
{
+ private static final float ONE_MB = 1048576f;
+
boolean showMemoryUsage = false;
Runtime runtime;
{
try
{
- maxMemory = runtime.maxMemory() / 1048576f;
- allocatedMemory = runtime.totalMemory() / 1048576f;
- freeMemory = runtime.freeMemory() / 1048576f;
+ maxMemory = runtime.maxMemory() / ONE_MB;
+ allocatedMemory = runtime.totalMemory() / ONE_MB;
+ freeMemory = runtime.freeMemory() / ONE_MB;
totalFreeMemory = freeMemory + (maxMemory - allocatedMemory);
percentUsage = (totalFreeMemory / maxMemory) * 100;
if (showMemoryUsage && g != null && df != null)
{
if (percentUsage < 20)
+ {
g.setColor(Color.red);
+ }
FontMetrics fm = g.getFontMetrics();
if (fm != null)
{
g.drawString(MessageManager.formatMessage(
"label.memory_stats",
- new String[]
+ new Object[]
{ df.format(totalFreeMemory), df.format(maxMemory),
df.format(percentUsage) }), 10,
getHeight() - fm.getHeight());
/**
* Accessor method to quickly get all the AlignmentFrames loaded.
+ *
+ * @return an array of AlignFrame, or null if none found
*/
- public static AlignFrame[] getAlignframes()
+ public static AlignFrame[] getAlignFrames()
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
{
return null;
}
- Vector avp = new Vector();
- try
+ List<AlignFrame> avp = new ArrayList<AlignFrame>();
+ // REVERSE ORDER
+ for (int i = frames.length - 1; i > -1; i--)
{
- // REVERSE ORDER
- for (int i = frames.length - 1; i > -1; i--)
+ if (frames[i] instanceof AlignFrame)
{
- if (frames[i] instanceof AlignFrame)
+ avp.add((AlignFrame) frames[i]);
+ }
+ else if (frames[i] instanceof SplitFrame)
+ {
+ /*
+ * Also check for a split frame containing an AlignFrame
+ */
+ GSplitFrame sf = (GSplitFrame) frames[i];
+ if (sf.getTopFrame() instanceof AlignFrame)
+ {
+ avp.add((AlignFrame) sf.getTopFrame());
+ }
+ if (sf.getBottomFrame() instanceof AlignFrame)
{
- AlignFrame af = (AlignFrame) frames[i];
- avp.addElement(af);
+ avp.add((AlignFrame) sf.getBottomFrame());
}
}
- } catch (Exception ex)
- {
- ex.printStackTrace();
}
if (avp.size() == 0)
{
return null;
}
- AlignFrame afs[] = new AlignFrame[avp.size()];
- for (int i = 0, j = avp.size(); i < j; i++)
- {
- afs[i] = (AlignFrame) avp.elementAt(i);
- }
- avp.clear();
+ AlignFrame afs[] = avp.toArray(new AlignFrame[avp.size()]);
return afs;
}
- public AppJmol[] getJmols()
+ /**
+ * Returns an array of any AppJmol frames in the Desktop (or null if none).
+ *
+ * @return
+ */
+ public GStructureViewer[] getJmols()
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
{
return null;
}
- Vector avp = new Vector();
- try
+ List<GStructureViewer> avp = new ArrayList<GStructureViewer>();
+ // REVERSE ORDER
+ for (int i = frames.length - 1; i > -1; i--)
{
- // REVERSE ORDER
- for (int i = frames.length - 1; i > -1; i--)
+ if (frames[i] instanceof AppJmol)
{
- if (frames[i] instanceof AppJmol)
- {
- AppJmol af = (AppJmol) frames[i];
- avp.addElement(af);
- }
+ GStructureViewer af = (GStructureViewer) frames[i];
+ avp.add(af);
}
- } catch (Exception ex)
- {
- ex.printStackTrace();
}
if (avp.size() == 0)
{
return null;
}
- AppJmol afs[] = new AppJmol[avp.size()];
- for (int i = 0, j = avp.size(); i < j; i++)
- {
- afs[i] = (AppJmol) avp.elementAt(i);
- }
- avp.clear();
+ GStructureViewer afs[] = avp.toArray(new GStructureViewer[avp.size()]);
return afs;
}
if (!jalview.bin.Cache.groovyJarsPresent())
{
throw new Error(
- "Implementation Error. Cannot create groovyShell without Groovy on the classpath!");
+ MessageManager
+ .getString("error.implementation_error_cannot_create_groovyshell"));
}
try
{
- Class gcClass = Desktop.class.getClassLoader().loadClass(
+ Class<?> gcClass = Desktop.class.getClassLoader().loadClass(
"groovy.ui.Console");
- Constructor gccons = gcClass.getConstructor(null);
+ Constructor<?> gccons = gcClass.getConstructor();
java.lang.reflect.Method setvar = gcClass.getMethod("setVariable",
new Class[]
{ String.class, Object.class });
- java.lang.reflect.Method run = gcClass.getMethod("run", null);
- Object gc = gccons.newInstance(null);
+ java.lang.reflect.Method run = gcClass.getMethod("run");
+ Object gc = gccons.newInstance();
setvar.invoke(gc, new Object[]
{ "Jalview", this });
- run.invoke(gc, null);
+ run.invoke(gc);
} catch (Exception ex)
{
jalview.bin.Cache.log.error("Groovy Shell Creation failed.", ex);
- JOptionPane
- .showInternalMessageDialog(
- Desktop.desktop,
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Couldn't create the groovy Shell. Check the error log for the details of what went wrong.",
- "Jalview Groovy Support Failed",
- JOptionPane.ERROR_MESSAGE);
+ MessageManager.getString("label.couldnt_create_groovy_shell"),
+ MessageManager.getString("label.groovy_support_failed"),
+ JOptionPane.ERROR_MESSAGE);
}
}
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
{
- if (progressBarHandlers == null || !progressBars.contains(new Long(id)))
+ if (progressBarHandlers == null
+ || !progressBars.containsKey(new Long(id)))
{
throw new Error(
- "call setProgressBar before registering the progress bar's handler.");
+ MessageManager
+ .getString("error.call_setprogressbar_before_registering_handler"));
}
progressBarHandlers.put(new Long(id), handler);
- final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
+ final JPanel progressPanel = progressBars.get(new Long(id));
if (handler.canCancel())
{
JButton cancel = new JButton(
public void actionPerformed(ActionEvent e)
{
handler.cancelActivity(id);
- us.setProgressBar(
- "Cancelled "
- + ((JLabel) progressPanel.getComponent(0))
- .getText(), id);
+ us.setProgressBar(MessageManager.formatMessage(
+ "label.cancelled_params", new Object[]
+ { ((JLabel) progressPanel.getComponent(0)).getText() }),
+ id);
}
});
progressPanel.add(cancel, BorderLayout.EAST);
}
/**
- * This will return the first AlignFrame viewing AlignViewport av. It will
- * break if there are more than one AlignFrames viewing a particular av. This
+ * This will return the first AlignFrame holding the given viewport instance. It
+ * will break if there are more than one AlignFrames viewing a particular av.
*
- * @param av
- * @return alignFrame for av
+ * @param viewport
+ * @return alignFrame for viewport
*/
- public static AlignFrame getAlignFrameFor(AlignViewport av)
+ public static AlignFrame getAlignFrameFor(AlignViewportI viewport)
{
if (desktop != null)
{
- AlignmentPanel[] aps = getAlignmentPanels(av.getSequenceSetId());
+ AlignmentPanel[] aps = getAlignmentPanels(viewport
+ .getSequenceSetId());
for (int panel = 0; aps != null && panel < aps.length; panel++)
{
- if (aps[panel] != null && aps[panel].av == av)
+ if (aps[panel] != null && aps[panel].av == viewport)
{
return aps[panel].alignFrame;
}
(t0 = new Thread(discoverer)).start();
}
- // ENFIN services are EOLed as of Jalview 2.8.1 release
- if (false)
- {
- try
- {
- if (Cache.getDefault("SHOW_ENFIN_SERVICES", true))
- {
- // EnfinEnvision web service menu entries are rebuild every time the
- // menu is shown, so no changeSupport events are needed.
- jalview.ws.EnfinEnvision2OneWay.getInstance();
- (t1 = new Thread(jalview.ws.EnfinEnvision2OneWay.getInstance()))
- .start();
- }
- } catch (Exception e)
- {
- Cache.log
- .info("Exception when trying to launch Envision2 workflow discovery.",
- e);
- Cache.log.info(e.getStackTrace());
- }
- }
-
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning())
+ ermsg
+ "</td></tr></table>"
+ "<p>It may be that you have invalid JABA URLs<br/>in your web service preferences,"
- + " or mis-configured HTTP proxy settings.</p>"
+ + "<br>or as a command-line argument, or mis-configured HTTP proxy settings.</p>"
+ "<p>Check the <em>Connections</em> and <em>Web services</em> tab<br/>of the"
+ " Tools->Preferences dialog box to change them.</p></html>"),
"Web Service Configuration Problem",
{
if (progress != null)
{
- progress.setProgressBar("Opening " + url, this.hashCode());
+ progress.setProgressBar(MessageManager.formatMessage(
+ "status.opening_params", new Object[]
+ { url }), this.hashCode());
}
jalview.util.BrowserLauncher.openURL(url);
} catch (Exception ex)
{
- JOptionPane
- .showInternalMessageDialog(
- Desktop.desktop,
- "Unixers: Couldn't find default web browser."
- + "\nAdd the full path to your browser in Preferences.",
- "Web browser not found",
- JOptionPane.WARNING_MESSAGE);
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager
+ .getString("label.web_browser_not_found_unix"),
+ MessageManager.getString("label.web_browser_not_found"),
+ JOptionPane.WARNING_MESSAGE);
ex.printStackTrace();
}
dialogPause = false;
block.release();
}
+
+ @Override
+ protected void snapShotWindow_actionPerformed(ActionEvent e)
+ {
+ invalidate();
+ File of;
+ ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.TYPE.EPS,
+ "View of Desktop", getWidth(), getHeight(), of = new File(
+ "Jalview_snapshot" + System.currentTimeMillis()
+ + ".eps"), "View of desktop");
+ try
+ {
+ paintAll(im.getGraphics());
+ im.writeImage();
+ } catch (Exception q)
+ {
+ Cache.log.error("Couldn't write snapshot to " + of.getAbsolutePath(),
+ q);
+ return;
+ }
+ Cache.log.info("Successfully written snapshot to file "
+ + of.getAbsolutePath());
+ }
+
+ /**
+ * Explode the views in the given frame into separate AlignFrame windows.
+ *
+ * @param sf
+ */
+ public void explodeViews(SplitFrame sf)
+ {
+ AlignFrame oldTopFrame = (AlignFrame) sf.getTopFrame();
+ AlignFrame oldBottomFrame = (AlignFrame) sf.getBottomFrame();
+ List<? extends AlignmentViewPanel> topPanels = oldTopFrame
+ .getAlignPanels();
+ List<? extends AlignmentViewPanel> bottomPanels = oldBottomFrame
+ .getAlignPanels();
+ int viewCount = topPanels.size();
+ if (viewCount < 2)
+ {
+ return;
+ }
+
+ /*
+ * Processing in reverse order works, forwards order leaves the first panels
+ * not visible. I don't know why!
+ */
+ for (int i = viewCount - 1; i >= 0; i--)
+ {
+ /*
+ * Make new top and bottom frames. These take over the respective
+ * AlignmentPanel objects, including their AlignmentViewports, so the
+ * cdna/protein relationships between the viewports is carried over to the
+ * new split frames.
+ */
+ AlignmentPanel topPanel = (AlignmentPanel) topPanels.get(i);
+ AlignFrame newTopFrame = new AlignFrame(topPanel);
+ newTopFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT));
+ newTopFrame.setVisible(true);
+ AlignmentPanel bottomPanel = (AlignmentPanel) bottomPanels.get(i);
+ AlignFrame newBottomFrame = new AlignFrame(bottomPanel);
+ newBottomFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT));
+ newBottomFrame.setVisible(true);
+ topPanel.av.setGatherViewsHere(false);
+ bottomPanel.av.setGatherViewsHere(false);
+ JInternalFrame splitFrame = new SplitFrame(newTopFrame,
+ newBottomFrame);
+ // either panel may hold previous exploded frame geometry
+ Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport())
+ .getExplodedGeometry();
+ if (geometry != null)
+ {
+ splitFrame.setBounds(geometry);
+ }
+ Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
+ }
+
+ /*
+ * Clear references to the panels (now relocated in the new SplitFrames)
+ * before closing the old SplitFrame.
+ */
+ topPanels.clear();
+ bottomPanels.clear();
+ sf.close();
+ }
+
+ /**
+ * Gather expanded split frames, sharing the same pairs of sequence set ids,
+ * back into the given SplitFrame as additional views. Note that the gathered
+ * frames may themselves have multiple views.
+ *
+ * @param source
+ */
+ public void gatherViews(GSplitFrame source)
+ {
+ AlignFrame myTopFrame = (AlignFrame) source.getTopFrame();
+ AlignFrame myBottomFrame = (AlignFrame) source.getBottomFrame();
+ myTopFrame.viewport.setExplodedGeometry(source.getBounds());
+ myBottomFrame.viewport.setExplodedGeometry(source.getBounds());
+ myTopFrame.viewport.setGatherViewsHere(true);
+ myBottomFrame.viewport.setGatherViewsHere(true);
+ String topViewId = myTopFrame.viewport.getSequenceSetId();
+ String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
+
+ JInternalFrame[] frames = desktop.getAllFrames();
+ for (JInternalFrame frame : frames)
+ {
+ if (frame instanceof SplitFrame && frame != source)
+ {
+ SplitFrame sf = (SplitFrame) frame;
+ AlignFrame topFrame = (AlignFrame) sf.getTopFrame();
+ AlignFrame bottomFrame = (AlignFrame) sf.getBottomFrame();
+ boolean gatherThis = false;
+ for (int a = 0; a < topFrame.alignPanels.size(); a++)
+ {
+ AlignmentPanel topPanel = topFrame.alignPanels.get(a);
+ AlignmentPanel bottomPanel = bottomFrame.alignPanels.get(a);
+ if (topViewId.equals(topPanel.av.getSequenceSetId())
+ && bottomViewId.equals(bottomPanel.av.getSequenceSetId()))
+ {
+ gatherThis = true;
+ topPanel.av.setGatherViewsHere(false);
+ bottomPanel.av.setGatherViewsHere(false);
+ // both panels refer to the same split frame geometry
+ Rectangle position = sf.getBounds();
+ topPanel.av.setExplodedGeometry(position);
+ bottomPanel.av.setExplodedGeometry(position);
+ myTopFrame.addAlignmentPanel(topPanel, false);
+ myBottomFrame.addAlignmentPanel(bottomPanel, false);
+ }
+ }
+
+ if (gatherThis)
+ {
+ topFrame.getAlignPanels().clear();
+ bottomFrame.getAlignPanels().clear();
+ sf.close();
+ }
+ }
+ }
+
+ /*
+ * The dust settles...give focus to the tab we did this from.
+ */
+ myTopFrame.setDisplayedView(myTopFrame.alignPanel);
+
+ }
+
+ // public static AlignFrame getCurrentAlignFrame()
+ // {
+ // return currentAlignFrame;
+ // }
+ //
+ // public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
+ // {
+ // Desktop.currentAlignFrame = currentAlignFrame;
+ // }
+
+
}