2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.appletgui;
24 import jalview.analysis.*;
26 import jalview.datamodel.*;
27 import jalview.schemes.*;
28 import jalview.structure.SelectionSource;
30 public class AlignViewport implements SelectionSource
40 boolean cursorMode = false;
42 boolean showJVSuffix = true;
44 boolean showText = true;
46 boolean showColourText = false;
48 boolean showBoxes = true;
50 boolean wrapAlignment = false;
52 boolean renderGaps = true;
54 boolean showSequenceFeatures = false;
56 boolean showAnnotation = true;
58 boolean showConservation = true;
60 boolean showQuality = true;
62 boolean showConsensus = true;
64 boolean upperCasebold = false;
66 boolean colourAppliesToAllGroups = true;
68 ColourSchemeI globalColourScheme = null;
70 boolean conservationColourSelected = false;
72 boolean abovePIDThreshold = false;
74 SequenceGroup selectionGroup;
82 Font font = new Font("SansSerif", Font.PLAIN, 10);
84 boolean validCharWidth = true;
88 ColumnSelection colSel = new ColumnSelection();
94 NJTree currentTree = null;
96 boolean scaleAboveWrapped = true;
98 boolean scaleLeftWrapped = true;
100 boolean scaleRightWrapped = true;
102 // The following vector holds the features which are
103 // currently visible, in the correct order or rendering
104 public Hashtable featuresDisplayed;
106 boolean hasHiddenColumns = false;
108 boolean hasHiddenRows = false;
110 boolean showHiddenMarkers = true;
112 public Hashtable[] hconsensus;
114 AlignmentAnnotation consensus;
116 AlignmentAnnotation conservation;
118 AlignmentAnnotation quality;
120 AlignmentAnnotation[] groupConsensus;
122 AlignmentAnnotation[] groupConservation;
124 boolean autocalculateConsensus = true;
126 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
128 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
131 boolean ignoreGapsInConsensusCalculation = false;
133 jalview.bin.JalviewLite applet;
135 Hashtable sequenceColours;
139 Stack historyList = new Stack();
141 Stack redoList = new Stack();
143 String sequenceSetID;
145 Hashtable hiddenRepSequences;
147 public AlignViewport(AlignmentI al, JalviewLite applet)
149 this.applet = applet;
152 this.endRes = al.getWidth() - 1;
154 this.endSeq = al.getHeight() - 1;
157 // get the width and height scaling factors if they were specified
158 String param = applet.getParameter("widthScale");
163 widthScale = new Float(param).floatValue();
164 } catch (Exception e)
167 if (widthScale <= 1.0)
170 .println("Invalid alignment character width scaling factor ("
171 + widthScale + "). Ignoring.");
177 .println("Alignment character width scaling factor is now "
181 param = applet.getParameter("heightScale");
186 heightScale = new Float(param).floatValue();
187 } catch (Exception e)
190 if (heightScale <= 1.0)
193 .println("Invalid alignment character height scaling factor ("
194 + heightScale + "). Ignoring.");
200 .println("Alignment character height scaling factor is now "
207 MAC = new jalview.util.Platform().isAMac();
211 String param = applet.getParameter("showFullId");
214 showJVSuffix = Boolean.valueOf(param).booleanValue();
217 param = applet.getParameter("showAnnotation");
220 showAnnotation = Boolean.valueOf(param).booleanValue();
223 param = applet.getParameter("showConservation");
226 showConservation = Boolean.valueOf(param).booleanValue();
229 param = applet.getParameter("showQuality");
232 showQuality = Boolean.valueOf(param).booleanValue();
235 param = applet.getParameter("showConsensus");
238 showConsensus = Boolean.valueOf(param).booleanValue();
241 param = applet.getParameter("showUnconserved");
244 this.showUnconserved = Boolean.valueOf(param).booleanValue();
247 param = applet.getParameter("upperCase");
250 if (param.equalsIgnoreCase("bold"))
252 upperCasebold = true;
255 param = applet.getParameter("sortByTree");
258 sortByTree = Boolean.valueOf(param).booleanValue();
265 String colour = applet.getParameter("defaultColour");
269 colour = applet.getParameter("userDefinedColour");
272 colour = "User Defined";
278 globalColourScheme = ColourSchemeProperty.getColour(alignment,
280 if (globalColourScheme != null)
282 globalColourScheme.setConsensus(hconsensus);
286 if (applet.getParameter("userDefinedColour") != null)
288 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
289 .getParameter("userDefinedColour"));
292 if (hconsensus == null)
294 if (!alignment.isNucleotide())
296 conservation = new AlignmentAnnotation("Conservation",
297 "Conservation of total alignment less than " + ConsPercGaps
298 + "% gaps", new Annotation[1], 0f, 11f,
299 AlignmentAnnotation.BAR_GRAPH);
300 conservation.hasText = true;
301 conservation.autoCalculated = true;
303 if (showConservation)
305 alignment.addAnnotation(conservation);
310 quality = new AlignmentAnnotation("Quality",
311 "Alignment Quality based on Blosum62 scores",
312 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
313 quality.hasText = true;
314 quality.autoCalculated = true;
316 alignment.addAnnotation(quality);
320 consensus = new AlignmentAnnotation("Consensus", "PID",
321 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
322 consensus.hasText = true;
323 consensus.autoCalculated = true;
327 alignment.addAnnotation(consensus);
333 public void showSequenceFeatures(boolean b)
335 showSequenceFeatures = b;
338 public boolean getShowSequenceFeatures()
340 return showSequenceFeatures;
343 class ConservationThread extends Thread
347 public ConservationThread(AlignmentPanel ap)
356 updatingConservation = true;
358 while (UPDATING_CONSERVATION)
364 ap.paintAlignment(false);
367 } catch (Exception ex)
369 ex.printStackTrace();
373 UPDATING_CONSERVATION = true;
375 int alWidth = (alignment==null) ? -1 : alignment.getWidth();
378 updatingConservation = false;
379 UPDATING_CONSERVATION = false;
383 Conservation cons = new jalview.analysis.Conservation("All",
384 jalview.schemes.ResidueProperties.propHash, 3,
385 alignment.getSequences(), 0, alWidth - 1);
388 cons.verdict(false, ConsPercGaps);
395 char[] sequence = cons.getConsSequence().getSequence();
407 maxB = 0f - minB; // scalable range for colouring both Conservation and
417 conservation.annotations = new Annotation[alWidth];
421 quality.graphMax = cons.qualityRange[1].floatValue();
422 quality.annotations = new Annotation[alWidth];
423 qmin = cons.qualityRange[0].floatValue();
424 qmax = cons.qualityRange[1].floatValue();
427 for (int i = 0; i < alWidth; i++)
433 if (Character.isDigit(c))
435 value = (int) (c - '0');
445 // TODO - refactor to use a graduatedColorScheme to calculate the
447 float vprop = value - min;
449 conservation.annotations[i] = new Annotation(String.valueOf(c),
450 String.valueOf(value), ' ', value, new Color(minR
451 + (maxR * vprop), minG + (maxG * vprop), minB
457 value = ((Double) cons.quality.elementAt(i)).floatValue();
458 vprop = value - qmin;
460 quality.annotations[i] = new Annotation(" ",
461 String.valueOf(value), ' ', value, new Color(minR
462 + (maxR * vprop), minG + (maxG * vprop), minB
466 } catch (OutOfMemoryError error)
468 System.out.println("Out of memory calculating conservation!!");
474 UPDATING_CONSERVATION = false;
475 updatingConservation = false;
479 ap.paintAlignment(true);
485 ConservationThread conservationThread;
487 ConsensusThread consensusThread;
489 boolean consUpdateNeeded = false;
491 static boolean UPDATING_CONSENSUS = false;
493 static boolean UPDATING_CONSERVATION = false;
495 boolean updatingConsensus = false;
497 boolean updatingConservation = false;
502 public void updateConservation(final AlignmentPanel ap)
504 if (alignment.isNucleotide() || conservation == null)
509 conservationThread = new ConservationThread(ap);
510 conservationThread.start();
516 public void updateConsensus(final AlignmentPanel ap)
518 consensusThread = new ConsensusThread(ap);
519 consensusThread.start();
522 class ConsensusThread extends Thread
526 public ConsensusThread(AlignmentPanel ap)
533 updatingConsensus = true;
534 while (UPDATING_CONSENSUS)
540 ap.paintAlignment(false);
544 } catch (Exception ex)
546 ex.printStackTrace();
550 UPDATING_CONSENSUS = true;
554 int aWidth = alignment==null ? -1 : alignment.getWidth();
557 UPDATING_CONSENSUS = false;
558 updatingConsensus = false;
562 consensus.annotations = null;
563 consensus.annotations = new Annotation[aWidth];
565 hconsensus = new Hashtable[aWidth];
566 AAFrequency.calculate(alignment.getSequencesArray(), 0,
567 alignment.getWidth(), hconsensus, true); // always calculate the
569 AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
570 ignoreGapsInConsensusCalculation,
571 includeAllConsensusSymbols);
573 if (globalColourScheme != null)
575 globalColourScheme.setConsensus(hconsensus);
578 } catch (OutOfMemoryError error)
580 alignment.deleteAnnotation(consensus);
584 System.out.println("Out of memory calculating consensus!!");
587 UPDATING_CONSENSUS = false;
588 updatingConsensus = false;
592 ap.paintAlignment(true);
598 * get the consensus sequence as displayed under the PID consensus annotation
601 * @return consensus sequence as a new sequence object
603 public SequenceI getConsensusSeq()
605 if (consensus == null)
609 StringBuffer seqs = new StringBuffer();
610 for (int i = 0; i < consensus.annotations.length; i++)
612 if (consensus.annotations[i] != null)
614 if (consensus.annotations[i].description.charAt(0) == '[')
616 seqs.append(consensus.annotations[i].description.charAt(1));
620 seqs.append(consensus.annotations[i].displayCharacter);
624 SequenceI sq = new Sequence("Consensus", seqs.toString());
625 sq.setDescription("Percentage Identity Consensus "
626 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
630 public SequenceGroup getSelectionGroup()
632 return selectionGroup;
635 public void setSelectionGroup(SequenceGroup sg)
640 public boolean getConservationSelected()
642 return conservationColourSelected;
645 public void setConservationSelected(boolean b)
647 conservationColourSelected = b;
650 public boolean getAbovePIDThreshold()
652 return abovePIDThreshold;
655 public void setAbovePIDThreshold(boolean b)
657 abovePIDThreshold = b;
660 public int getStartRes()
665 public int getEndRes()
670 public int getStartSeq()
675 public void setGlobalColourScheme(ColourSchemeI cs)
677 globalColourScheme = cs;
680 public ColourSchemeI getGlobalColourScheme()
682 return globalColourScheme;
685 public void setStartRes(int res)
690 public void setStartSeq(int seq)
695 public void setEndRes(int res)
697 if (res > alignment.getWidth() - 1)
699 // log.System.out.println(" Corrected res from " + res + " to maximum " +
700 // (alignment.getWidth()-1));
701 res = alignment.getWidth() - 1;
710 public void setEndSeq(int seq)
712 if (seq > alignment.getHeight())
714 seq = alignment.getHeight();
723 public int getEndSeq()
728 java.awt.Frame nullFrame;
730 protected FeatureSettings featureSettings = null;
732 private float heightScale = 1, widthScale = 1;
734 public void setFont(Font f)
737 if (nullFrame == null)
739 nullFrame = new java.awt.Frame();
740 nullFrame.addNotify();
743 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
744 setCharHeight((int) (heightScale * fm.getHeight()));
745 charWidth = (int) (widthScale * fm.charWidth('M'));
749 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
750 fm = nullFrame.getGraphics().getFontMetrics(f2);
751 charWidth = (int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10));
755 public Font getFont()
760 public int getCharWidth()
765 public void setCharHeight(int h)
770 public int getCharHeight()
775 public void setWrappedWidth(int w)
777 this.wrappedWidth = w;
780 public int getwrappedWidth()
785 public AlignmentI getAlignment()
790 public void setAlignment(AlignmentI align)
792 this.alignment = align;
795 public void setWrapAlignment(boolean state)
797 wrapAlignment = state;
800 public void setShowText(boolean state)
805 public void setRenderGaps(boolean state)
810 public boolean getColourText()
812 return showColourText;
815 public void setColourText(boolean state)
817 showColourText = state;
820 public void setShowBoxes(boolean state)
825 public boolean getWrapAlignment()
827 return wrapAlignment;
830 public boolean getShowText()
835 public boolean getShowBoxes()
840 public char getGapCharacter()
842 return getAlignment().getGapCharacter();
845 public void setGapCharacter(char gap)
847 if (getAlignment() != null)
849 getAlignment().setGapCharacter(gap);
853 public void setThreshold(int thresh)
858 public int getThreshold()
863 public void setIncrement(int inc)
868 public int getIncrement()
873 public void setHiddenColumns(ColumnSelection colsel)
875 this.colSel = colsel;
876 if (colSel.getHiddenColumns() != null)
878 hasHiddenColumns = true;
882 public ColumnSelection getColumnSelection()
887 public void resetSeqLimits(int height)
889 setEndSeq(height / getCharHeight());
892 public void setCurrentTree(NJTree tree)
897 public NJTree getCurrentTree()
902 public void setColourAppliesToAllGroups(boolean b)
904 colourAppliesToAllGroups = b;
907 public boolean getColourAppliesToAllGroups()
909 return colourAppliesToAllGroups;
912 public boolean getShowJVSuffix()
917 public void setShowJVSuffix(boolean b)
922 public boolean getShowAnnotation()
924 return showAnnotation;
927 public void setShowAnnotation(boolean b)
932 public boolean getScaleAboveWrapped()
934 return scaleAboveWrapped;
937 public boolean getScaleLeftWrapped()
939 return scaleLeftWrapped;
942 public boolean getScaleRightWrapped()
944 return scaleRightWrapped;
947 public void setScaleAboveWrapped(boolean b)
949 scaleAboveWrapped = b;
952 public void setScaleLeftWrapped(boolean b)
954 scaleLeftWrapped = b;
957 public void setScaleRightWrapped(boolean b)
959 scaleRightWrapped = b;
962 public void setIgnoreGapsConsensus(boolean b)
964 ignoreGapsInConsensusCalculation = b;
965 updateConsensus(null);
966 if (globalColourScheme != null)
968 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
969 ignoreGapsInConsensusCalculation);
975 * Property change listener for changes in alignment
980 public void addPropertyChangeListener(
981 java.beans.PropertyChangeListener listener)
983 changeSupport.addPropertyChangeListener(listener);
992 public void removePropertyChangeListener(
993 java.beans.PropertyChangeListener listener)
995 changeSupport.removePropertyChangeListener(listener);
999 * Property change listener for changes in alignment
1008 public void firePropertyChange(String prop, Object oldvalue,
1011 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1014 public boolean getIgnoreGapsConsensus()
1016 return ignoreGapsInConsensusCalculation;
1019 public void hideSelectedColumns()
1021 if (colSel.size() < 1)
1026 colSel.hideSelectedColumns();
1027 setSelectionGroup(null);
1029 hasHiddenColumns = true;
1032 public void invertColumnSelection()
1034 for (int i = 0; i < alignment.getWidth(); i++)
1036 if (colSel.contains(i))
1038 colSel.removeElement(i);
1042 if (!hasHiddenColumns || colSel.isVisible(i))
1044 colSel.addElement(i);
1050 public void hideColumns(int start, int end)
1054 colSel.hideColumns(start);
1058 colSel.hideColumns(start, end);
1061 hasHiddenColumns = true;
1064 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1066 int sSize = sg.getSize();
1072 if (hiddenRepSequences == null)
1074 hiddenRepSequences = new Hashtable();
1077 hiddenRepSequences.put(repSequence, sg);
1079 // Hide all sequences except the repSequence
1080 SequenceI[] seqs = new SequenceI[sSize - 1];
1082 for (int i = 0; i < sSize; i++)
1084 if (sg.getSequenceAt(i) != repSequence)
1086 if (index == sSize - 1)
1091 seqs[index++] = sg.getSequenceAt(i);
1099 public void hideAllSelectedSeqs()
1101 if (selectionGroup == null || selectionGroup.getSize() < 1)
1106 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1110 setSelectionGroup(null);
1113 public void hideSequence(SequenceI[] seq)
1117 for (int i = 0; i < seq.length; i++)
1119 alignment.getHiddenSequences().hideSequence(seq[i]);
1122 hasHiddenRows = true;
1123 firePropertyChange("alignment", null, alignment.getSequences());
1126 public void showSequence(int index)
1128 Vector tmp = alignment.getHiddenSequences().showSequence(index,
1129 hiddenRepSequences);
1132 if (selectionGroup == null)
1134 selectionGroup = new SequenceGroup();
1135 selectionGroup.setEndRes(alignment.getWidth() - 1);
1138 for (int t = 0; t < tmp.size(); t++)
1140 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1142 firePropertyChange("alignment", null, alignment.getSequences());
1146 if (alignment.getHiddenSequences().getSize() < 1)
1148 hasHiddenRows = false;
1151 public void showColumn(int col)
1153 colSel.revealHiddenColumns(col);
1154 if (colSel.getHiddenColumns() == null)
1156 hasHiddenColumns = false;
1160 public void showAllHiddenColumns()
1162 colSel.revealAllHiddenColumns();
1163 hasHiddenColumns = false;
1166 public void showAllHiddenSeqs()
1168 if (alignment.getHiddenSequences().getSize() > 0)
1170 if (selectionGroup == null)
1172 selectionGroup = new SequenceGroup();
1173 selectionGroup.setEndRes(alignment.getWidth() - 1);
1175 Vector tmp = alignment.getHiddenSequences().showAll(
1176 hiddenRepSequences);
1177 for (int t = 0; t < tmp.size(); t++)
1179 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1181 firePropertyChange("alignment", null, alignment.getSequences());
1182 hasHiddenRows = false;
1183 hiddenRepSequences = null;
1188 public int adjustForHiddenSeqs(int alignmentIndex)
1190 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1195 * This method returns the a new SequenceI [] with the selection sequence and
1196 * start and end points adjusted
1200 public SequenceI[] getSelectionAsNewSequence()
1202 SequenceI[] sequences;
1204 if (selectionGroup == null)
1206 sequences = alignment.getSequencesArray();
1210 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1217 * get the currently selected sequence objects or all the sequences in the
1220 * @return array of references to sequence objects
1222 public SequenceI[] getSequenceSelection()
1224 SequenceI[] sequences = null;
1225 if (selectionGroup != null)
1227 sequences = selectionGroup.getSequencesInOrder(alignment);
1229 if (sequences == null)
1231 sequences = alignment.getSequencesArray();
1237 * This method returns the visible alignment as text, as seen on the GUI, ie
1238 * if columns are hidden they will not be returned in the result. Use this for
1239 * calculating trees, PCA, redundancy etc on views which contain hidden
1244 public jalview.datamodel.CigarArray getViewAsCigars(
1245 boolean selectedRegionOnly)
1247 return new jalview.datamodel.CigarArray(alignment, (hasHiddenColumns ? colSel : null), (selectedRegionOnly ? selectionGroup : null));
1251 * return a compact representation of the current alignment selection to pass
1252 * to an analysis function
1254 * @param selectedOnly
1255 * boolean true to just return the selected view
1256 * @return AlignmentView
1258 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1260 return getAlignmentView(selectedOnly, false);
1264 * return a compact representation of the current alignment selection to pass
1265 * to an analysis function
1267 * @param selectedOnly
1268 * boolean true to just return the selected view
1270 * boolean true to annotate the alignment view with groups on the alignment (and intersecting with selected region if selectedOnly is true)
1271 * @return AlignmentView
1273 public jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups)
1275 return new AlignmentView(alignment, colSel, selectionGroup, hasHiddenColumns, selectedOnly, markGroups);
1278 * This method returns the visible alignment as text, as seen on the GUI, ie
1279 * if columns are hidden they will not be returned in the result. Use this for
1280 * calculating trees, PCA, redundancy etc on views which contain hidden
1285 public String[] getViewAsString(boolean selectedRegionOnly)
1287 String[] selection = null;
1288 SequenceI[] seqs = null;
1290 int start = 0, end = 0;
1291 if (selectedRegionOnly && selectionGroup != null)
1293 iSize = selectionGroup.getSize();
1294 seqs = selectionGroup.getSequencesInOrder(alignment);
1295 start = selectionGroup.getStartRes();
1296 end = selectionGroup.getEndRes() + 1;
1300 iSize = alignment.getHeight();
1301 seqs = alignment.getSequencesArray();
1302 end = alignment.getWidth();
1305 selection = new String[iSize];
1307 for (i = 0; i < iSize; i++)
1309 if (hasHiddenColumns)
1311 StringBuffer visibleSeq = new StringBuffer();
1312 Vector regions = colSel.getHiddenColumns();
1314 int blockStart = start, blockEnd = end;
1316 int hideStart, hideEnd;
1318 for (int j = 0; j < regions.size(); j++)
1320 region = (int[]) regions.elementAt(j);
1321 hideStart = region[0];
1322 hideEnd = region[1];
1324 if (hideStart < start)
1329 blockStart = Math.min(blockStart, hideEnd + 1);
1330 blockEnd = Math.min(blockEnd, hideStart);
1332 if (blockStart > blockEnd)
1337 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1339 blockStart = hideEnd + 1;
1343 if (end > blockStart)
1345 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1348 selection[i] = visibleSeq.toString();
1352 selection[i] = seqs[i].getSequenceAsString(start, end);
1359 public boolean getShowHiddenMarkers()
1361 return showHiddenMarkers;
1364 public void setShowHiddenMarkers(boolean show)
1366 showHiddenMarkers = show;
1369 public Color getSequenceColour(SequenceI seq)
1371 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1377 return (Color) sequenceColours.get(seq);
1381 public void setSequenceColour(SequenceI seq, Color col)
1383 if (sequenceColours == null)
1385 sequenceColours = new Hashtable();
1390 sequenceColours.remove(seq);
1394 sequenceColours.put(seq, col);
1398 public String getSequenceSetId()
1400 if (sequenceSetID == null)
1402 sequenceSetID = alignment.hashCode() + "";
1405 return sequenceSetID;
1408 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1411 private String viewId = null;
1413 public String getViewId()
1417 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1422 public void alignmentChanged(AlignmentPanel ap)
1424 alignment.padGaps();
1426 if (hconsensus != null && autocalculateConsensus)
1428 updateConsensus(ap);
1429 updateConservation(ap);
1432 // Reset endRes of groups if beyond alignment width
1433 int alWidth = alignment.getWidth();
1434 Vector groups = alignment.getGroups();
1437 for (int i = 0; i < groups.size(); i++)
1439 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1440 if (sg.getEndRes() > alWidth)
1442 sg.setEndRes(alWidth - 1);
1447 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1449 selectionGroup.setEndRes(alWidth - 1);
1452 resetAllColourSchemes();
1454 // AW alignment.adjustSequenceAnnotations();
1457 void resetAllColourSchemes()
1459 ColourSchemeI cs = globalColourScheme;
1462 if (cs instanceof ClustalxColourScheme)
1464 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1465 alignment.getWidth());
1468 cs.setConsensus(hconsensus);
1469 if (cs.conservationApplied())
1471 Alignment al = (Alignment) alignment;
1472 Conservation c = new Conservation("All",
1473 ResidueProperties.propHash, 3, al.getSequences(), 0,
1476 c.verdict(false, ConsPercGaps);
1478 cs.setConservation(c);
1482 int s, sSize = alignment.getGroups().size();
1483 for (s = 0; s < sSize; s++)
1485 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1486 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1488 ((ClustalxColourScheme) sg.cs).resetClustalX(
1489 sg.getSequences(hiddenRepSequences), sg.getWidth());
1491 sg.recalcConservation();
1495 boolean centreColumnLabels;
1497 public boolean getCentreColumnLabels()
1499 return centreColumnLabels;
1502 public void updateSequenceIdColours()
1504 Vector groups = alignment.getGroups();
1505 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1507 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1508 if (sg.idColour != null)
1510 Vector sqs = sg.getSequences(hiddenRepSequences);
1511 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1513 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1519 public boolean followHighlight = false;
1521 public boolean getFollowHighlight()
1523 return followHighlight;
1526 public boolean followSelection = true;
1529 * @return true if view selection should always follow the selections
1530 * broadcast by other selection sources
1532 public boolean getFollowSelection()
1534 return followSelection;
1537 private long sgrouphash = -1, colselhash = -1;
1540 * checks current SelectionGroup against record of last hash value, and
1543 * @return true if SelectionGroup changed since last call
1545 boolean isSelectionGroupChanged()
1547 int hc = (selectionGroup == null) ? -1 : selectionGroup.hashCode();
1548 if (hc != sgrouphash)
1557 * checks current colsel against record of last hash value, and updates
1560 * @return true if colsel changed since last call
1562 boolean isColSelChanged()
1564 int hc = (colSel == null) ? -1 : colSel.hashCode();
1565 if (hc != colselhash)
1574 * show non-conserved residues only
1576 public boolean showUnconserved = false;
1579 * when set, alignment should be reordered according to a newly opened tree
1581 public boolean sortByTree = false;
1584 * @return the showUnconserved
1586 public boolean getShowunconserved()
1588 return showUnconserved;
1592 * @param showNonconserved
1593 * the showUnconserved to set
1595 public void setShowunconserved(boolean displayNonconserved)
1597 this.showUnconserved = displayNonconserved;
1601 * consensus annotation includes all percentage for all symbols in column
1602 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1
1605 private boolean includeAllConsensusSymbols = false;
1608 * should conservation rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1611 boolean showGroupConservation = false;
1614 * should consensus rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1617 boolean showGroupConsensus = false;
1620 * should consensus profile be rendered by default DISABLED FOR 2.5 RELEASE
1621 * (bug #60064 logo rendering is not AWT 1.1 compatible)
1623 public boolean showSequenceLogo = false;
1626 * should consensus histograms be rendered by default
1628 public boolean showConsensusHistogram = true;
1631 * @return the showConsensusProfile
1633 public boolean isShowSequenceLogo()
1635 return showSequenceLogo;
1639 * @param showSequenceLogo
1640 * the new value public void setShowSequenceLogo(boolean
1641 * showSequenceLogo) { this.showSequenceLogo = showSequenceLogo; }
1644 * @param showGroupConsensus
1645 * the showGroupConsensus to set
1647 public void setShowGroupConsensus(boolean showGroupConsensus)
1649 this.showGroupConsensus = showGroupConsensus;
1653 * @return the includeAllConsensusSymbols
1655 public boolean isIncludeAllConsensusSymbols()
1662 * @return flag to indicate if the consensus histogram should be rendered by
1665 public boolean isShowConsensusHistogram()
1667 return this.showConsensusHistogram;
1671 * synthesize a column selection if none exists so it covers the given
1672 * selection group. if wholewidth is false, no column selection is made if the
1673 * selection group covers the whole alignment width.
1678 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
1682 && (sgs = sg.getStartRes()) >= 0
1683 && sg.getStartRes() <= (sge = sg.getEndRes())
1684 && (colSel == null || colSel.getSelected() == null || colSel
1685 .getSelected().size() == 0))
1687 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
1694 colSel = new ColumnSelection();
1696 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
1698 colSel.addElement(cspos);
1702 public void sendSelection()
1704 jalview.structure.StructureSelectionManager
1705 .getStructureSelectionManager().sendSelection(
1706 new SequenceGroup(getSelectionGroup()),
1707 new ColumnSelection(getColumnSelection()), this);