X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=46b2cc5acc64c83758cbdc75c04b6d9385141090;hb=7e129811d6ff01074428462284dffc2a6c2395a4;hp=efe8e639010b869c5773bcd1abffa0e48a040fa5;hpb=7bf593f3593a0392fb01d78644f7bfd75762a87e;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index efe8e63..46b2cc5 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -68,6 +68,17 @@ public class AlignFrame { viewport = new AlignViewport(al); + if(viewport.vconsensus==null) + { + //Out of memory caluclating consensus. + BLOSUM62Colour.setEnabled(false); + PIDColour.setEnabled(false); + conservationMenuItem.setEnabled(false); + modifyConservation.setEnabled(false); + abovePIDThreshold.setEnabled(false); + modifyPID.setEnabled(false); + } + alignPanel = new AlignmentPanel(this, viewport); alignPanel.annotationPanel.adjustPanelHeight(); alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel. @@ -76,21 +87,27 @@ public class AlignFrame getPreferredSize()); alignPanel.setAnnotationVisible(viewport.getShowAnnotation()); + String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort"); + + if(sortby.equals("Id")) + sortIDMenuItem_actionPerformed(null); + else if(sortby.equals("Pairwise Identity")) + sortPairwiseMenuItem_actionPerformed(null); + getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER); - addInternalFrameListener(new InternalFrameAdapter() + viewport.addPropertyChangeListener(new PropertyChangeListener() { - public void internalFrameActivated(InternalFrameEvent evt) - { - javax.swing.SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - alignPanel.requestFocus(); - } - }); - } - }); + public void propertyChange(PropertyChangeEvent evt) + { + if (evt.getPropertyName().equals("alignment")) + { + alignmentChanged(); + } + } + }); + + addServiceListeners(); } @@ -410,7 +427,7 @@ public class AlignFrame redoList.push(new HistoryItem(hi.getDescription(), viewport.alignment, HistoryItem.HIDE)); restoreHistoryItem(hi); - resetAllColourSchemes(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } /** @@ -423,9 +440,7 @@ public class AlignFrame HistoryItem hi = (HistoryItem) redoList.pop(); restoreHistoryItem(hi); updateEditMenuBar(); - viewport.updateConsensus(); - resetAllColourSchemes(); - alignPanel.repaint(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } // used by undo and redo @@ -470,9 +485,6 @@ public class AlignFrame updateEditMenuBar(); - viewport.updateConsensus(); - viewport.updateConservation(); - alignPanel.repaint(); viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } @@ -701,20 +713,17 @@ public class AlignFrame } else { - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); viewport.setEndSeq(viewport.alignment.getHeight()); viewport.alignment.getWidth(); - viewport.updateConservation(); - viewport.updateConsensus(); - alignPanel.repaint(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } } catch (Exception ex) { + // could be anything being pasted in here } - // could be anything being pasted in here + } /** @@ -779,13 +788,10 @@ public class AlignFrame viewport.setSelectionGroup(null); viewport.alignment.deleteGroup(sg); - if (seqsdeleted) - { - viewport.firePropertyChange("alignment", null, + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); - } - viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getHeight()); + if (viewport.getAlignment().getHeight() < 1) { @@ -797,10 +803,6 @@ public class AlignFrame { } } - - viewport.updateConservation(); - viewport.updateConsensus(); - alignPanel.repaint(); } /** @@ -909,7 +911,7 @@ public class AlignFrame } } - alignPanel.repaint(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } } @@ -947,7 +949,7 @@ public class AlignFrame } } - alignPanel.repaint(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } } @@ -970,10 +972,7 @@ public class AlignFrame viewport.setStartRes(seq.findIndex(startRes)-1); - resetAllColourSchemes(); - viewport.updateConservation(); - viewport.updateConsensus(); - alignPanel.repaint(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } /** @@ -1035,40 +1034,45 @@ public class AlignFrame viewport.setStartRes(seq.findIndex(startRes)-1); - - viewport.updateConservation(); - viewport.updateConsensus(); - resetAllColourSchemes(); - alignPanel.repaint(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } + public void alignmentChanged() + { + if(viewport.vconsensus!=null) + { + viewport.updateConsensus(); + viewport.updateConservation(); + } + resetAllColourSchemes(); + alignPanel.repaint(); + } void resetAllColourSchemes() { ColourSchemeI cs = viewport.globalColourScheme; if(cs!=null) { - cs.setConsensus(viewport.vconsensus); - if(cs.conservationApplied()) - { - Alignment al = (Alignment) viewport.alignment; - Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, - al.getSequences(), 0, - al.getWidth() - 1); - c.calculate(); - c.verdict(false, viewport.ConsPercGaps); + if (cs instanceof ClustalxColourScheme) + { + ( (ClustalxColourScheme) viewport.getGlobalColourScheme()). + resetClustalX(viewport.alignment.getSequences(), + viewport.alignment.getWidth()); + } - cs.setConservation(c); - } - } + cs.setConsensus(viewport.vconsensus); + if (cs.conservationApplied()) + { + Alignment al = (Alignment) viewport.alignment; + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, + al.getSequences(), 0, + al.getWidth() - 1); + c.calculate(); + c.verdict(false, viewport.ConsPercGaps); - if(viewport.getGlobalColourScheme()!=null - && viewport.getGlobalColourScheme() instanceof ClustalxColourScheme) - { - ((ClustalxColourScheme)viewport.getGlobalColourScheme()). - resetClustalX(viewport.alignment.getSequences(), - viewport.alignment.getWidth()); + cs.setConservation(c); + } } int s, sSize = viewport.alignment.getGroups().size(); @@ -1079,9 +1083,7 @@ public class AlignFrame { ((ClustalxColourScheme)sg.cs).resetClustalX(sg.sequences, sg.getWidth()); } - sg.recalcConservation(); - } } @@ -1109,9 +1111,7 @@ public class AlignFrame } } - viewport.updateConservation(); - viewport.updateConsensus(); - alignPanel.repaint(); + alignmentChanged(); } /**