import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.NJTree;
import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
import jalview.api.ViewStyleI;
import jalview.bin.Cache;
import jalview.commands.CommandI;
+import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
+import java.util.Set;
import java.util.Vector;
import javax.swing.JInternalFrame;
private boolean gatherViewsHere = false;
private AnnotationColumnChooser annotationColumnSelectionState;
+
/**
* Creates a new AlignViewport object.
*
viewStyle.getFontSize()), false);
}
+
/**
* DOCUMENT ME!
*
*/
public void replaceMappings(AlignmentI align)
{
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Desktop.instance);
/*
* Deregister current mappings (if any)
*/
- if (alignment != null)
- {
- ssm.deregisterMappings(alignment.getCodonFrames());
- }
+ deregisterMappings();
/*
* Register new mappings (if any)
*/
if (align != null)
{
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance);
ssm.registerMappings(align.getCodonFrames());
}
}
}
+ protected void deregisterMappings()
+ {
+ AlignmentI al = getAlignment();
+ if (al != null)
+ {
+ Set<AlignedCodonFrame> mappings = al.getCodonFrames();
+ if (mappings != null)
+ {
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance);
+ for (AlignedCodonFrame acf : mappings)
+ {
+ if (noReferencesTo(acf))
+ {
+ ssm.deregisterMapping(acf);
+ }
+ }
+ }
+ }
+ }
+
/**
* DOCUMENT ME!
*
// TODO: JAL-1126
if (historyList == null || redoList == null)
{
- return new long[]
- { -1, -1 };
+ return new long[] { -1, -1 };
}
- return new long[]
- { historyList.hashCode(), this.redoList.hashCode() };
+ return new long[] { historyList.hashCode(), this.redoList.hashCode() };
}
/**
List<SequenceI> seqs = new ArrayList<SequenceI>();
for (SequenceI sq : alignment.getSequences())
{
- Vector<PDBEntry> pdbs = sq
- .getDatasetSequence().getAllPDBEntries();
+ Vector<PDBEntry> pdbs = sq.getDatasetSequence().getAllPDBEntries();
if (pdbs == null)
{
continue;
*/
protected boolean openLinkedAlignment(AlignmentI al, String title)
{
- String[] options = new String[]
- { MessageManager.getString("action.no"),
+ String[] options = new String[] {
+ MessageManager.getString("action.no"),
MessageManager.getString("label.split_window"),
MessageManager.getString("label.new_window"), };
final String question = JvSwingUtils.wrapTooltip(true,
* is a pre-requisite for building mappings.
*/
al.setDataset(null);
- AlignmentUtils.mapProteinToCdna(protein, cdna);
+ AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
/*
* Create the AlignFrame for the added alignment. If it is protein, mappings
AlignFrame.DEFAULT_HEIGHT);
newAlignFrame.setTitle(title);
newAlignFrame.statusBar.setText(MessageManager.formatMessage(
- "label.successfully_loaded_file", new Object[]
- { title }));
+ "label.successfully_loaded_file", new Object[] { title }));
// TODO if we want this (e.g. to enable reload of the alignment from file),
// we will need to add parameters to the stack.
if (openInNewWindow)
{
Desktop.addInternalFrame(newAlignFrame, title,
- AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
+ AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
}
try
{
newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
- "SHOW_FULLSCREEN",
- false));
+ "SHOW_FULLSCREEN", false));
} catch (java.beans.PropertyVetoException ex)
{
}
{
/*
* Make a new frame with a copy of the alignment we are adding to. If this
- * is protein, the mappings to cDNA will be registered with StructureSelectionManager as a side-effect.
+ * is protein, the mappings to cDNA will be registered with
+ * StructureSelectionManager as a side-effect.
*/
AlignFrame copyMe = new AlignFrame(complement,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
AlignmentI al = newAlignFrame.viewport.getAlignment();
final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
: newAlignFrame;
- final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame
- : copyMe;
+ final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
cdnaFrame.setVisible(true);
proteinFrame.setVisible(true);
String linkedTitle = MessageManager
if (!sr.isEmpty())
{
// TODO would like next line without cast but needs more refactoring...
- final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement()).getAlignPanel();
- complementPanel.setFollowingComplementScroll(true);
+ final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
+ .getAlignPanel();
+ complementPanel.setDontScrollComplement(true);
complementPanel.scrollToCentre(sr, verticalOffset);
}
}
+ /**
+ * Answers true if no alignment holds a reference to the given mapping
+ *
+ * @param acf
+ * @return
+ */
+ protected boolean noReferencesTo(AlignedCodonFrame acf)
+ {
+ AlignFrame[] frames = Desktop.getAlignFrames();
+ if (frames == null)
+ {
+ return true;
+ }
+ for (AlignFrame af : frames)
+ {
+ if (!af.isClosed())
+ {
+ for (AlignmentViewPanel ap : af.getAlignPanels())
+ {
+ AlignmentI al = ap.getAlignment();
+ if (al != null && al.getCodonFrames().contains(acf))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
}