X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=ec52ee35c56572ccadff42af340733d18765fec3;hb=38c2f5336bb602570ab698985810b870fa7390de;hp=efce038fde607092cbcf8ff3c05ff1d5ec9b02e0;hpb=36244a2f01fed95c198b8f8c84b6f0020f679b66;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index efce038..ec52ee3 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -109,6 +109,16 @@ public class AlignViewport boolean gatherViewsHere = false; + Stack historyList = new Stack(); + Stack redoList = new Stack(); + + Hashtable sequenceColours; + + int thresholdTextColour = 0; + Color textColour = Color.black; + Color textColour2 = Color.white; + + /** * Creates a new AlignViewport object. * @@ -231,6 +241,8 @@ public class AlignViewport globalColourScheme.setConsensus(hconsensus); } } + + wrapAlignment = jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false); } @@ -264,6 +276,27 @@ public class AlignViewport { try { + updatingConservation = true; + + while (UPDATING_CONSERVATION) + { + try + { + if (ap != null) + { + ap.repaint(); + } + Thread.sleep(200); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + UPDATING_CONSERVATION = true; + + int alWidth = alignment.getWidth(); if(alWidth<0) return; @@ -372,21 +405,28 @@ public class AlignViewport } + UPDATING_CONSERVATION = false; + updatingConservation = false; + if(ap!=null) { ap.repaint(); } - updatingConservation = false; + } } - static ConservationThread conservationThread; + ConservationThread conservationThread; - static ConsensusThread consensusThread; + ConsensusThread consensusThread; boolean consUpdateNeeded = false; + static boolean UPDATING_CONSENSUS = false; + + static boolean UPDATING_CONSERVATION = false; + boolean updatingConsensus = false; boolean updatingConservation = false; @@ -399,21 +439,8 @@ public class AlignViewport if (alignment.isNucleotide() || conservation==null) return; - updatingConservation = true; - // javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { - while (conservationThread != null && conservationThread.isAlive()) - { - try - { - // Thread.sleep(100); - ap.repaint(); - } - catch (Exception ex) - {} - } - conservationThread = new ConservationThread(ap); - conservationThread.start(); - // } }); + conservationThread = new ConservationThread(ap); + conservationThread.start(); } /** @@ -421,22 +448,8 @@ public class AlignViewport */ public void updateConsensus(final AlignmentPanel ap) { - updatingConsensus = true; - - // javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { - while (consensusThread != null && consensusThread.isAlive()) - { - try - { - // Thread.sleep(100); - ap.repaint(); - } - catch (Exception ex) - {} - } - consensusThread = new ConsensusThread(ap); - consensusThread.start(); - // } }); + consensusThread = new ConsensusThread(ap); + consensusThread.start(); } @@ -449,6 +462,27 @@ public class AlignViewport } public void run() { + updatingConsensus = true; + while (UPDATING_CONSENSUS) + { + try + { + if (ap != null) + { + ap.repaint(); + } + + Thread.sleep(200); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + + UPDATING_CONSENSUS = true; + try { int aWidth = alignment.getWidth(); @@ -495,6 +529,8 @@ public class AlignViewport } catch (OutOfMemoryError error) { + alignment.deleteAnnotation(consensus); + consensus = null; hconsensus = null; javax.swing.SwingUtilities.invokeLater(new Runnable() @@ -513,14 +549,13 @@ public class AlignViewport System.out.println("Consensus calculation: " + error); System.gc(); } + UPDATING_CONSENSUS = false; + updatingConsensus = false; if (ap != null) { ap.repaint(); } - - - updatingConsensus = false; } } /** @@ -541,6 +576,7 @@ public class AlignViewport seqs.append(consensus.annotations[i].displayCharacter); } } + SequenceI sq = new Sequence("Consensus", seqs.toString()); sq.setDescription("Percentage Identity Consensus "+((ignoreGapsInConsensusCalculation) ? " without gaps" : "")); return sq; @@ -1507,6 +1543,22 @@ public class AlignViewport updateConservation(ap); } + //Reset endRes of groups if beyond alignment width + int alWidth = alignment.getWidth(); + Vector groups = alignment.getGroups(); + if(groups!=null) + { + for(int i=0; ialWidth) + sg.setEndRes(alWidth-1); + } + } + + if(selectionGroup!=null && selectionGroup.getEndRes()>alWidth) + selectionGroup.setEndRes(alWidth-1); + resetAllColourSchemes(); alignment.adjustSequenceAnnotations(); @@ -1554,5 +1606,24 @@ public class AlignViewport } + public Color getSequenceColour(SequenceI seq) + { + if(sequenceColours==null || !sequenceColours.containsKey(seq)) + return Color.white; + else + return (Color)sequenceColours.get(seq); + } + + public void setSequenceColour(SequenceI seq, Color col) + { + if(sequenceColours==null) + sequenceColours = new Hashtable(); + + if(col == null) + sequenceColours.remove(seq); + else + sequenceColours.put(seq, col); + } + }