X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=99cd9365b77333b797e262a25b04903134ea1859;hb=e7ddb4e421ed93f92b6a94f13f11c6f5677e2a0b;hp=dcb4b21ca4fc84f9d7f0592a3c761cb39eb94b60;hpb=cdb91a578a7900e23e8925cbfffe7001307906b9;p=jalview.git
diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java
index dcb4b21..99cd936 100755
--- a/src/jalview/gui/AlignFrame.java
+++ b/src/jalview/gui/AlignFrame.java
@@ -1,42 +1,126 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
*/
package jalview.gui;
-import java.beans.*;
-import java.io.*;
-import java.util.*;
-
-import java.awt.*;
-import java.awt.datatransfer.*;
-import java.awt.dnd.*;
-import java.awt.event.*;
-import java.awt.print.*;
-import javax.swing.*;
-import javax.swing.event.MenuEvent;
-
-import jalview.analysis.*;
-import jalview.commands.*;
-import jalview.datamodel.*;
-import jalview.io.*;
-import jalview.jbgui.*;
-import jalview.schemes.*;
-import jalview.ws.*;
+import jalview.analysis.AAFrequency;
+import jalview.analysis.AlignmentSorter;
+import jalview.analysis.Conservation;
+import jalview.analysis.CrossRef;
+import jalview.analysis.NJTree;
+import jalview.analysis.ParseProperties;
+import jalview.analysis.SequenceIdMatcher;
+import jalview.bin.Cache;
+import jalview.commands.CommandI;
+import jalview.commands.EditCommand;
+import jalview.commands.OrderCommand;
+import jalview.commands.RemoveGapColCommand;
+import jalview.commands.RemoveGapsCommand;
+import jalview.commands.SlideSequencesCommand;
+import jalview.commands.TrimRegionCommand;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentOrder;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SeqCigar;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentProperties;
+import jalview.io.AnnotationFile;
+import jalview.io.FeaturesFile;
+import jalview.io.FileLoader;
+import jalview.io.FormatAdapter;
+import jalview.io.HTMLOutput;
+import jalview.io.IdentifyFile;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.io.JnetAnnotationMaker;
+import jalview.io.NewickFile;
+import jalview.jbgui.GAlignFrame;
+import jalview.schemes.Blosum62ColourScheme;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ClustalxColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemeProperty;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.NucleotideColourScheme;
+import jalview.schemes.PIDColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.RNAHelicesColourChooser;
+import jalview.schemes.ResidueProperties;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
+import jalview.ws.WSMenuEntryProviderI;
+import jalview.ws.jws1.Discoverer;
+import jalview.ws.jws2.Jws2Discoverer;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.print.PageFormat;
+import java.awt.print.PrinterJob;
+import java.beans.PropertyChangeEvent;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JEditorPane;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
/**
* DOCUMENT ME!
@@ -200,7 +284,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
void init()
{
- if (viewport.conservation == null)
+ if (viewport.getAlignmentConservationAnnotation()== null)
{
BLOSUM62Colour.setEnabled(false);
conservationMenuItem.setEnabled(false);
@@ -226,7 +310,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
addServiceListeners();
- setGUINucleotide(viewport.alignment.isNucleotide());
+ setGUINucleotide(viewport.getAlignment().isNucleotide());
}
setMenusFromViewport(viewport);
@@ -319,7 +403,22 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
|| evt.isShiftDown() || evt.isAltDown());
}
break;
-
+
+ //case KeyEvent.VK_A:
+ // if (viewport.cursorMode)
+ // {
+ // alignPanel.seqPanel.insertNucAtCursor(false,"A");
+ // //System.out.println("A");
+ // }
+ // break;
+ /*
+ case KeyEvent.VK_CLOSE_BRACKET:
+ if (viewport.cursorMode)
+ {
+ System.out.println("closing bracket");
+ }
+ break;
+ */
case KeyEvent.VK_DELETE:
case KeyEvent.VK_BACK_SPACE:
if (!viewport.cursorMode)
@@ -406,70 +505,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
boolean toggleSeqs = !evt.isControlDown();
boolean toggleCols = !evt.isShiftDown();
-
- boolean hide = false;
- SequenceGroup sg = viewport.getSelectionGroup();
- // TODO: document ctrl-shift-h for show visible selected area and fix hack so columns for the current selected region get transferred.
- if (!toggleSeqs && !toggleCols)
- {
- // Hide everything by the current selection - this is a hack - we do the invert and then hide
- // first check that there will be visible columns after the invert.
- if ((viewport.colSel!=null && viewport.colSel.getSelected()!=null && viewport.colSel.getSelected().size()>0) || (sg!=null && sg.getSize()>0 && sg.getStartRes()<=sg.getEndRes()))
- {
- // now invert the sequence set, if required - empty selection implies that no hiding is required.
- if (sg!=null) {
- invertSequenceMenuItem_actionPerformed(null);
- sg = viewport.getSelectionGroup();
- toggleSeqs = true;
-
- }
-
- if (sg!=null && sg.getStartRes()>=0 && sg.getStartRes()<=sg.getEndRes()&& (viewport.colSel==null || viewport.colSel.getSelected()==null || viewport.colSel.getSelected().size()==0))
- {
- // synthesize a column selection if none exists. this happens if a single region has been selected rather than whole columns.
- if (viewport.colSel==null)
- {
- viewport.colSel = new ColumnSelection();
- }
- for (int cspos = sg.getStartRes(); cspos<=sg.getEndRes(); cspos++) {
- viewport.colSel.addElement(cspos);
- }
- }
- // finally invert the column selection and get the new sequence selection.
- invertColSel_actionPerformed(null);
- toggleCols = true;
- }
- }
-
- if (toggleSeqs)
- {
- if (sg != null
- && sg.getSize() != viewport.alignment.getHeight())
- {
- hideSelSequences_actionPerformed(null);
- hide = true;
- }
- else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))
- {
- showAllSeqs_actionPerformed(null);
- }
- }
-
- if (toggleCols)
- {
- if (viewport.colSel.getSelected().size() > 0)
- {
- hideSelColumns_actionPerformed(null);
- if (!toggleSeqs)
- {
- viewport.selectionGroup = sg;
- }
- }
- else if (!hide)
- {
- showAllColumns_actionPerformed(null);
- }
- }
+ toggleHiddenRegions(toggleSeqs, toggleCols);
break;
}
case KeyEvent.VK_PAGE_UP:
@@ -549,12 +585,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (newPanel)
{
- if (ap.av.padGaps)
+ if (ap.av.isPadGaps())
{
- ap.av.alignment.padGaps();
+ ap.av.getAlignment().padGaps();
}
ap.av.updateConservation(ap);
ap.av.updateConsensus(ap);
+ ap.av.updateStrucConsensus(ap);
}
}
@@ -577,32 +614,47 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
private void addServiceListeners()
{
final java.beans.PropertyChangeListener thisListener;
- // Do this once to get current state
- BuildWebServiceMenu();
- Desktop.discoverer
- .addPropertyChangeListener(thisListener = new java.beans.PropertyChangeListener()
+ Desktop.instance.addJalviewPropertyChangeListener("services",
+ thisListener = new java.beans.PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent evt)
{
- // System.out.println("Discoverer property change.");
- if (evt.getPropertyName().equals("services"))
+ // // System.out.println("Discoverer property change.");
+ // if (evt.getPropertyName().equals("services"))
{
- // System.out.println("Rebuilding web service menu");
- BuildWebServiceMenu();
+ SwingUtilities.invokeLater(new Runnable()
+ {
+
+ public void run()
+ {
+ System.err
+ .println("Rebuild WS Menu for service change");
+ BuildWebServiceMenu();
+ }
+
+ });
}
}
});
-
addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
public void internalFrameClosed(
javax.swing.event.InternalFrameEvent evt)
{
- // System.out.println("deregistering discoverer listener");
- Desktop.discoverer.removePropertyChangeListener(thisListener);
+ System.out.println("deregistering discoverer listener");
+ Desktop.instance.removeJalviewPropertyChangeListener("services",
+ thisListener);
closeMenuItem_actionPerformed(true);
};
});
+ // Finally, build the menu once to get current service state
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ BuildWebServiceMenu();
+ }
+ }).start();
}
public void setGUINucleotide(boolean nucleotide)
@@ -610,12 +662,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
showTranslation.setVisible(nucleotide);
conservationMenuItem.setEnabled(!nucleotide);
modifyConservation.setEnabled(!nucleotide);
-
+ showGroupConservation.setEnabled(!nucleotide);
+ rnahelicesColour.setEnabled(nucleotide);
+ purinePyrimidineColour.setEnabled(nucleotide);
// Remember AlignFrame always starts as protein
- if (!nucleotide)
- {
- calculateMenu.remove(calculateMenu.getItemCount() - 2);
- }
+ //if (!nucleotide)
+ // {
+ // showTr
+ // calculateMenu.remove(calculateMenu.getItemCount() - 2);
+ // }
}
/**
@@ -637,7 +692,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
void setMenusFromViewport(AlignViewport av)
{
- padGapsMenuitem.setSelected(av.padGaps);
+ padGapsMenuitem.setSelected(av.isPadGaps());
colourTextMenuItem.setSelected(av.showColourText);
abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
conservationMenuItem.setSelected(av.getConservationSelected());
@@ -652,9 +707,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
annotationPanelMenuItem.setState(av.showAnnotation);
viewBoxesMenuItem.setSelected(av.showBoxes);
viewTextMenuItem.setSelected(av.showText);
- showUnconservedMenuItem.setSelected(av.showUnconserved);
- showGroupConsensus.setSelected(av.showGroupConsensus);
- showGroupConservation.setSelected(av.showGroupConservation);
+ showNonconservedMenuItem.setSelected(av.getShowUnconserved());
+ showGroupConsensus.setSelected(av.isShowGroupConsensus());
+ showGroupConservation.setSelected(av.isShowGroupConservation());
+ showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
+ showSequenceLogo.setSelected(av.isShowSequenceLogo());
+ normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
+
setColourSelected(ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
@@ -663,7 +722,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
applyToAllGroups.setState(av.colourAppliesToAllGroups);
showNpFeatsMenuitem.setSelected(av.isShowNpFeats());
showDbRefsMenuitem.setSelected(av.isShowDbRefs());
-
+ autoCalculate.setSelected(av.autoCalculateConsensus);
+ sortByTree.setSelected(av.sortByTree);
+ listenToViewSelections.setSelected(av.followSelection);
+ rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
+ rnahelicesColour.setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
setShowProductsEnabled();
updateEditMenuBar();
@@ -685,7 +748,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
JPanel progressPanel;
- Long lId=new Long(id);
+ Long lId = new Long(id);
GridLayout layout = (GridLayout) statusPanel.getLayout();
if (progressBars.get(lId) != null)
{
@@ -719,7 +782,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
progressBars.put(lId, progressPanel);
}
// update GUI
- setMenusForViewport();
+ // setMenusForViewport();
validate();
}
@@ -743,8 +806,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void actionPerformed(ActionEvent e)
{
handler.cancelActivity(id);
- us.setProgressBar("Cancelled "
- + ((JLabel) progressPanel.getComponent(0)).getText(), id);
+ us.setProgressBar(
+ "Cancelled "
+ + ((JLabel) progressPanel.getComponent(0))
+ .getText(), id);
}
});
progressPanel.add(cancel, BorderLayout.EAST);
@@ -791,6 +856,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
if (fileName != null)
{
+ // TODO: work out how to recover feature settings for correct view(s) when
+ // file is reloaded.
if (currentFileFormat.equals("Jalview"))
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
@@ -825,7 +892,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
protocol, currentFileFormat);
newframe.setBounds(bounds);
-
+ if (featureSettings != null && featureSettings.isShowing())
+ {
+ final Rectangle fspos = featureSettings.frame.getBounds();
+ // TODO: need a 'show feature settings' function that takes bounds -
+ // need to refactor Desktop.addFrame
+ newframe.featureSettings_actionPerformed(null);
+ final FeatureSettings nfs = newframe.featureSettings;
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ nfs.frame.setBounds(fspos);
+ }
+ });
+ this.featureSettings.close();
+ this.featureSettings = null;
+ }
this.closeMenuItem_actionPerformed(true);
}
}
@@ -864,8 +947,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
public void saveAs_actionPerformed(ActionEvent e)
{
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
- .getProperty("LAST_DIRECTORY"),
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
currentFileFormat, false);
@@ -936,7 +1019,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
String[] omitHidden = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
int reply = JOptionPane
.showInternalConfirmDialog(
@@ -954,9 +1037,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
FormatAdapter f = new FormatAdapter();
String output = f.formatSequences(format,
- (Alignment) viewport.alignment, // class cast exceptions will
+ (Alignment) viewport.getAlignment(), // class cast exceptions will
// occur in the distant future
- omitHidden, f.getCacheSuffixDefault(format), viewport.colSel);
+ omitHidden, f.getCacheSuffixDefault(format), viewport.getColumnSelection());
if (output == null)
{
@@ -1016,7 +1099,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
String[] omitHidden = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
int reply = JOptionPane
.showInternalConfirmDialog(
@@ -1035,11 +1118,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
CutAndPasteTransfer cap = new CutAndPasteTransfer();
cap.setForInput(null);
- Desktop.addInternalFrame(cap, "Alignment output - "
- + e.getActionCommand(), 600, 500);
- cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
- viewport.alignment, omitHidden, viewport.colSel));
+ try
+ {
+ cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
+ viewport.getAlignment(), omitHidden, viewport.getColumnSelection()));
+ Desktop.addInternalFrame(cap,
+ "Alignment output - " + e.getActionCommand(), 600, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("Outputting alignment as " + e.getActionCommand(), oom);
+ cap.dispose();
+ }
+
}
/**
@@ -1050,9 +1141,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
- new HTMLOutput(alignPanel, alignPanel.seqPanel.seqCanvas
- .getSequenceRenderer(), alignPanel.seqPanel.seqCanvas
- .getFeatureRenderer());
+ new HTMLOutput(alignPanel,
+ alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
}
public void createImageMap(File file, String image)
@@ -1108,18 +1199,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void exportAnnotations_actionPerformed(ActionEvent e)
{
- new AnnotationExporter().exportAnnotations(alignPanel,
- viewport.showAnnotation ? viewport.alignment
- .getAlignmentAnnotation() : null, viewport.alignment
+ new AnnotationExporter().exportAnnotations(
+ alignPanel,
+ viewport.showAnnotation ? viewport.getAlignment()
+ .getAlignmentAnnotation() : null, viewport.getAlignment()
.getGroups(),
- ((Alignment) viewport.alignment).alignmentProperties);
+ ((Alignment) viewport.getAlignment()).alignmentProperties);
}
public void associatedData_actionPerformed(ActionEvent e)
{
// Pick the tree file
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
- .getProperty("LAST_DIRECTORY"));
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle("Load Jalview Annotations or Features File");
chooser.setToolTipText("Load Jalview Annotations / Features file");
@@ -1130,7 +1222,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
String choice = chooser.getSelectedFile().getPath();
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
- loadJalviewDataFile(choice);
+ loadJalviewDataFile(choice, null, null, null);
}
}
@@ -1250,7 +1342,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
viewport.historyList.push(command);
viewport.redoList.clear();
updateEditMenuBar();
- viewport.hasHiddenColumns = (viewport.colSel!=null && viewport.colSel.getHiddenColumns() != null && viewport.colSel.getHiddenColumns().size()>0);
+ viewport.updateHiddenColumns();
+// viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
+// && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+// .getHiddenColumns().size() > 0);
}
}
@@ -1273,7 +1368,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (viewport != null)
{
return new AlignmentI[]
- { viewport.alignment };
+ { viewport.getAlignment() };
}
return null;
}
@@ -1297,9 +1392,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (originalSource != null)
{
- originalSource.hasHiddenColumns = (viewport.colSel!=null && viewport.colSel.getHiddenColumns() != null && viewport.colSel.getHiddenColumns().size()>0);
+ if (originalSource!=viewport)
+ {
+ Cache.log.warn("Implementation worry: mismatch of viewport origin for undo");
+ }
+ originalSource.updateHiddenColumns();
+// originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
+// && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+// .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
- originalSource.alignment.getSequences());
+ originalSource.getAlignment().getSequences());
}
}
@@ -1325,9 +1427,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (originalSource != null)
{
- originalSource.hasHiddenColumns = (viewport.colSel!=null && viewport.colSel.getHiddenColumns() != null && viewport.colSel.getHiddenColumns().size()>0);
+
+ if (originalSource!=viewport)
+ {
+ Cache.log.warn("Implementation worry: mismatch of viewport origin for redo");
+ }
+ originalSource.updateHiddenColumns();
+ //originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
+ // && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+ // .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
- originalSource.alignment.getSequences());
+ originalSource.getAlignment().getSequences());
}
}
@@ -1349,7 +1459,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
if (comps.elementAt(i) instanceof AlignmentPanel)
{
- if (al == ((AlignmentPanel) comps.elementAt(i)).av.alignment)
+ if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment())
{
originalSource = ((AlignmentPanel) comps.elementAt(i)).av;
break;
@@ -1364,7 +1474,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
// the current view against the closed view first
if (al != null)
{
- PaintRefresher.validateSequences(al, viewport.alignment);
+ PaintRefresher.validateSequences(al, viewport.getAlignment());
}
originalSource = viewport;
@@ -1390,46 +1500,46 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (up)
{
- for (int i = 1; i < viewport.alignment.getHeight(); i++)
+ for (int i = 1; i < viewport.getAlignment().getHeight(); i++)
{
- SequenceI seq = viewport.alignment.getSequenceAt(i);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(i);
if (!sg.getSequences(null).contains(seq))
{
continue;
}
- SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
+ SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1);
if (sg.getSequences(null).contains(temp))
{
continue;
}
- viewport.alignment.getSequences().setElementAt(temp, i);
- viewport.alignment.getSequences().setElementAt(seq, i - 1);
+ viewport.getAlignment().getSequences().setElementAt(temp, i);
+ viewport.getAlignment().getSequences().setElementAt(seq, i - 1);
}
}
else
{
- for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
+ for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--)
{
- SequenceI seq = viewport.alignment.getSequenceAt(i);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(i);
if (!sg.getSequences(null).contains(seq))
{
continue;
}
- SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
+ SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1);
if (sg.getSequences(null).contains(temp))
{
continue;
}
- viewport.alignment.getSequences().setElementAt(temp, i);
- viewport.alignment.getSequences().setElementAt(seq, i + 1);
+ viewport.getAlignment().getSequences().setElementAt(temp, i);
+ viewport.getAlignment().getSequences().setElementAt(seq, i + 1);
}
}
@@ -1441,15 +1551,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
Vector sg = new Vector();
if (viewport.cursorMode)
{
- sg.addElement(viewport.alignment
+ sg.addElement(viewport.getAlignment()
.getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
}
else if (viewport.getSelectionGroup() != null
- && viewport.getSelectionGroup().getSize() != viewport.alignment
+ && viewport.getSelectionGroup().getSize() != viewport.getAlignment()
.getHeight())
{
sg = viewport.getSelectionGroup().getSequences(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
}
if (sg.size() < 1)
@@ -1459,10 +1569,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
Vector invertGroup = new Vector();
- for (int i = 0; i < viewport.alignment.getHeight(); i++)
+ for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
{
- if (!sg.contains(viewport.alignment.getSequenceAt(i)))
- invertGroup.add(viewport.alignment.getSequenceAt(i));
+ if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
+ invertGroup.add(viewport.getAlignment().getSequenceAt(i));
}
SequenceI[] seqs1 = new SequenceI[sg.size()];
@@ -1538,7 +1648,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
SequenceI[] seqs = viewport.getSelectionAsNewSequence();
String[] omitHidden = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
omitHidden = viewport.getViewAsString(true);
}
@@ -1553,11 +1663,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
jalview.gui.Desktop.internalCopy = true;
// Its really worth setting the clipboard contents
// to empty before setting the large StringSelection!!
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
- new StringSelection(""), null);
+ Toolkit.getDefaultToolkit().getSystemClipboard()
+ .setContents(new StringSelection(""), null);
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
- Desktop.instance);
+ Toolkit.getDefaultToolkit().getSystemClipboard()
+ .setContents(ss, Desktop.instance);
} catch (OutOfMemoryError er)
{
new OOMWarning("copying region", er);
@@ -1565,23 +1675,26 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
Vector hiddenColumns = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
hiddenColumns = new Vector();
- int hiddenOffset = viewport.getSelectionGroup().getStartRes();
+ int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
+ .getSelectionGroup().getEndRes();
for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns()
.size(); i++)
{
int[] region = (int[]) viewport.getColumnSelection()
.getHiddenColumns().elementAt(i);
-
- hiddenColumns.addElement(new int[]
- { region[0] - hiddenOffset, region[1] - hiddenOffset });
+ if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff)
+ {
+ hiddenColumns.addElement(new int[]
+ { region[0] - hiddenOffset, region[1] - hiddenOffset });
+ }
}
}
Desktop.jalviewClipboard = new Object[]
- { seqs, viewport.alignment.getDataset(), hiddenColumns };
+ { seqs, viewport.getAlignment().getDataset(), hiddenColumns };
statusBar.setText("Copied " + seqs.length + " sequences to clipboard.");
}
@@ -1817,8 +1930,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
buildSortByAnnotationScoresMenu();
}
- viewport.firePropertyChange("alignment", null, alignment
- .getSequences());
+ viewport.firePropertyChange("alignment", null,
+ alignment.getSequences());
}
else
@@ -1912,7 +2025,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
// If the cut affects all sequences, remove highlighted columns
- if (sg.getSize() == viewport.alignment.getHeight())
+ if (sg.getSize() == viewport.getAlignment().getHeight())
{
viewport.getColumnSelection().removeElements(sg.getStartRes(),
sg.getEndRes() + 1);
@@ -1929,11 +2042,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,
sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
- viewport.alignment));
+ viewport.getAlignment()));
viewport.setSelectionGroup(null);
viewport.sendSelection();
- viewport.alignment.deleteGroup(sg);
+ viewport.getAlignment().deleteGroup(sg);
viewport.firePropertyChange("alignment", null, viewport.getAlignment()
.getSequences());
@@ -1956,7 +2069,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
protected void deleteGroups_actionPerformed(ActionEvent e)
{
- viewport.alignment.deleteAllGroups();
+ viewport.getAlignment().deleteAllGroups();
viewport.sequenceColours = null;
viewport.setSelectionGroup(null);
PaintRefresher.Refresh(this, viewport.getSequenceSetId());
@@ -1979,7 +2092,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
}
- sg.setEndRes(viewport.alignment.getWidth() - 1);
+ sg.setEndRes(viewport.getAlignment().getWidth() - 1);
viewport.setSelectionGroup(sg);
viewport.sendSelection();
alignPanel.paintAlignment(true);
@@ -2006,6 +2119,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
alignPanel.idPanel.idCanvas.searchResults = null;
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
/**
@@ -2031,14 +2145,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
alignPanel.paintAlignment(true);
- viewport.sendSelection();
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
public void invertColSel_actionPerformed(ActionEvent e)
{
viewport.invertColumnSelection();
alignPanel.paintAlignment(true);
+ viewport.sendSelection();
}
/**
@@ -2083,11 +2198,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (viewport.getSelectionGroup() != null)
{
seqs = viewport.getSelectionGroup().getSequencesAsArray(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
}
else
{
- seqs = viewport.alignment.getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
TrimRegionCommand trimRegion;
@@ -2095,23 +2210,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
trimRegion = new TrimRegionCommand("Remove Left",
TrimRegionCommand.TRIM_LEFT, seqs, column,
- viewport.alignment, viewport.colSel,
- viewport.selectionGroup);
+ viewport.getAlignment(), viewport.getColumnSelection(),
+ viewport.getSelectionGroup());
viewport.setStartRes(0);
}
else
{
trimRegion = new TrimRegionCommand("Remove Right",
TrimRegionCommand.TRIM_RIGHT, seqs, column,
- viewport.alignment, viewport.colSel,
- viewport.selectionGroup);
+ viewport.getAlignment(), viewport.getColumnSelection(),
+ viewport.getSelectionGroup());
}
statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
addHistoryItem(trimRegion);
- Vector groups = viewport.alignment.getGroups();
+ Vector groups = viewport.getAlignment().getGroups();
for (int i = 0; i < groups.size(); i++)
{
@@ -2120,7 +2235,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if ((trimLeft && !sg.adjustForRemoveLeft(column))
|| (!trimLeft && !sg.adjustForRemoveRight(column)))
{
- viewport.alignment.deleteGroup(sg);
+ viewport.getAlignment().deleteGroup(sg);
}
}
@@ -2137,23 +2252,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
{
- int start = 0, end = viewport.alignment.getWidth() - 1;
+ int start = 0, end = viewport.getAlignment().getWidth() - 1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
{
seqs = viewport.getSelectionGroup().getSequencesAsArray(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
start = viewport.getSelectionGroup().getStartRes();
end = viewport.getSelectionGroup().getEndRes();
}
else
{
- seqs = viewport.alignment.getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
- "Remove Gapped Columns", seqs, start, end, viewport.alignment);
+ "Remove Gapped Columns", seqs, start, end, viewport.getAlignment());
addHistoryItem(removeGapCols);
@@ -2162,7 +2277,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
// This is to maintain viewport position on first residue
// of first sequence
- SequenceI seq = viewport.alignment.getSequenceAt(0);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(0);
int startRes = seq.findPosition(viewport.startRes);
// ShiftList shifts;
// viewport.getAlignment().removeGaps(shifts=new ShiftList());
@@ -2183,28 +2298,28 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
{
- int start = 0, end = viewport.alignment.getWidth() - 1;
+ int start = 0, end = viewport.getAlignment().getWidth() - 1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
{
seqs = viewport.getSelectionGroup().getSequencesAsArray(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
start = viewport.getSelectionGroup().getStartRes();
end = viewport.getSelectionGroup().getEndRes();
}
else
{
- seqs = viewport.alignment.getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
// This is to maintain viewport position on first residue
// of first sequence
- SequenceI seq = viewport.alignment.getSequenceAt(0);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(0);
int startRes = seq.findPosition(viewport.startRes);
addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
- viewport.alignment));
+ viewport.getAlignment()));
viewport.setStartRes(seq.findIndex(startRes) - 1);
@@ -2221,7 +2336,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
public void padGapsMenuitem_actionPerformed(ActionEvent e)
{
- viewport.padGaps = padGapsMenuitem.isSelected();
+ viewport.setPadGaps(padGapsMenuitem.isSelected());
viewport.firePropertyChange("alignment", null, viewport.getAlignment()
.getSequences());
}
@@ -2249,8 +2364,57 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void newView_actionPerformed(ActionEvent e)
{
+ newView(true);
+ }
+
+ /**
+ *
+ * @param copyAnnotation
+ * if true then duplicate all annnotation, groups and settings
+ * @return new alignment panel, already displayed.
+ */
+ public AlignmentPanel newView(boolean copyAnnotation)
+ {
+ return newView(null, copyAnnotation);
+ }
+
+ /**
+ *
+ * @param viewTitle
+ * title of newly created view
+ * @return new alignment panel, already displayed.
+ */
+ public AlignmentPanel newView(String viewTitle)
+ {
+ return newView(viewTitle, true);
+ }
+
+ /**
+ *
+ * @param viewTitle
+ * title of newly created view
+ * @param copyAnnotation
+ * if true then duplicate all annnotation, groups and settings
+ * @return new alignment panel, already displayed.
+ */
+ public AlignmentPanel newView(String viewTitle, boolean copyAnnotation)
+ {
AlignmentPanel newap = new Jalview2XML().copyAlignPanel(alignPanel,
true);
+ if (!copyAnnotation)
+ {
+ // just remove all the current annotation except for the automatic stuff
+ newap.av.getAlignment().deleteAllGroups();
+ for (AlignmentAnnotation alan : newap.av.getAlignment()
+ .getAlignmentAnnotation())
+ {
+ if (!alan.autoCalculated)
+ {
+ newap.av.getAlignment().deleteAnnotation(alan);
+ }
+ ;
+ }
+ }
newap.av.gatherViewsHere = false;
@@ -2263,8 +2427,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
newap.av.redoList = viewport.redoList;
int index = Desktop.getViewCount(viewport.getSequenceSetId());
- String newViewName = "View " + index;
-
+ // make sure the new view has a unique name - this is essential for Jalview
+ // 2 archives
+ boolean addFirstIndex = false;
+ if (viewTitle == null || viewTitle.trim().length() == 0)
+ {
+ viewTitle = "View";
+ addFirstIndex = true;
+ }
+ else
+ {
+ index = 1;// we count from 1 if given a specific name
+ }
+ String newViewName = viewTitle + ((addFirstIndex) ? " " + index : "");
Vector comps = (Vector) PaintRefresher.components.get(viewport
.getSequenceSetId());
Vector existingNames = new Vector();
@@ -2282,7 +2457,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
while (existingNames.contains(newViewName))
{
- newViewName = "View " + (++index);
+ newViewName = viewTitle + " " + (++index);
}
newap.av.viewName = newViewName;
@@ -2294,6 +2469,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
viewport.gatherViewsHere = true;
}
tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
+ return newap;
}
public void expandViews_actionPerformed(ActionEvent e)
@@ -2402,6 +2578,116 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
alignPanel.paintAlignment(true);
}
+ /**
+ * called by key handler and the hide all/show all menu items
+ *
+ * @param toggleSeqs
+ * @param toggleCols
+ */
+ private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
+ {
+
+ boolean hide = false;
+ SequenceGroup sg = viewport.getSelectionGroup();
+ if (!toggleSeqs && !toggleCols)
+ {
+ // Hide everything by the current selection - this is a hack - we do the
+ // invert and then hide
+ // first check that there will be visible columns after the invert.
+ if ((viewport.getColumnSelection() != null && viewport.getColumnSelection().getSelected() != null && viewport.getColumnSelection()
+ .getSelected().size() > 0)
+ || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
+ .getEndRes()))
+ {
+ // now invert the sequence set, if required - empty selection implies
+ // that no hiding is required.
+ if (sg != null)
+ {
+ invertSequenceMenuItem_actionPerformed(null);
+ sg = viewport.getSelectionGroup();
+ toggleSeqs = true;
+
+ }
+ viewport.expandColSelection(sg, true);
+ // finally invert the column selection and get the new sequence
+ // selection.
+ invertColSel_actionPerformed(null);
+ toggleCols = true;
+ }
+ }
+
+ if (toggleSeqs)
+ {
+ if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
+ {
+ hideSelSequences_actionPerformed(null);
+ hide = true;
+ }
+ else if (!(toggleCols && viewport.getColumnSelection().getSelected().size() > 0))
+ {
+ showAllSeqs_actionPerformed(null);
+ }
+ }
+
+ if (toggleCols)
+ {
+ if (viewport.getColumnSelection().getSelected().size() > 0)
+ {
+ hideSelColumns_actionPerformed(null);
+ if (!toggleSeqs)
+ {
+ viewport.setSelectionGroup(sg);
+ }
+ }
+ else if (!hide)
+ {
+ showAllColumns_actionPerformed(null);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
+ * event.ActionEvent)
+ */
+ public void hideAllButSelection_actionPerformed(ActionEvent e)
+ {
+ toggleHiddenRegions(false, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
+ * .ActionEvent)
+ */
+ public void hideAllSelection_actionPerformed(ActionEvent e)
+ {
+ SequenceGroup sg = viewport.getSelectionGroup();
+ viewport.expandColSelection(sg, false);
+ viewport.hideAllSelectedSeqs();
+ viewport.hideSelectedColumns();
+ alignPanel.paintAlignment(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
+ * ActionEvent)
+ */
+ public void showAllhidden_actionPerformed(ActionEvent e)
+ {
+ viewport.showAllHiddenColumns();
+ viewport.showAllHiddenSeqs();
+ alignPanel.paintAlignment(true);
+ }
+
public void hideSelColumns_actionPerformed(ActionEvent e)
{
viewport.hideSelectedColumns();
@@ -2559,58 +2845,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
JEditorPane editPane = new JEditorPane("text/html", "");
editPane.setEditable(false);
- StringBuffer contents = new StringBuffer("");
-
- float avg = 0;
- int min = Integer.MAX_VALUE, max = 0;
- for (int i = 0; i < viewport.alignment.getHeight(); i++)
- {
- int size = viewport.alignment.getSequenceAt(i).getEnd()
- - viewport.alignment.getSequenceAt(i).getStart();
- avg += size;
- if (size > max)
- max = size;
- if (size < min)
- min = size;
- }
- avg = avg / (float) viewport.alignment.getHeight();
-
- contents.append("
Sequences: " + viewport.alignment.getHeight());
- contents.append("
Minimum Sequence Length: " + min);
- contents.append("
Maximum Sequence Length: " + max);
- contents.append("
Average Length: " + (int) avg);
-
- if (((Alignment) viewport.alignment).getProperties() != null)
- {
- Hashtable props = ((Alignment) viewport.alignment).getProperties();
- Enumeration en = props.keys();
- contents.append("
");
- while (en.hasMoreElements())
- {
- String key = en.nextElement().toString();
- StringBuffer val = new StringBuffer();
- String vals = props.get(key).toString();
- int pos = 0, npos;
- do
- {
- npos = vals.indexOf("\n", pos);
- if (npos == -1)
- {
- val.append(vals.substring(pos));
- }
- else
- {
- val.append(vals.substring(pos, npos));
- val.append("
");
- }
- pos = npos + 1;
- } while (npos != -1);
- contents
- .append("" + key + " | " + val + " |
");
- }
- contents.append("
");
- }
- editPane.setText(contents.toString() + "");
+ StringBuffer contents = new AlignmentProperties(viewport.getAlignment())
+ .formatAsHtml();
+ editPane.setText("" + contents.toString() + "");
JInternalFrame frame = new JInternalFrame();
frame.getContentPane().add(new JScrollPane(editPane));
@@ -2634,19 +2871,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
JInternalFrame frame = new JInternalFrame();
OverviewPanel overview = new OverviewPanel(alignPanel);
frame.setContentPane(overview);
- Desktop.addInternalFrame(frame, "Overview " + this.getTitle(), frame
- .getWidth(), frame.getHeight());
+ Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
+ frame.getWidth(), frame.getHeight());
frame.pack();
frame.setLayer(JLayeredPane.PALETTE_LAYER);
- frame
- .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
- {
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
- {
- alignPanel.setOverviewPanel(null);
- };
- });
+ frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ {
+ public void internalFrameClosed(
+ javax.swing.event.InternalFrameEvent evt)
+ {
+ alignPanel.setOverviewPanel(null);
+ };
+ });
alignPanel.setOverviewPanel(overview);
}
@@ -2676,8 +2912,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void clustalColour_actionPerformed(ActionEvent e)
{
changeColour(new ClustalxColourScheme(
- viewport.alignment.getSequences(), viewport.alignment
- .getWidth()));
+ viewport.getAlignment().getSequences(),
+ viewport.getAlignment().getWidth()));
}
/**
@@ -2768,10 +3004,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
changeColour(new NucleotideColourScheme());
}
+ public void purinePyrimidineColour_actionPerformed(ActionEvent e)
+ {
+ changeColour(new PurinePyrimidineColourScheme());
+ }
+ /*
+ public void covariationColour_actionPerformed(ActionEvent e)
+ {
+ changeColour(new CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation()[0]));
+ }
+ */
public void annotationColour_actionPerformed(ActionEvent e)
{
new AnnotationColourChooser(viewport, alignPanel);
}
+
+ public void rnahelicesColour_actionPerformed(ActionEvent e)
+ {
+ new RNAHelicesColourChooser(viewport, alignPanel);
+ }
/**
* DOCUMENT ME!
@@ -2813,13 +3064,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (viewport.getConservationSelected())
{
- Alignment al = (Alignment) viewport.alignment;
+ Alignment al = (Alignment) viewport.getAlignment();
Conservation c = new Conservation("All",
- ResidueProperties.propHash, 3, al.getSequences(), 0, al
- .getWidth() - 1);
+ ResidueProperties.propHash, 3, al.getSequences(), 0,
+ al.getWidth() - 1);
c.calculate();
- c.verdict(false, viewport.ConsPercGaps);
+ c.verdict(false, viewport.getConsPercGaps());
cs.setConservation(c);
@@ -2831,14 +3082,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
cs.setConservation(null);
}
- cs.setConsensus(viewport.hconsensus);
+ cs.setConsensus(viewport.getSequenceConsensusHash());
}
viewport.setGlobalColourScheme(cs);
if (viewport.getColourAppliesToAllGroups())
{
- Vector groups = viewport.alignment.getGroups();
+ Vector groups = viewport.getAlignment().getGroups();
for (int i = 0; i < groups.size(); i++)
{
@@ -2852,8 +3103,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (cs instanceof ClustalxColourScheme)
{
- sg.cs = new ClustalxColourScheme(sg
- .getSequences(viewport.hiddenRepSequences), sg.getWidth());
+ sg.cs = new ClustalxColourScheme(
+ sg.getSequences(viewport.getHiddenRepSequences()),
+ sg.getWidth());
}
else if (cs instanceof UserColourScheme)
{
@@ -2875,9 +3127,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
- sg.cs.setConsensus(AAFrequency.calculate(sg
- .getSequences(viewport.hiddenRepSequences), sg
- .getStartRes(), sg.getEndRes() + 1));
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(viewport.getHiddenRepSequences()),
+ sg.getStartRes(), sg.getEndRes() + 1));
}
else
{
@@ -2887,11 +3139,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (viewport.getConservationSelected())
{
Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg
- .getSequences(viewport.hiddenRepSequences), sg
- .getStartRes(), sg.getEndRes() + 1);
+ ResidueProperties.propHash, 3,
+ sg.getSequences(viewport.getHiddenRepSequences()),
+ sg.getStartRes(), sg.getEndRes() + 1);
c.calculate();
- c.verdict(false, viewport.ConsPercGaps);
+ c.verdict(false, viewport.getConsPercGaps());
sg.cs.setConservation(c);
}
else
@@ -2918,10 +3170,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
protected void modifyPID_actionPerformed(ActionEvent e)
{
if (viewport.getAbovePIDThreshold()
- && viewport.globalColourScheme != null)
+ && viewport.getGlobalColourScheme() != null)
{
- SliderPanel.setPIDSliderSource(alignPanel, viewport
- .getGlobalColourScheme(), "Background");
+ SliderPanel.setPIDSliderSource(alignPanel,
+ viewport.getGlobalColourScheme(), "Background");
SliderPanel.showPIDSlider();
}
}
@@ -2935,10 +3187,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
protected void modifyConservation_actionPerformed(ActionEvent e)
{
if (viewport.getConservationSelected()
- && viewport.globalColourScheme != null)
+ && viewport.getGlobalColourScheme()!= null)
{
SliderPanel.setConservationSlider(alignPanel,
- viewport.globalColourScheme, "Background");
+ viewport.getGlobalColourScheme(), "Background");
SliderPanel.showConservationSlider();
}
}
@@ -3031,8 +3283,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (evt.isControlDown()
|| SwingUtilities.isRightMouseButton(evt))
{
- radioItem
- .removeActionListener(radioItem.getActionListeners()[0]);
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
int option = JOptionPane.showInternalConfirmDialog(
jalview.gui.Desktop.desktop,
@@ -3106,7 +3357,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
AlignmentSorter.sortByPID(viewport.getAlignment(), viewport
.getAlignment().getSequenceAt(0), null);
addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
@@ -3120,7 +3371,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByID(viewport.getAlignment());
- addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
+ addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
@@ -3135,7 +3386,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByLength(viewport.getAlignment());
addHistoryItem(new OrderCommand("Length Sort", oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
@@ -3150,7 +3401,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByGroup(viewport.getAlignment());
addHistoryItem(new OrderCommand("Group Sort", oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
@@ -3223,7 +3474,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
.getAlignment().getSequences());
}
}
+ public void sortByTreeOption_actionPerformed(ActionEvent e)
+ {
+ viewport.sortByTree = sortByTree.isSelected();
+ }
+ @Override
+ protected void listenToViewSelections_actionPerformed(ActionEvent e)
+ {
+ viewport.followSelection = listenToViewSelections.isSelected();
+ }
/**
* DOCUMENT ME!
*
@@ -3321,8 +3581,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
else
{
- // are the sequences aligned?
- if (!viewport.alignment.isAligned())
+ // are the visible sequences aligned?
+ if (!viewport.getAlignment().isAligned(false))
{
JOptionPane
.showMessageDialog(
@@ -3336,7 +3596,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
return;
}
- if (viewport.alignment.getHeight() < 2)
+ if (viewport.getAlignment().getHeight() < 2)
{
return;
}
@@ -3380,7 +3640,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
AlignmentSorter.sortBy(viewport.getAlignment(), order);
addHistoryItem(new OrderCommand(order.getName(), oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
@@ -3406,10 +3666,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void actionPerformed(ActionEvent e)
{
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
- AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport
- .getAlignment());// ,viewport.getSelectionGroup());
+ AlignmentSorter.sortByAnnotationScore(scoreLabel,
+ viewport.getAlignment());// ,viewport.getSelectionGroup());
addHistoryItem(new OrderCommand("Sort by " + scoreLabel, oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
});
@@ -3429,18 +3689,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
public void buildSortByAnnotationScoresMenu()
{
- if (viewport.alignment.getAlignmentAnnotation() == null)
+ if (viewport.getAlignment().getAlignmentAnnotation() == null)
{
return;
}
- if (viewport.alignment.getAlignmentAnnotation().hashCode() != _annotationScoreVectorHash)
+ if (viewport.getAlignment().getAlignmentAnnotation().hashCode() != _annotationScoreVectorHash)
{
sortByAnnotScore.removeAll();
// almost certainly a quicker way to do this - but we keep it simple
Hashtable scoreSorts = new Hashtable();
AlignmentAnnotation aann[];
- Enumeration sq = viewport.alignment.getSequences().elements();
+ Enumeration sq = viewport.getAlignment().getSequences().elements();
while (sq.hasMoreElements())
{
aann = ((SequenceI) sq.nextElement()).getAnnotation();
@@ -3455,13 +3715,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
Enumeration labels = scoreSorts.keys();
while (labels.hasMoreElements())
{
- addSortByAnnotScoreMenuItem(sortByAnnotScore, (String) labels
- .nextElement());
+ addSortByAnnotScoreMenuItem(sortByAnnotScore,
+ (String) labels.nextElement());
}
sortByAnnotScore.setVisible(scoreSorts.size() > 0);
scoreSorts.clear();
- _annotationScoreVectorHash = viewport.alignment
+ _annotationScoreVectorHash = viewport.getAlignment()
.getAlignmentAnnotation().hashCode();
}
}
@@ -3506,21 +3766,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
for (i = 0; i < treePanels.size(); i++)
{
- TreePanel tp = (TreePanel) treePanels.elementAt(i);
+ final TreePanel tp = (TreePanel) treePanels.elementAt(i);
final JMenuItem item = new JMenuItem(tp.getTitle());
final NJTree tree = ((TreePanel) treePanels.elementAt(i)).getTree();
item.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
- SequenceI[] oldOrder = viewport.getAlignment()
- .getSequencesArray();
- AlignmentSorter.sortByTree(viewport.getAlignment(), tree);
-
- addHistoryItem(new OrderCommand("Tree Sort", oldOrder,
- viewport.alignment));
-
- alignPanel.paintAlignment(true);
+ tp.sortByTree_actionPerformed(null);
+ addHistoryItem(tp.sortAlignmentIn(alignPanel));
+
}
});
@@ -3528,6 +3783,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
}
+ public boolean sortBy(AlignmentOrder alorder, String undoname)
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
+ if (undoname != null)
+ {
+ addHistoryItem(new OrderCommand(undoname, oldOrder,
+ viewport.getAlignment()));
+ }
+ alignPanel.paintAlignment(true);
+ return true;
+ }
+
/**
* Work out whether the whole set of sequences or just the selected set will
* be submitted for multiple alignment.
@@ -3589,13 +3857,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
// limit sequences - JBPNote in future - could spawn multiple prediction
// jobs
- // TODO: viewport.alignment.isAligned is a global state - the local
+ // TODO: viewport.getAlignment().isAligned is a global state - the local
// selection may well be aligned - we preserve 2.0.8 behaviour for moment.
- if (!viewport.alignment.isAligned())
+ if (!viewport.getAlignment().isAligned(false))
{
seqs.setSequences(new SeqCigar[]
{ seqs.getSequences()[0] });
- // TODO: if seqs.getSequences().length>1 then should really have warned user!
+ // TODO: if seqs.getSequences().length>1 then should really have warned
+ // user!
}
return seqs;
@@ -3610,8 +3879,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
{
// Pick the tree file
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
- .getProperty("LAST_DIRECTORY"));
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle("Select a newick-like tree file");
chooser.setToolTipText("Load a tree file");
@@ -3635,8 +3904,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
if (fin != null && fin.hasWarningMessage())
{
- JOptionPane.showMessageDialog(Desktop.desktop, fin
- .getWarningMessage(), "Possible problem with tree file",
+ JOptionPane.showMessageDialog(Desktop.desktop,
+ fin.getWarningMessage(), "Possible problem with tree file",
JOptionPane.WARNING_MESSAGE);
}
}
@@ -3709,98 +3978,201 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
return tp;
}
+ private boolean buildingMenu = false;
+
/**
* Generates menu items and listener event actions for web service clients
*
*/
public void BuildWebServiceMenu()
{
- // TODO: add support for context dependent disabling of services based on
- // alignment and current selection
- // TODO: add additional serviceHandle parameter to specify abstract handler
- // class independently of AbstractName
- // TODO: add in rediscovery GUI function to restart discoverer
- // TODO: group services by location as well as function and/or introduce
- // object broker mechanism.
- if ((Discoverer.services != null) && (Discoverer.services.size() > 0))
- {
- // TODO: refactor to allow list of AbstractName/Handler bindings to be
- // stored or retrieved from elsewhere
- Vector msaws = (Vector) Discoverer.services.get("MsaWS");
- Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
- Vector seqsrch = (Vector) Discoverer.services.get("SeqSearch");
- // TODO: move GUI generation code onto service implementation - so a
- // client instance attaches itself to the GUI with method call like
- // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
- // alignframe)
- Vector wsmenu = new Vector();
- final IProgressIndicator af = this;
- if (msaws != null)
+ while (buildingMenu)
+ {
+ try
{
- // Add any Multiple Sequence Alignment Services
- final JMenu msawsmenu = new JMenu("Alignment");
- for (int i = 0, j = msaws.size(); i < j; i++)
- {
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
- .get(i);
- jalview.ws.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(msawsmenu, this);
-
- }
- wsmenu.add(msawsmenu);
- }
- if (secstrpr != null)
+ System.err.println("Waiting for building menu to finish.");
+ Thread.sleep(10);
+ } catch (Exception e)
{
- // Add any secondary structure prediction services
- final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
- for (int i = 0, j = secstrpr.size(); i < j; i++)
- {
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
- .get(i);
- jalview.ws.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(secstrmenu, this);
- }
- wsmenu.add(secstrmenu);
}
- if (seqsrch != null)
+ ;
+ }
+ final AlignFrame me = this;
+ buildingMenu = true;
+ new Thread(new Runnable()
+ {
+ public void run()
{
- // Add any sequence search services
- final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
- for (int i = 0, j = seqsrch.size(); i < j; i++)
+ try
+ {
+ System.err.println("Building ws menu again "
+ + Thread.currentThread());
+ // TODO: add support for context dependent disabling of services based
+ // on
+ // alignment and current selection
+ // TODO: add additional serviceHandle parameter to specify abstract
+ // handler
+ // class independently of AbstractName
+ // TODO: add in rediscovery GUI function to restart discoverer
+ // TODO: group services by location as well as function and/or
+ // introduce
+ // object broker mechanism.
+ final Vector wsmenu = new Vector();
+ final IProgressIndicator af = me;
+ final JMenu msawsmenu = new JMenu("Alignment");
+ final JMenu secstrmenu = new JMenu(
+ "Secondary Structure Prediction");
+ final JMenu seqsrchmenu = new JMenu(
+ "Sequence Database Search");
+ final JMenu analymenu = new JMenu(
+ "Analysis");
+ // JAL-940 - only show secondary structure prediction services from the legacy server
+ if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
+ // &&
+ Discoverer.services != null
+ && (Discoverer.services.size() > 0))
+ {
+ // TODO: refactor to allow list of AbstractName/Handler bindings to
+ // be
+ // stored or retrieved from elsewhere
+ Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS");
+ Vector secstrpr = (Vector) Discoverer.services
+ .get("SecStrPred");
+ Vector seqsrch = null; // (Vector) Discoverer.services.get("SeqSearch");
+ // TODO: move GUI generation code onto service implementation - so a
+ // client instance attaches itself to the GUI with method call like
+ // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
+ // alignframe)
+ if (msaws != null)
+ {
+ // Add any Multiple Sequence Alignment Services
+ for (int i = 0, j = msaws.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
+ .get(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(msawsmenu, me);
+
+ }
+ }
+ if (secstrpr != null)
+ {
+ // Add any secondary structure prediction services
+ for (int i = 0, j = secstrpr.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
+ .get(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(secstrmenu, me);
+ }
+ }
+ if (seqsrch != null)
+ {
+ // Add any sequence search services
+ for (int i = 0, j = seqsrch.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
+ .elementAt(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(seqsrchmenu, me);
+ }
+ }
+ }
+
+ // TODO: move into separate menu builder class.
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ {
+ Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+ if (jws2servs != null)
+ {
+ if (jws2servs.hasServices())
+ {
+ jws2servs.attachWSMenuEntry(msawsmenu, me);
+ }
+ }
+ }
+ // Add all submenus in the order they should appear on the web services menu
+ wsmenu.add(msawsmenu);
+ wsmenu.add(secstrmenu);
+ wsmenu.add(analymenu);
+ // No search services yet
+ // wsmenu.add(seqsrchmenu);
+
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ webService.removeAll();
+ // first, add discovered services onto the webservices menu
+ if (wsmenu.size() > 0)
+ {
+ for (int i = 0, j = wsmenu.size(); i < j; i++)
+ {
+ webService.add((JMenu) wsmenu.get(i));
+ }
+ }
+ else
+ {
+ webService.add(me.webServiceNoServices);
+ }
+ build_urlServiceMenu(me.webService);
+ build_fetchdbmenu(webService);
+ } catch (Exception e)
+ {
+ }
+ ;
+ }
+ });
+ } catch (Exception e)
{
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
- .elementAt(i);
- jalview.ws.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(seqsrchmenu, this);
}
- // finally, add the whole shebang onto the webservices menu
- wsmenu.add(seqsrchmenu);
- }
- resetWebServiceMenu();
- for (int i = 0, j = wsmenu.size(); i < j; i++)
- {
- webService.add((JMenu) wsmenu.get(i));
+ ;
+
+ buildingMenu = false;
}
- }
- else
- {
- resetWebServiceMenu();
- this.webService.add(this.webServiceNoServices);
- }
+ }).start();
+
}
+
/**
- * empty the web service menu and add any ad-hoc functions not dynamically
- * discovered.
+ * construct any groupURL type service menu entries.
*
+ * @param webService
*/
- private void resetWebServiceMenu()
+ private void build_urlServiceMenu(JMenu webService)
{
- webService.removeAll();
- build_fetchdbmenu(webService);
+ // TODO: remove this code when 2.7 is released
+ // DEBUG - alignmentView
+ /*
+ * JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
+ * AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
+ *
+ * @Override public void actionPerformed(ActionEvent e) {
+ * jalview.datamodel.AlignmentView.testSelectionViews(af.viewport.getAlignment(),
+ * af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
+ *
+ * }); webService.add(testAlView);
+ */
+ // TODO: refactor to RestClient discoverer and merge menu entries for
+ // rest-style services with other types of analysis/calculation service
+ // SHmmr test client - still being implemented.
+ // DEBUG - alignmentView
+
+ for (jalview.ws.rest.RestClient client: jalview.ws.rest.RestClient.getRestClients()) {
+ client.attachWSMenuEntry(JvSwingUtils.findOrCreateMenu(webService, client.getAction()), this);
+ }
+
+ if (Cache.getDefault("SHOW_ENFIN_SERVICES", true))
+ {
+ jalview.ws.EnfinEnvision2OneWay.getInstance().attachWSMenuEntry(
+ webService, this);
+ }
}
/*
@@ -3885,8 +4257,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
} catch (Exception e)
{
jalview.bin.Cache.log
- .warn(
- "canTranslate threw an exception - please report to help@jalview.org",
+ .warn("canTranslate threw an exception - please report to help@jalview.org",
e);
return false;
}
@@ -3910,7 +4281,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
ths.setProgressBar("Searching for sequences from " + fsrc, sttime);
try
{
- Alignment ds = ths.getViewport().alignment.getDataset(); // update
+ Alignment ds = ths.getViewport().getAlignment().getDataset(); // update
// our local
// dataset
// reference
@@ -3976,13 +4347,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
// old way
try
{
- return (jalview.analysis.Dna.canTranslate(selection, viewport
- .getViewAsVisibleContigs(true)));
+ return (jalview.analysis.Dna.canTranslate(selection,
+ viewport.getViewAsVisibleContigs(true)));
} catch (Exception e)
{
jalview.bin.Cache.log
- .warn(
- "canTranslate threw an exception - please report to help@jalview.org",
+ .warn("canTranslate threw an exception - please report to help@jalview.org",
e);
return false;
}
@@ -4033,8 +4403,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
al = jalview.analysis.Dna.CdnaTranslate(selection, seqstring,
viewport.getViewAsVisibleContigs(true), viewport
- .getGapCharacter(), viewport.alignment
- .getAlignmentAnnotation(), viewport.alignment
+ .getGapCharacter(), viewport.getAlignment()
+ .getAlignmentAnnotation(), viewport.getAlignment()
.getWidth(), viewport.getAlignment().getDataset());
} catch (Exception ex)
{
@@ -4071,9 +4441,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
boolean featuresFile = false;
try
{
- featuresFile = new FeaturesFile(file, type).parse(viewport.alignment
- .getDataset(), alignPanel.seqPanel.seqCanvas
- .getFeatureRenderer().featureColours, false);
+ featuresFile = new FeaturesFile(file, type)
+ .parse(viewport.getAlignment().getDataset(),
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,
+ false, jalview.bin.Cache.getDefault(
+ "RELAXEDSEQIDMATCHING", false));
} catch (Exception ex)
{
ex.printStackTrace();
@@ -4088,6 +4460,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
// update the min/max ranges where necessary
alignPanel.seqPanel.seqCanvas.fr.findAllFeatures(true);
}
+ if (featureSettings != null)
+ {
+ featureSettings.setTableData();
+ }
alignPanel.paintAlignment(true);
}
@@ -4164,10 +4540,127 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
try
{
-
+ // check to see if any of these files have names matching sequences in
+ // the alignment
+ SequenceIdMatcher idm = new SequenceIdMatcher(viewport
+ .getAlignment().getSequencesArray());
+ /**
+ * Object[] { String,SequenceI}
+ */
+ ArrayList