*/
package jalview.gui;
+import java.awt.Rectangle;
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import org.exolab.castor.xml.Unmarshaller;
+
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.AlignedCodonFrame;
import jalview.ws.params.AutoCalcSetting;
import jalview.ws.params.WsParamSetI;
-import java.awt.Rectangle;
-import java.io.BufferedReader;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-
-import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import org.exolab.castor.xml.Unmarshaller;
-
/**
* Write out the current jalview desktop state as a Jalview XML stream.
*
view.setGatheredViews(av.isGatherViewsHere());
Rectangle position = ap.av.getExplodedGeometry();
- if (position != null)
- {
- view.setXpos(position.x);
- view.setYpos(position.y);
- view.setWidth(position.width);
- view.setHeight(position.height);
- }
- else
+ if (position == null)
{
- view.setXpos(ap.alignFrame.getBounds().x);
- view.setYpos(ap.alignFrame.getBounds().y);
- view.setWidth(ap.alignFrame.getBounds().width);
- view.setHeight(ap.alignFrame.getBounds().height);
+ position = ap.alignFrame.getBounds();
}
+ view.setXpos(position.x);
+ view.setYpos(position.y);
+ view.setWidth(position.width);
+ view.setHeight(position.height);
view.setStartRes(av.startRes);
view.setStartSeq(av.startSeq);
{
SplitFrame splitFrame = new SplitFrame(dnaFrame, proteinFrame);
String title = MessageManager.getString("label.linked_view_title");
- Desktop.addInternalFrame(splitFrame, title, -1, -1);
+ int width = (int) dnaFrame.getBounds().getWidth();
+ int height = (int) (dnaFrame.getBounds().getHeight()
+ + proteinFrame.getBounds().getHeight() + 50);
+ Desktop.addInternalFrame(splitFrame, title, width, height);
return splitFrame;
}
package jalview.gui;
-import jalview.api.SplitContainerI;
-import jalview.api.ViewStyleI;
-import jalview.datamodel.AlignmentI;
-import jalview.jbgui.GAlignFrame;
-import jalview.jbgui.GSplitFrame;
-import jalview.structure.StructureSelectionManager;
-import jalview.viewmodel.AlignmentViewport;
-
import java.awt.Component;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
+import jalview.api.SplitContainerI;
+import jalview.api.ViewStyleI;
+import jalview.datamodel.AlignmentI;
+import jalview.jbgui.GAlignFrame;
+import jalview.jbgui.GSplitFrame;
+import jalview.structure.StructureSelectionManager;
+import jalview.viewmodel.AlignmentViewport;
+
/**
* An internal frame on the desktop that hosts a horizontally split view of
* linked DNA and Protein alignments. Additional views can be created in linked
((AlignFrame) getTopFrame()).getViewport().setCodingComplement(
((AlignFrame) getBottomFrame()).getViewport());
- setSize(AlignFrame.DEFAULT_WIDTH, Desktop.instance.getHeight() - 20);
+ int width = ((AlignFrame) getTopFrame()).getWidth();
+ // about 50 pixels for the SplitFrame's title bar etc
+ int height = ((AlignFrame) getTopFrame()).getHeight()
+ + ((AlignFrame) getBottomFrame()).getHeight() + 50;
+ height = Math.min(height, Desktop.instance.getHeight() - 20);
+ // setSize(AlignFrame.DEFAULT_WIDTH, Desktop.instance.getHeight() - 20);
+ setSize(width, height);
adjustLayout();
*/
protected void overrideImplementedKeyBindings()
{
+ overrideFind();
overrideNewView();
overrideCloseView();
overrideExpandViews();
}
super.setComplementVisible(alignFrame, show);
}
+
+ /**
+ * Replace Cmd-F Find action with our version. This is necessary because the
+ * 'default' Finder searches in the first AlignFrame it finds. We need it to
+ * search in the half of the SplitFrame that has the mouse.
+ */
+ protected void overrideFind()
+ {
+ /*
+ * Ctrl-F / Cmd-F open Finder dialog, 'focused' on the right alignment
+ */
+ KeyStroke key_cmdF = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit
+ .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+ AbstractAction action = new AbstractAction()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ Component c = getFrameAtMouse();
+ if (c != null && c instanceof AlignFrame)
+ {
+ AlignFrame af = (AlignFrame) c;
+ new Finder(af.viewport, af.alignPanel);
+ }
+ }
+ };
+ overrideKeyBinding(key_cmdF, action);
+ }
}
package jalview.jbgui;
-import jalview.util.Platform;
-
import java.awt.Component;
import java.awt.MouseInfo;
import java.awt.Point;
import javax.swing.JSplitPane;
import javax.swing.plaf.basic.BasicInternalFrameUI;
+import jalview.util.Platform;
+
public class GSplitFrame extends JInternalFrame
{
private static final long serialVersionUID = 1L;
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame,
bottomFrame);
splitPane.setVisible(true);
- splitPane.setDividerLocation(0.5d);
- splitPane.setResizeWeight(0.5d);
+ final double ratio = topFrame.getHeight()
+ / (double) (topFrame.getHeight() + bottomFrame.getHeight());
+ splitPane.setDividerLocation(ratio);
+ splitPane.setResizeWeight(ratio);
splitPane.setDividerSize(5);
add(splitPane);
}
if (show)
{
// SplitPane needs nudging to restore 50-50 split
+ // TODO save/restore other ratios
splitPane.setDividerLocation(0.5d);
}
validate();