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 public 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();
260 param = applet.getParameter("automaticScrolling");
262 followHighlight = Boolean.valueOf(param).booleanValue();
263 followSelection = followHighlight;
269 String colour = applet.getParameter("defaultColour");
273 colour = applet.getParameter("userDefinedColour");
276 colour = "User Defined";
282 globalColourScheme = ColourSchemeProperty.getColour(alignment,
284 if (globalColourScheme != null)
286 globalColourScheme.setConsensus(hconsensus);
290 if (applet.getParameter("userDefinedColour") != null)
292 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
293 .getParameter("userDefinedColour"));
296 if (hconsensus == null)
298 if (!alignment.isNucleotide())
300 conservation = new AlignmentAnnotation("Conservation",
301 "Conservation of total alignment less than " + ConsPercGaps
302 + "% gaps", new Annotation[1], 0f, 11f,
303 AlignmentAnnotation.BAR_GRAPH);
304 conservation.hasText = true;
305 conservation.autoCalculated = true;
307 if (showConservation)
309 alignment.addAnnotation(conservation);
314 quality = new AlignmentAnnotation("Quality",
315 "Alignment Quality based on Blosum62 scores",
316 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
317 quality.hasText = true;
318 quality.autoCalculated = true;
320 alignment.addAnnotation(quality);
324 consensus = new AlignmentAnnotation("Consensus", "PID",
325 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
326 consensus.hasText = true;
327 consensus.autoCalculated = true;
331 alignment.addAnnotation(consensus);
337 public void showSequenceFeatures(boolean b)
339 showSequenceFeatures = b;
342 public boolean getShowSequenceFeatures()
344 return showSequenceFeatures;
347 class ConservationThread extends Thread
351 public ConservationThread(AlignmentPanel ap)
360 updatingConservation = true;
362 while (UPDATING_CONSERVATION)
368 ap.paintAlignment(false);
371 } catch (Exception ex)
373 ex.printStackTrace();
377 UPDATING_CONSERVATION = true;
379 int alWidth = (alignment==null) ? -1 : alignment.getWidth();
382 updatingConservation = false;
383 UPDATING_CONSERVATION = false;
387 Conservation cons = new jalview.analysis.Conservation("All",
388 jalview.schemes.ResidueProperties.propHash, 3,
389 alignment.getSequences(), 0, alWidth - 1);
392 cons.verdict(false, ConsPercGaps);
399 char[] sequence = cons.getConsSequence().getSequence();
411 maxB = 0f - minB; // scalable range for colouring both Conservation and
421 conservation.annotations = new Annotation[alWidth];
425 quality.graphMax = cons.qualityRange[1].floatValue();
426 quality.annotations = new Annotation[alWidth];
427 qmin = cons.qualityRange[0].floatValue();
428 qmax = cons.qualityRange[1].floatValue();
431 for (int i = 0; i < alWidth; i++)
437 if (Character.isDigit(c))
439 value = (int) (c - '0');
449 // TODO - refactor to use a graduatedColorScheme to calculate the
451 float vprop = value - min;
453 conservation.annotations[i] = new Annotation(String.valueOf(c),
454 String.valueOf(value), ' ', value, new Color(minR
455 + (maxR * vprop), minG + (maxG * vprop), minB
461 value = ((Double) cons.quality.elementAt(i)).floatValue();
462 vprop = value - qmin;
464 quality.annotations[i] = new Annotation(" ",
465 String.valueOf(value), ' ', value, new Color(minR
466 + (maxR * vprop), minG + (maxG * vprop), minB
470 } catch (OutOfMemoryError error)
472 System.out.println("Out of memory calculating conservation!!");
478 UPDATING_CONSERVATION = false;
479 updatingConservation = false;
483 ap.paintAlignment(true);
489 ConservationThread conservationThread;
491 ConsensusThread consensusThread;
493 boolean consUpdateNeeded = false;
495 static boolean UPDATING_CONSENSUS = false;
497 static boolean UPDATING_CONSERVATION = false;
499 boolean updatingConsensus = false;
501 boolean updatingConservation = false;
506 public void updateConservation(final AlignmentPanel ap)
508 if (alignment.isNucleotide() || conservation == null)
513 conservationThread = new ConservationThread(ap);
514 conservationThread.start();
520 public void updateConsensus(final AlignmentPanel ap)
522 consensusThread = new ConsensusThread(ap);
523 consensusThread.start();
526 class ConsensusThread extends Thread
530 public ConsensusThread(AlignmentPanel ap)
537 updatingConsensus = true;
538 while (UPDATING_CONSENSUS)
544 ap.paintAlignment(false);
548 } catch (Exception ex)
550 ex.printStackTrace();
554 UPDATING_CONSENSUS = true;
558 int aWidth = alignment==null ? -1 : alignment.getWidth();
561 UPDATING_CONSENSUS = false;
562 updatingConsensus = false;
566 consensus.annotations = null;
567 consensus.annotations = new Annotation[aWidth];
569 hconsensus = new Hashtable[aWidth];
570 AAFrequency.calculate(alignment.getSequencesArray(), 0,
571 alignment.getWidth(), hconsensus, true); // always calculate the
573 AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
574 ignoreGapsInConsensusCalculation,
575 includeAllConsensusSymbols);
577 if (globalColourScheme != null)
579 globalColourScheme.setConsensus(hconsensus);
582 } catch (OutOfMemoryError error)
584 alignment.deleteAnnotation(consensus);
588 System.out.println("Out of memory calculating consensus!!");
591 UPDATING_CONSENSUS = false;
592 updatingConsensus = false;
596 ap.paintAlignment(true);
602 * get the consensus sequence as displayed under the PID consensus annotation
605 * @return consensus sequence as a new sequence object
607 public SequenceI getConsensusSeq()
609 if (consensus == null)
613 StringBuffer seqs = new StringBuffer();
614 for (int i = 0; i < consensus.annotations.length; i++)
616 if (consensus.annotations[i] != null)
618 if (consensus.annotations[i].description.charAt(0) == '[')
620 seqs.append(consensus.annotations[i].description.charAt(1));
624 seqs.append(consensus.annotations[i].displayCharacter);
628 SequenceI sq = new Sequence("Consensus", seqs.toString());
629 sq.setDescription("Percentage Identity Consensus "
630 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
634 public SequenceGroup getSelectionGroup()
636 return selectionGroup;
639 public void setSelectionGroup(SequenceGroup sg)
644 public boolean getConservationSelected()
646 return conservationColourSelected;
649 public void setConservationSelected(boolean b)
651 conservationColourSelected = b;
654 public boolean getAbovePIDThreshold()
656 return abovePIDThreshold;
659 public void setAbovePIDThreshold(boolean b)
661 abovePIDThreshold = b;
664 public int getStartRes()
669 public int getEndRes()
674 public int getStartSeq()
679 public void setGlobalColourScheme(ColourSchemeI cs)
681 globalColourScheme = cs;
684 public ColourSchemeI getGlobalColourScheme()
686 return globalColourScheme;
689 public void setStartRes(int res)
694 public void setStartSeq(int seq)
699 public void setEndRes(int res)
701 if (res > alignment.getWidth() - 1)
703 // log.System.out.println(" Corrected res from " + res + " to maximum " +
704 // (alignment.getWidth()-1));
705 res = alignment.getWidth() - 1;
714 public void setEndSeq(int seq)
716 if (seq > alignment.getHeight())
718 seq = alignment.getHeight();
727 public int getEndSeq()
732 java.awt.Frame nullFrame;
734 protected FeatureSettings featureSettings = null;
736 private float heightScale = 1, widthScale = 1;
738 public void setFont(Font f)
741 if (nullFrame == null)
743 nullFrame = new java.awt.Frame();
744 nullFrame.addNotify();
747 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
748 setCharHeight((int) (heightScale * fm.getHeight()));
749 charWidth = (int) (widthScale * fm.charWidth('M'));
753 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
754 fm = nullFrame.getGraphics().getFontMetrics(f2);
755 charWidth = (int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10));
759 public Font getFont()
764 public int getCharWidth()
769 public void setCharHeight(int h)
774 public int getCharHeight()
779 public void setWrappedWidth(int w)
781 this.wrappedWidth = w;
784 public int getwrappedWidth()
789 public AlignmentI getAlignment()
794 public void setAlignment(AlignmentI align)
796 this.alignment = align;
799 public void setWrapAlignment(boolean state)
801 wrapAlignment = state;
804 public void setShowText(boolean state)
809 public void setRenderGaps(boolean state)
814 public boolean getColourText()
816 return showColourText;
819 public void setColourText(boolean state)
821 showColourText = state;
824 public void setShowBoxes(boolean state)
829 public boolean getWrapAlignment()
831 return wrapAlignment;
834 public boolean getShowText()
839 public boolean getShowBoxes()
844 public char getGapCharacter()
846 return getAlignment().getGapCharacter();
849 public void setGapCharacter(char gap)
851 if (getAlignment() != null)
853 getAlignment().setGapCharacter(gap);
857 public void setThreshold(int thresh)
862 public int getThreshold()
867 public void setIncrement(int inc)
872 public int getIncrement()
877 public void setHiddenColumns(ColumnSelection colsel)
879 this.colSel = colsel;
880 if (colSel.getHiddenColumns() != null)
882 hasHiddenColumns = true;
886 public ColumnSelection getColumnSelection()
891 public void resetSeqLimits(int height)
893 setEndSeq(height / getCharHeight());
896 public void setCurrentTree(NJTree tree)
901 public NJTree getCurrentTree()
906 public void setColourAppliesToAllGroups(boolean b)
908 colourAppliesToAllGroups = b;
911 public boolean getColourAppliesToAllGroups()
913 return colourAppliesToAllGroups;
916 public boolean getShowJVSuffix()
921 public void setShowJVSuffix(boolean b)
926 public boolean getShowAnnotation()
928 return showAnnotation;
931 public void setShowAnnotation(boolean b)
936 public boolean getScaleAboveWrapped()
938 return scaleAboveWrapped;
941 public boolean getScaleLeftWrapped()
943 return scaleLeftWrapped;
946 public boolean getScaleRightWrapped()
948 return scaleRightWrapped;
951 public void setScaleAboveWrapped(boolean b)
953 scaleAboveWrapped = b;
956 public void setScaleLeftWrapped(boolean b)
958 scaleLeftWrapped = b;
961 public void setScaleRightWrapped(boolean b)
963 scaleRightWrapped = b;
966 public void setIgnoreGapsConsensus(boolean b)
968 ignoreGapsInConsensusCalculation = b;
969 updateConsensus(null);
970 if (globalColourScheme != null)
972 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
973 ignoreGapsInConsensusCalculation);
979 * Property change listener for changes in alignment
984 public void addPropertyChangeListener(
985 java.beans.PropertyChangeListener listener)
987 changeSupport.addPropertyChangeListener(listener);
996 public void removePropertyChangeListener(
997 java.beans.PropertyChangeListener listener)
999 changeSupport.removePropertyChangeListener(listener);
1003 * Property change listener for changes in alignment
1012 public void firePropertyChange(String prop, Object oldvalue,
1015 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1018 public boolean getIgnoreGapsConsensus()
1020 return ignoreGapsInConsensusCalculation;
1023 public void hideSelectedColumns()
1025 if (colSel.size() < 1)
1030 colSel.hideSelectedColumns();
1031 setSelectionGroup(null);
1033 hasHiddenColumns = true;
1036 public void invertColumnSelection()
1038 for (int i = 0; i < alignment.getWidth(); i++)
1040 if (colSel.contains(i))
1042 colSel.removeElement(i);
1046 if (!hasHiddenColumns || colSel.isVisible(i))
1048 colSel.addElement(i);
1054 public void hideColumns(int start, int end)
1058 colSel.hideColumns(start);
1062 colSel.hideColumns(start, end);
1065 hasHiddenColumns = true;
1068 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1070 int sSize = sg.getSize();
1076 if (hiddenRepSequences == null)
1078 hiddenRepSequences = new Hashtable();
1081 hiddenRepSequences.put(repSequence, sg);
1083 // Hide all sequences except the repSequence
1084 SequenceI[] seqs = new SequenceI[sSize - 1];
1086 for (int i = 0; i < sSize; i++)
1088 if (sg.getSequenceAt(i) != repSequence)
1090 if (index == sSize - 1)
1095 seqs[index++] = sg.getSequenceAt(i);
1103 public void hideAllSelectedSeqs()
1105 if (selectionGroup == null || selectionGroup.getSize() < 1)
1110 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1114 setSelectionGroup(null);
1117 public void hideSequence(SequenceI[] seq)
1121 for (int i = 0; i < seq.length; i++)
1123 alignment.getHiddenSequences().hideSequence(seq[i]);
1126 hasHiddenRows = true;
1127 firePropertyChange("alignment", null, alignment.getSequences());
1130 public void showSequence(int index)
1132 Vector tmp = alignment.getHiddenSequences().showSequence(index,
1133 hiddenRepSequences);
1136 if (selectionGroup == null)
1138 selectionGroup = new SequenceGroup();
1139 selectionGroup.setEndRes(alignment.getWidth() - 1);
1142 for (int t = 0; t < tmp.size(); t++)
1144 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1146 firePropertyChange("alignment", null, alignment.getSequences());
1150 if (alignment.getHiddenSequences().getSize() < 1)
1152 hasHiddenRows = false;
1155 public void showColumn(int col)
1157 colSel.revealHiddenColumns(col);
1158 if (colSel.getHiddenColumns() == null)
1160 hasHiddenColumns = false;
1164 public void showAllHiddenColumns()
1166 colSel.revealAllHiddenColumns();
1167 hasHiddenColumns = false;
1170 public void showAllHiddenSeqs()
1172 if (alignment.getHiddenSequences().getSize() > 0)
1174 if (selectionGroup == null)
1176 selectionGroup = new SequenceGroup();
1177 selectionGroup.setEndRes(alignment.getWidth() - 1);
1179 Vector tmp = alignment.getHiddenSequences().showAll(
1180 hiddenRepSequences);
1181 for (int t = 0; t < tmp.size(); t++)
1183 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1185 firePropertyChange("alignment", null, alignment.getSequences());
1186 hasHiddenRows = false;
1187 hiddenRepSequences = null;
1192 public int adjustForHiddenSeqs(int alignmentIndex)
1194 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1199 * This method returns the a new SequenceI [] with the selection sequence and
1200 * start and end points adjusted
1204 public SequenceI[] getSelectionAsNewSequence()
1206 SequenceI[] sequences;
1208 if (selectionGroup == null)
1210 sequences = alignment.getSequencesArray();
1214 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1221 * get the currently selected sequence objects or all the sequences in the
1224 * @return array of references to sequence objects
1226 public SequenceI[] getSequenceSelection()
1228 SequenceI[] sequences = null;
1229 if (selectionGroup != null)
1231 sequences = selectionGroup.getSequencesInOrder(alignment);
1233 if (sequences == null)
1235 sequences = alignment.getSequencesArray();
1241 * This method returns the visible alignment as text, as seen on the GUI, ie
1242 * if columns are hidden they will not be returned in the result. Use this for
1243 * calculating trees, PCA, redundancy etc on views which contain hidden
1248 public jalview.datamodel.CigarArray getViewAsCigars(
1249 boolean selectedRegionOnly)
1251 return new jalview.datamodel.CigarArray(alignment, (hasHiddenColumns ? colSel : null), (selectedRegionOnly ? selectionGroup : null));
1255 * return a compact representation of the current alignment selection to pass
1256 * to an analysis function
1258 * @param selectedOnly
1259 * boolean true to just return the selected view
1260 * @return AlignmentView
1262 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1264 return getAlignmentView(selectedOnly, false);
1268 * return a compact representation of the current alignment selection to pass
1269 * to an analysis function
1271 * @param selectedOnly
1272 * boolean true to just return the selected view
1274 * boolean true to annotate the alignment view with groups on the alignment (and intersecting with selected region if selectedOnly is true)
1275 * @return AlignmentView
1277 public jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups)
1279 return new AlignmentView(alignment, colSel, selectionGroup, hasHiddenColumns, selectedOnly, markGroups);
1282 * This method returns the visible alignment as text, as seen on the GUI, ie
1283 * if columns are hidden they will not be returned in the result. Use this for
1284 * calculating trees, PCA, redundancy etc on views which contain hidden
1289 public String[] getViewAsString(boolean selectedRegionOnly)
1291 String[] selection = null;
1292 SequenceI[] seqs = null;
1294 int start = 0, end = 0;
1295 if (selectedRegionOnly && selectionGroup != null)
1297 iSize = selectionGroup.getSize();
1298 seqs = selectionGroup.getSequencesInOrder(alignment);
1299 start = selectionGroup.getStartRes();
1300 end = selectionGroup.getEndRes() + 1;
1304 iSize = alignment.getHeight();
1305 seqs = alignment.getSequencesArray();
1306 end = alignment.getWidth();
1309 selection = new String[iSize];
1311 for (i = 0; i < iSize; i++)
1313 if (hasHiddenColumns)
1315 StringBuffer visibleSeq = new StringBuffer();
1316 Vector regions = colSel.getHiddenColumns();
1318 int blockStart = start, blockEnd = end;
1320 int hideStart, hideEnd;
1322 for (int j = 0; j < regions.size(); j++)
1324 region = (int[]) regions.elementAt(j);
1325 hideStart = region[0];
1326 hideEnd = region[1];
1328 if (hideStart < start)
1333 blockStart = Math.min(blockStart, hideEnd + 1);
1334 blockEnd = Math.min(blockEnd, hideStart);
1336 if (blockStart > blockEnd)
1341 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1343 blockStart = hideEnd + 1;
1347 if (end > blockStart)
1349 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1352 selection[i] = visibleSeq.toString();
1356 selection[i] = seqs[i].getSequenceAsString(start, end);
1363 public boolean getShowHiddenMarkers()
1365 return showHiddenMarkers;
1368 public void setShowHiddenMarkers(boolean show)
1370 showHiddenMarkers = show;
1373 public Color getSequenceColour(SequenceI seq)
1375 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1381 return (Color) sequenceColours.get(seq);
1385 public void setSequenceColour(SequenceI seq, Color col)
1387 if (sequenceColours == null)
1389 sequenceColours = new Hashtable();
1394 sequenceColours.remove(seq);
1398 sequenceColours.put(seq, col);
1402 public String getSequenceSetId()
1404 if (sequenceSetID == null)
1406 sequenceSetID = alignment.hashCode() + "";
1409 return sequenceSetID;
1412 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1415 private String viewId = null;
1417 public String getViewId()
1421 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1426 public void alignmentChanged(AlignmentPanel ap)
1428 alignment.padGaps();
1430 if (hconsensus != null && autocalculateConsensus)
1432 updateConsensus(ap);
1433 updateConservation(ap);
1436 // Reset endRes of groups if beyond alignment width
1437 int alWidth = alignment.getWidth();
1438 Vector groups = alignment.getGroups();
1441 for (int i = 0; i < groups.size(); i++)
1443 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1444 if (sg.getEndRes() > alWidth)
1446 sg.setEndRes(alWidth - 1);
1451 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1453 selectionGroup.setEndRes(alWidth - 1);
1456 resetAllColourSchemes();
1458 // AW alignment.adjustSequenceAnnotations();
1461 void resetAllColourSchemes()
1463 ColourSchemeI cs = globalColourScheme;
1466 if (cs instanceof ClustalxColourScheme)
1468 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1469 alignment.getWidth());
1472 cs.setConsensus(hconsensus);
1473 if (cs.conservationApplied())
1475 Alignment al = (Alignment) alignment;
1476 Conservation c = new Conservation("All",
1477 ResidueProperties.propHash, 3, al.getSequences(), 0,
1480 c.verdict(false, ConsPercGaps);
1482 cs.setConservation(c);
1486 int s, sSize = alignment.getGroups().size();
1487 for (s = 0; s < sSize; s++)
1489 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1490 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1492 ((ClustalxColourScheme) sg.cs).resetClustalX(
1493 sg.getSequences(hiddenRepSequences), sg.getWidth());
1495 sg.recalcConservation();
1499 boolean centreColumnLabels;
1501 public boolean getCentreColumnLabels()
1503 return centreColumnLabels;
1506 public void updateSequenceIdColours()
1508 Vector groups = alignment.getGroups();
1509 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1511 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1512 if (sg.idColour != null)
1514 Vector sqs = sg.getSequences(hiddenRepSequences);
1515 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1517 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1523 public boolean followHighlight = false;
1525 public boolean getFollowHighlight()
1527 return followHighlight;
1530 public boolean followSelection = true;
1533 * @return true if view selection should always follow the selections
1534 * broadcast by other selection sources
1536 public boolean getFollowSelection()
1538 return followSelection;
1541 private long sgrouphash = -1, colselhash = -1;
1544 * checks current SelectionGroup against record of last hash value, and
1547 * @return true if SelectionGroup changed since last call
1549 boolean isSelectionGroupChanged()
1551 int hc = (selectionGroup == null) ? -1 : selectionGroup.hashCode();
1552 if (hc != sgrouphash)
1561 * checks current colsel against record of last hash value, and updates
1564 * @return true if colsel changed since last call
1566 boolean isColSelChanged()
1568 int hc = (colSel == null) ? -1 : colSel.hashCode();
1569 if (hc != colselhash)
1578 * show non-conserved residues only
1580 public boolean showUnconserved = false;
1583 * when set, alignment should be reordered according to a newly opened tree
1585 public boolean sortByTree = false;
1588 * @return the showUnconserved
1590 public boolean getShowunconserved()
1592 return showUnconserved;
1596 * @param showNonconserved
1597 * the showUnconserved to set
1599 public void setShowunconserved(boolean displayNonconserved)
1601 this.showUnconserved = displayNonconserved;
1605 * consensus annotation includes all percentage for all symbols in column
1606 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1
1609 private boolean includeAllConsensusSymbols = false;
1612 * should conservation rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1615 boolean showGroupConservation = false;
1618 * should consensus rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1621 boolean showGroupConsensus = false;
1624 * should consensus profile be rendered by default DISABLED FOR 2.5 RELEASE
1625 * (bug #60064 logo rendering is not AWT 1.1 compatible)
1627 public boolean showSequenceLogo = false;
1630 * should consensus histograms be rendered by default
1632 public boolean showConsensusHistogram = true;
1635 * @return the showConsensusProfile
1637 public boolean isShowSequenceLogo()
1639 return showSequenceLogo;
1643 * @param showSequenceLogo
1644 * the new value public void setShowSequenceLogo(boolean
1645 * showSequenceLogo) { this.showSequenceLogo = showSequenceLogo; }
1648 * @param showGroupConsensus
1649 * the showGroupConsensus to set
1651 public void setShowGroupConsensus(boolean showGroupConsensus)
1653 this.showGroupConsensus = showGroupConsensus;
1657 * @return the includeAllConsensusSymbols
1659 public boolean isIncludeAllConsensusSymbols()
1666 * @return flag to indicate if the consensus histogram should be rendered by
1669 public boolean isShowConsensusHistogram()
1671 return this.showConsensusHistogram;
1675 * synthesize a column selection if none exists so it covers the given
1676 * selection group. if wholewidth is false, no column selection is made if the
1677 * selection group covers the whole alignment width.
1682 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
1686 && (sgs = sg.getStartRes()) >= 0
1687 && sg.getStartRes() <= (sge = sg.getEndRes())
1688 && (colSel == null || colSel.getSelected() == null || colSel
1689 .getSelected().size() == 0))
1691 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
1698 colSel = new ColumnSelection();
1700 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
1702 colSel.addElement(cspos);
1706 public void sendSelection()
1708 jalview.structure.StructureSelectionManager
1709 .getStructureSelectionManager().sendSelection(
1710 new SequenceGroup(getSelectionGroup()),
1711 new ColumnSelection(getColumnSelection()), this);