import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
if (jalview.bin.Cache.getDefault("SHOW_OVERVIEW", false))
{
- this.overviewMenuItem_actionPerformed(null);
+ this.overviewMenuItem_actionPerformed();
}
addKeyListener();
}
ap.updateLayout();
- ap.setSelected(true);
+ ap.setSelected(true, true);
ap.alignFrame.setMenusForViewport();
}
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Opens a new Overview window for the current alignment view, unless one is
+ * open already, in which case does nothing.
*/
@Override
- public void overviewMenuItem_actionPerformed(ActionEvent e)
+ public void overviewMenuItem_actionPerformed()
{
if (alignPanel.overviewPanel != null)
{
{
frame.addKeyListener(getKeyListeners()[0]);
}
-
- /*
- * bring alignment panel to front when Overview gets focus
- * (even after New View / eXpand / Gather!)
- */
+
final AlignmentPanel ap = alignPanel;
frame.addFocusListener(new FocusAdapter()
{
@Override
public void focusGained(FocusEvent e)
{
+ /*
+ * bring alignment panel to front when Overview gets focus
+ * (AlignFrame, or SplitFrame if alignment is in a split frame)
+ */
+ ap.setSelected(true, true);
+
+ /*
+ * restore focus to the Overview
+ * (temporarily removing the focus listener)
+ */
+ FocusListener me = frame.getFocusListeners()[0];
+ frame.removeFocusListener(me);
try
{
- ap.alignFrame.setSelected(true);
- ap.alignFrame.setIcon(false);
- ap.alignFrame.setDisplayedView(ap);
+ frame.setSelected(true);
} catch (PropertyVetoException e1)
{
+ } finally
+ {
+ /*
+ * restore the listener _after_ setSelected has run
+ */
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ frame.addFocusListener(me);
+ }
+ });
}
}
});
*/
package jalview.gui;
-import jalview.analysis.AnnotationSorter;
-import jalview.api.AlignViewportI;
-import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
-import jalview.bin.Jalview;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.SearchResultsI;
-import jalview.datamodel.SequenceFeature;
-import jalview.datamodel.SequenceGroup;
-import jalview.datamodel.SequenceI;
-import jalview.gui.ImageExporter.ImageWriterI;
-import jalview.io.HTMLOutput;
-import jalview.jbgui.GAlignmentPanel;
-import jalview.math.AlignmentDimension;
-import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.Comparison;
-import jalview.util.ImageMaker;
-import jalview.util.MessageManager;
-import jalview.viewmodel.ViewportListenerI;
-import jalview.viewmodel.ViewportRanges;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.print.PrinterException;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import javax.swing.SwingUtilities;
+import jalview.analysis.AnnotationSorter;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.api.SplitContainerI;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SearchResultsI;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
+import jalview.io.HTMLOutput;
+import jalview.jbgui.GAlignmentPanel;
+import jalview.math.AlignmentDimension;
+import jalview.schemes.ResidueProperties;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.Comparison;
+import jalview.util.ImageMaker;
+import jalview.util.MessageManager;
+import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
+
/**
* DOCUMENT ME!
*
*/
public AlignmentPanel(AlignFrame af, final AlignViewport av)
{
-// setBackground(Color.white); // BH 2019
+ // setBackground(Color.white); // BH 2019
alignFrame = af;
this.av = av;
setSeqPanel(new SeqPanel(av, this));
/*
* Scroll down to make end of search results visible
*/
- setScrollValues(ranges.getStartRes(), starts + seqIndex - ends
- + 1);
+ setScrollValues(ranges.getStartRes(), starts + seqIndex - ends + 1);
}
/*
* Else results are already visible - no need to scroll
Dimension e = idPanel.getSize();
alabels.setSize(new Dimension(e.width, annotationHeight));
-
annotationSpaceFillerHolder.setPreferredSize(new Dimension(
annotationSpaceFillerHolder.getWidth(), annotationHeight));
annotationScroller.validate();
* single graphics context), then reset to (0, scale height)
*/
alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
- getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics, startRes,
- endRes, startSeq, endSeq - 1);
+ getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics,
+ startRes, endRes, startSeq, endSeq - 1);
alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
if (av.isShowAnnotation() && (endSeq == alignmentHeight))
*
* @throws PrinterException
*/
- public int printWrappedAlignment(int pageWidth, int pageHeight, int pageNumber,
- Graphics g) throws PrinterException
+ public int printWrappedAlignment(int pageWidth, int pageHeight,
+ int pageNumber, Graphics g) throws PrinterException
{
getSeqPanel().seqCanvas.calculateWrappedGeometry(getWidth(),
getHeight());
g.translate(idWidth, 0);
- getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth,
- totalHeight, 0);
+ getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g,
+ pageWidth - idWidth, totalHeight, 0);
if ((pageNumber * pageHeight) < totalHeight)
{
String triplet = null;
if (av.getAlignment().isNucleotide())
{
- triplet = ResidueProperties.nucleotideName.get(seq
- .getCharAt(column) + "");
+ triplet = ResidueProperties.nucleotideName
+ .get(seq.getCharAt(column) + "");
}
else
{
- triplet = ResidueProperties.aa2Triplet.get(seq.getCharAt(column)
- + "");
+ triplet = ResidueProperties.aa2Triplet
+ .get(seq.getCharAt(column) + "");
}
if (triplet == null)
text.append("<area shape=\"rect\" coords=\"")
.append((idWidth + column * av.getCharWidth()))
.append(",").append(sy).append(",")
- .append((idWidth + (column + 1) * av.getCharWidth()))
+ .append((idWidth
+ + (column + 1) * av.getCharWidth()))
.append(",").append((av.getCharHeight() + sy))
.append("\"").append(" onMouseOver=\"toolTip('")
.append(seqPos).append(" ").append(triplet);
}
if (!Comparison.isGap(seq.getCharAt(column)))
{
- List<SequenceFeature> features = seq.findFeatures(column, column);
+ List<SequenceFeature> features = seq.findFeatures(column,
+ column);
for (SequenceFeature sf : features)
{
if (sf.isContactFeature())
}
/**
- * Make/Unmake this alignment panel the current input focus
+ * Make/Unmake this alignment panel the current input focus, optionally
+ * restoring it if iconised
*
- * @param b
+ * @param sel
+ * @param deIconify
*/
- public void setSelected(boolean b)
+ public void setSelected(boolean sel, boolean deIconify)
{
try
{
- if (alignFrame.getSplitViewContainer() != null)
+ SplitContainerI splitFrame = alignFrame.getSplitViewContainer();
+ if (splitFrame != null)
{
/*
* bring enclosing SplitFrame to front first if there is one
*/
- ((SplitFrame) alignFrame.getSplitViewContainer()).setSelected(b);
+ ((SplitFrame) splitFrame).setSelected(sel);
+ if (sel && deIconify)
+ {
+ ((SplitFrame) splitFrame).setIcon(false);
+ }
}
- alignFrame.setSelected(b);
- } catch (Exception ex)
- {
- }
+ alignFrame.setSelected(sel);
- if (b)
+ if (sel)
+ {
+ if (deIconify)
+ {
+ alignFrame.setIcon(false);
+ }
+ alignFrame.setDisplayedView(this);
+ }
+ } catch (PropertyVetoException e)
{
- alignFrame.setDisplayedView(this);
}
}
*/
package jalview.jbgui;
-import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
-import jalview.analysis.GeneticCodeI;
-import jalview.analysis.GeneticCodes;
-import jalview.api.SplitContainerI;
-import jalview.bin.Cache;
-import jalview.gui.JvSwingUtils;
-import jalview.gui.Preferences;
-import jalview.io.FileFormats;
-import jalview.schemes.ResidueColourScheme;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
+import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
+import jalview.analysis.GeneticCodeI;
+import jalview.analysis.GeneticCodes;
+import jalview.api.SplitContainerI;
+import jalview.bin.Cache;
+import jalview.gui.JvSwingUtils;
+import jalview.gui.Preferences;
+import jalview.io.FileFormats;
+import jalview.schemes.ResidueColourScheme;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+
@SuppressWarnings("serial")
public class GAlignFrame extends JInternalFrame
{
@Override
public void actionPerformed(ActionEvent e)
{
- overviewMenuItem_actionPerformed(e);
+ overviewMenuItem_actionPerformed();
}
});
{
}
- protected void overviewMenuItem_actionPerformed(ActionEvent e)
+ protected void overviewMenuItem_actionPerformed()
{
}