X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=6c8e0e4e9573b1350249f2bf806649766bd7e4f4;hb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;hp=c0e9dc90293a739612790a790228bc0a2cdc9b13;hpb=e3a5770d5844eb5cf183424643605611d3545726;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index c0e9dc9..6c8e0e4 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -61,6 +61,7 @@ public class AlignViewport boolean validCharWidth; int wrappedWidth; Font font; + boolean seqNameItalics; AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); int threshold; @@ -109,13 +110,20 @@ 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; + + boolean rightAlignIds = false; + + Hashtable hiddenRepSequences; + - public AlignViewport(AlignmentI al, boolean dataset) - { - isDataset = dataset; - setAlignment(al); - init(); - } /** * Creates a new AlignViewport object. * @@ -153,14 +161,18 @@ public class AlignViewport showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true); showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true); + rightAlignIds = Cache.getDefault("RIGHT_ALIGN_IDS", false); + autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true); - padGaps = Cache.getDefault("PAD_GAPS", false); + padGaps = Cache.getDefault("PAD_GAPS", true); String fontName = Cache.getDefault("FONT_NAME", "SansSerif"); String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "") ; String fontSize = Cache.getDefault("FONT_SIZE", "10"); + seqNameItalics = Cache.getDefault("ID_ITALICS", true); + int style = 0; if (fontStyle.equals("bold")) @@ -174,7 +186,6 @@ public class AlignViewport setFont(new Font(fontName, style, Integer.parseInt(fontSize))); - alignment.setGapCharacter( Cache.getDefault("GAP_SYMBOL", "-").charAt(0) ); @@ -191,6 +202,7 @@ public class AlignViewport 11f, AlignmentAnnotation.BAR_GRAPH); conservation.hasText = true; + conservation.autoCalculated = true; if (Cache.getDefault("SHOW_CONSERVATION", true)) @@ -207,6 +219,7 @@ public class AlignViewport 11f, AlignmentAnnotation.BAR_GRAPH); quality.hasText = true; + quality.autoCalculated = true; alignment.addAnnotation(quality); } @@ -216,12 +229,12 @@ public class AlignViewport new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); consensus.hasText = true; + consensus.autoCalculated = true; if (Cache.getDefault("SHOW_IDENTITY", true)) { alignment.addAnnotation(consensus); } - } if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null) @@ -240,6 +253,8 @@ public class AlignViewport globalColourScheme.setConsensus(hconsensus); } } + + wrapAlignment = jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false); } @@ -273,6 +288,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; @@ -289,8 +325,7 @@ public class AlignViewport cons.findQuality(); } - - String sequence = cons.getConsSequence().getSequence(); + char [] sequence = cons.getConsSequence().getSequence(); float minR; float minG; float minB; @@ -325,7 +360,7 @@ public class AlignViewport { float value = 0; - c = sequence.charAt(i); + c = sequence[i]; if (Character.isDigit(c)) value = (int) (c - '0'); @@ -382,11 +417,14 @@ public class AlignViewport } + UPDATING_CONSERVATION = false; + updatingConservation = false; + if(ap!=null) { ap.repaint(); } - updatingConservation = false; + } } @@ -397,6 +435,10 @@ public class AlignViewport boolean consUpdateNeeded = false; + static boolean UPDATING_CONSENSUS = false; + + static boolean UPDATING_CONSERVATION = false; + boolean updatingConsensus = false; boolean updatingConservation = false; @@ -404,42 +446,22 @@ public class AlignViewport /** * DOCUMENT ME! */ - public void updateConservation(AlignmentPanel ap) + public void updateConservation(final AlignmentPanel ap) { - if (alignment.isNucleotide()) + if (alignment.isNucleotide() || conservation==null) return; - updatingConservation = true; - - if (conservationThread == null || !conservationThread.isAlive()) - { - conservationThread = new ConservationThread(ap); - conservationThread.start(); - } - else - { - consUpdateNeeded = true; - System.out.println("come back later"); - } + conservationThread = new ConservationThread(ap); + conservationThread.start(); } /** * DOCUMENT ME! */ - public void updateConsensus(AlignmentPanel ap) + public void updateConsensus(final AlignmentPanel ap) { - updatingConsensus = true; - - if (consensusThread == null || !consensusThread.isAlive()) - { - consensusThread = new ConsensusThread(ap); - consensusThread.start(); - } - else - { - consUpdateNeeded = true; - System.out.println("come back later"); - } + consensusThread = new ConsensusThread(ap); + consensusThread.start(); } @@ -452,6 +474,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(); @@ -498,6 +541,8 @@ public class AlignViewport } catch (OutOfMemoryError error) { + alignment.deleteAnnotation(consensus); + consensus = null; hconsensus = null; javax.swing.SwingUtilities.invokeLater(new Runnable() @@ -516,14 +561,13 @@ public class AlignViewport System.out.println("Consensus calculation: " + error); System.gc(); } + UPDATING_CONSENSUS = false; + updatingConsensus = false; if (ap != null) { ap.repaint(); } - - - updatingConsensus = false; } } /** @@ -544,6 +588,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; @@ -1225,6 +1270,33 @@ public class AlignViewport hasHiddenColumns = true; } + public void hideRepSequences(SequenceI repSequence, SequenceGroup sg) + { + int sSize = sg.getSize(); + if(sSize < 2) + return; + + if(hiddenRepSequences==null) + hiddenRepSequences = new Hashtable(); + + hiddenRepSequences.put(repSequence, sg); + + //Hide all sequences except the repSequence + SequenceI [] seqs = new SequenceI[sSize-1]; + int index = 0; + for(int i=0; i0) { if(selectionGroup==null) @@ -1295,7 +1369,7 @@ public class AlignViewport selectionGroup = new SequenceGroup(); selectionGroup.setEndRes(alignment.getWidth()-1); } - Vector tmp = alignment.getHiddenSequences().showAll(); + Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences); for(int t=0; talWidth) + sg.setEndRes(alWidth-1); + } + } + + if(selectionGroup!=null && selectionGroup.getEndRes()>alWidth) + selectionGroup.setEndRes(alWidth-1); + + resetAllColourSchemes(); + + // alignment.adjustSequenceAnnotations(); + } + + + void resetAllColourSchemes() + { + ColourSchemeI cs = globalColourScheme; + if(cs!=null) + { + if (cs instanceof ClustalxColourScheme) + { + ( (ClustalxColourScheme) cs). + resetClustalX(alignment.getSequences(), + alignment.getWidth()); + } + + cs.setConsensus(hconsensus); + if (cs.conservationApplied()) + { + Alignment al = (Alignment) alignment; + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, + al.getSequences(), 0, + al.getWidth() - 1); + c.calculate(); + c.verdict(false, ConsPercGaps); + + cs.setConservation(c); + } + } + + int s, sSize = alignment.getGroups().size(); + for(s=0; s