/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1)
+ * Copyright (C) 2015 The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.io.FileLoader;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
import jalview.structure.StructureSelectionManager;
import jalview.util.ImageMaker;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.ParamManager;
boolean showjconsole = jalview.bin.Cache.getDefault(
"SHOW_JAVA_CONSOLE", false);
desktop = new MyDesktopPane(selmemusage);
+ if (Platform.isAMac())
+ {
+ desktop.setDoubleBuffered(false);
+ }
showMemusage.setSelected(selmemusage);
desktop.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
frame.setResizable(resizable);
frame.setMaximizable(resizable);
frame.setIconifiable(resizable);
- frame.setFrameIcon(null);
-
+ if (Platform.isAMac())
+ {
+ frame.setIconifiable(false);
+ frame.setFrameIcon(null);
+ // frame.setDesktopIcon(null);
+ frame.setDoubleBuffered(false);
+ }
if (frame.getX() < 1 && frame.getY() < 1)
{
frame.setLocation(xOffset * openFrameCount, yOffset
{
JOptionPane.showInternalMessageDialog(Desktop.desktop,
MessageManager.formatMessage("label.couldnt_locate",
- new Object[]
- { url }), MessageManager
+ new Object[] { url }), MessageManager
.getString("label.url_not_found"),
JOptionPane.WARNING_MESSAGE);
public void saveState_actionPerformed(ActionEvent e)
{
JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jvp" }, new String[]
- { "Jalview Project" }, "Jalview Project");
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
+ new String[] { "jvp" }, new String[] { "Jalview Project" },
+ "Jalview Project");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.save_state"));
{
// TODO: refactor to Jalview desktop session controller action.
setProgressBar(MessageManager.formatMessage(
- "label.saving_jalview_project", new Object[]
- { choice.getName() }), choice.hashCode());
+ "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
ex);
JOptionPane.showMessageDialog(me, MessageManager.formatMessage(
"label.error_whilst_saving_current_state_to",
- new Object[]
- { choice.getName() }), MessageManager
+ new Object[] { choice.getName() }), MessageManager
.getString("label.couldnt_save_project"),
JOptionPane.WARNING_MESSAGE);
}
public void loadState_actionPerformed(ActionEvent e)
{
JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jvp", "jar" }, new String[]
- { "Jalview Project", "Jalview Project (old)" },
- "Jalview Project");
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
+ "jvp", "jar" }, new String[] { "Jalview Project",
+ "Jalview Project (old)" }, "Jalview Project");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
{
public void run()
{
- setProgressBar(MessageManager.formatMessage(
- "label.loading_jalview_project", new Object[]
- { choice }), choice.hashCode());
+ setProgressBar(
+ MessageManager.formatMessage(
+ "label.loading_jalview_project",
+ new Object[] { choice }), choice.hashCode());
try
{
new Jalview2XML().loadJalviewAlign(choice);
JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
.formatMessage(
"label.error_whilst_loading_project_from",
- new Object[]
- { choice }), MessageManager
+ new Object[] { choice }), MessageManager
.getString("label.couldnt_load_project"),
JOptionPane.WARNING_MESSAGE);
}
if (fileLoadingCount == 0)
{
fileLoadingPanels.add(addProgressPanel(MessageManager.formatMessage(
- "label.loading_file", new Object[]
- { fileName })));
+ "label.loading_file", new Object[] { fileName })));
}
fileLoadingCount++;
}
{
for (AlignmentPanel ap : af.alignPanels)
{
- if (alignmentId==null || alignmentId.equals(ap.av.getSequenceSetId()))
+ if (alignmentId == null
+ || alignmentId.equals(ap.av.getSequenceSetId()))
{
aps.add(ap);
}
for (AlignFrame afr : frames)
{
- if (sequenceSetId==null || afr.getViewport().getSequenceSetId().equals(sequenceSetId))
+ if (sequenceSetId == null
+ || afr.getViewport().getSequenceSetId()
+ .equals(sequenceSetId))
{
if (afr.alignPanels != null)
{
Desktop.desktop,
MessageManager.formatMessage(
"label.couldnt_import_as_vamsas_session",
- new Object[]
- { fle }),
+ new Object[] { fle }),
MessageManager
.getString("label.vamsas_document_import_failed"),
JOptionPane.ERROR_MESSAGE);
}
setProgressBar(MessageManager.formatMessage(
- "status.importing_vamsas_session_from", new Object[]
- { file.getName() }), file.hashCode());
+ "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(MessageManager.formatMessage(
- "status.importing_vamsas_session_from", new Object[]
- { file.getName() }), file.hashCode());
+ "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(MessageManager.formatMessage(
- "status.importing_vamsas_session_from", new Object[]
- { file.getName() }), file.hashCode());
+ "status.importing_vamsas_session_from",
+ new Object[] { file.getName() }), file.hashCode());
return v_client.inSession();
}
JMenuItem sessit = new JMenuItem();
sessit.setText(sess[i]);
sessit.setToolTipText(MessageManager.formatMessage(
- "label.connect_to_session", new Object[]
- { sess[i] }));
+ "label.connect_to_session", new Object[] { sess[i] }));
final Desktop dsktp = this;
final String mysesid = sess[i];
sessit.addActionListener(new ActionListener()
JalviewFileChooser chooser = new JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
{ "vdj" }, // TODO: VAMSAS DOCUMENT EXTENSION is VDJ
- new String[]
- { "Vamsas Document" }, "Vamsas Document");
+ new String[] { "Vamsas Document" }, "Vamsas Document");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
{
java.io.File choice = chooser.getSelectedFile();
JPanel progpanel = addProgressPanel(MessageManager.formatMessage(
- "label.saving_vamsas_doc", new Object[]
- { choice.getName() }));
+ "label.saving_vamsas_doc",
+ new Object[] { choice.getName() }));
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
String warnmsg = null;
String warnttl = null;
{
g.drawString(MessageManager.formatMessage(
"label.memory_stats",
- new Object[]
- { df.format(totalFreeMemory), df.format(maxMemory),
- df.format(percentUsage) }), 10,
+ new Object[] { df.format(totalFreeMemory),
+ df.format(maxMemory), df.format(percentUsage) }), 10,
getHeight() - fm.getHeight());
}
}
*/
public static AlignFrame[] getAlignFrames()
{
+ if (Jalview.isHeadlessMode())
+ {
+ // Desktop.desktop is null in headless mode
+ return new AlignFrame[] { currentAlignFrame };
+ }
+
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
if (frames == null)
"groovy.ui.Console");
Constructor<?> gccons = gcClass.getConstructor();
java.lang.reflect.Method setvar = gcClass.getMethod("setVariable",
- new Class[]
- { String.class, Object.class });
+ new Class[] { String.class, Object.class });
java.lang.reflect.Method run = gcClass.getMethod("run");
Object gc = gccons.newInstance();
- setvar.invoke(gc, new Object[]
- { "Jalview", this });
+ setvar.invoke(gc, new Object[] { "Jalview", this });
run.invoke(gc);
} catch (Exception ex)
{
{
handler.cancelActivity(id);
us.setProgressBar(MessageManager.formatMessage(
- "label.cancelled_params", new Object[]
- { ((JLabel) progressPanel.getComponent(0)).getText() }),
- id);
+ "label.cancelled_params",
+ new Object[] { ((JLabel) progressPanel.getComponent(0))
+ .getText() }), id);
}
});
progressPanel.add(cancel, BorderLayout.EAST);
}
/**
- * 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.
+ * 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 viewport
* @return alignFrame for viewport
{
if (desktop != null)
{
- AlignmentPanel[] aps = getAlignmentPanels(viewport
- .getSequenceSetId());
+ AlignmentPanel[] aps = getAlignmentPanels(viewport.getSequenceSetId());
for (int panel = 0; aps != null && panel < aps.length; panel++)
{
if (aps[panel] != null && aps[panel].av == viewport)
if (progress != null)
{
progress.setProgressBar(MessageManager.formatMessage(
- "status.opening_params", new Object[]
- { url }), this.hashCode());
+ "status.opening_params", new Object[] { url }), this
+ .hashCode());
}
jalview.util.BrowserLauncher.openURL(url);
} catch (Exception ex)
}
/**
- * Explode the views in the given frame into separate AlignFrame windows.
+ * Explode the views in the given SplitFrame into separate SplitFrame windows.
+ * This respects (remembers) any previous 'exploded geometry' i.e. the size
+ * and location last time the view was expanded (if any). However it does not
+ * remember the split pane divider location - this is set to match the
+ * 'exploding' frame.
*
* @param sf
*/
* AlignmentPanel objects, including their AlignmentViewports, so the
* cdna/protein relationships between the viewports is carried over to the
* new split frames.
+ *
+ * explodedGeometry holds the (x, y) position of the previously exploded
+ * SplitFrame, and the (width, height) of the AlignFrame component
*/
AlignmentPanel topPanel = (AlignmentPanel) topPanels.get(i);
AlignFrame newTopFrame = new AlignFrame(topPanel);
- newTopFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT));
+ newTopFrame.setSize(oldTopFrame.getSize());
newTopFrame.setVisible(true);
+ Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport())
+ .getExplodedGeometry();
+ if (geometry != null)
+ {
+ newTopFrame.setSize(geometry.getSize());
+ }
+
AlignmentPanel bottomPanel = (AlignmentPanel) bottomPanels.get(i);
AlignFrame newBottomFrame = new AlignFrame(bottomPanel);
- newBottomFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT));
+ newBottomFrame.setSize(oldBottomFrame.getSize());
newBottomFrame.setVisible(true);
+ geometry = ((AlignViewport) bottomPanel.getAlignViewport())
+ .getExplodedGeometry();
+ if (geometry != null)
+ {
+ newBottomFrame.setSize(geometry.getSize());
+ }
+
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);
+ splitFrame.setLocation(geometry.getLocation());
}
Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
}
*/
public void gatherViews(GSplitFrame source)
{
+ /*
+ * special handling of explodedGeometry for a view within a SplitFrame: - it
+ * holds the (x, y) position of the enclosing SplitFrame, and the (width,
+ * height) of the AlignFrame component
+ */
AlignFrame myTopFrame = (AlignFrame) source.getTopFrame();
AlignFrame myBottomFrame = (AlignFrame) source.getBottomFrame();
- myTopFrame.viewport.setExplodedGeometry(source.getBounds());
- myBottomFrame.viewport.setExplodedGeometry(source.getBounds());
+ myTopFrame.viewport.setExplodedGeometry(new Rectangle(source.getX(),
+ source.getY(), myTopFrame.getWidth(), myTopFrame.getHeight()));
+ myBottomFrame.viewport.setExplodedGeometry(new Rectangle(source.getX(),
+ source.getY(), myBottomFrame.getWidth(), myBottomFrame
+ .getHeight()));
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)
{
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);
+ topPanel.av.setExplodedGeometry(new Rectangle(sf.getLocation(),
+ topFrame.getSize()));
+ bottomPanel.av.setExplodedGeometry(new Rectangle(sf
+ .getLocation(), bottomFrame.getSize()));
myTopFrame.addAlignmentPanel(topPanel, false);
myBottomFrame.addAlignmentPanel(bottomPanel, false);
}
}
-
+
if (gatherThis)
{
topFrame.getAlignPanels().clear();
Desktop.currentAlignFrame = currentAlignFrame;
}
-
}