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;
29 import jalview.structure.VamsasSource;
31 public class AlignViewport implements SelectionSource, VamsasSource
41 boolean cursorMode = false;
43 boolean showJVSuffix = true;
45 boolean showText = true;
47 boolean showColourText = false;
49 boolean showBoxes = true;
51 boolean wrapAlignment = false;
53 boolean renderGaps = true;
55 boolean showSequenceFeatures = false;
57 boolean showAnnotation = true;
59 boolean showConservation = true;
61 boolean showQuality = true;
63 boolean showConsensus = true;
65 boolean upperCasebold = false;
67 boolean colourAppliesToAllGroups = true;
69 ColourSchemeI globalColourScheme = null;
71 boolean conservationColourSelected = false;
73 boolean abovePIDThreshold = false;
75 SequenceGroup selectionGroup;
83 Font font = new Font("SansSerif", Font.PLAIN, 10);
85 boolean validCharWidth = true;
89 ColumnSelection colSel = new ColumnSelection();
95 NJTree currentTree = null;
97 boolean scaleAboveWrapped = true;
99 boolean scaleLeftWrapped = true;
101 boolean scaleRightWrapped = true;
103 // The following vector holds the features which are
104 // currently visible, in the correct order or rendering
105 public Hashtable featuresDisplayed;
107 boolean hasHiddenColumns = false;
109 boolean hasHiddenRows = false;
111 boolean showHiddenMarkers = true;
113 public Hashtable[] hconsensus;
115 AlignmentAnnotation consensus;
117 AlignmentAnnotation conservation;
119 AlignmentAnnotation quality;
121 AlignmentAnnotation[] groupConsensus;
123 AlignmentAnnotation[] groupConservation;
125 boolean autocalculateConsensus = true;
127 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
129 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
132 boolean ignoreGapsInConsensusCalculation = false;
134 public jalview.bin.JalviewLite applet;
136 Hashtable sequenceColours;
140 Stack historyList = new Stack();
142 Stack redoList = new Stack();
144 String sequenceSetID;
146 Hashtable hiddenRepSequences;
148 public AlignViewport(AlignmentI al, JalviewLite applet)
150 this.applet = applet;
153 this.endRes = al.getWidth() - 1;
155 this.endSeq = al.getHeight() - 1;
158 // get the width and height scaling factors if they were specified
159 String param = applet.getParameter("widthScale");
164 widthScale = new Float(param).floatValue();
165 } catch (Exception e)
168 if (widthScale <= 1.0)
171 .println("Invalid alignment character width scaling factor ("
172 + widthScale + "). Ignoring.");
178 .println("Alignment character width scaling factor is now "
182 param = applet.getParameter("heightScale");
187 heightScale = new Float(param).floatValue();
188 } catch (Exception e)
191 if (heightScale <= 1.0)
194 .println("Invalid alignment character height scaling factor ("
195 + heightScale + "). Ignoring.");
201 .println("Alignment character height scaling factor is now "
208 MAC = new jalview.util.Platform().isAMac();
212 String param = applet.getParameter("showFullId");
215 showJVSuffix = Boolean.valueOf(param).booleanValue();
218 param = applet.getParameter("showAnnotation");
221 showAnnotation = Boolean.valueOf(param).booleanValue();
224 param = applet.getParameter("showConservation");
227 showConservation = Boolean.valueOf(param).booleanValue();
230 param = applet.getParameter("showQuality");
233 showQuality = Boolean.valueOf(param).booleanValue();
236 param = applet.getParameter("showConsensus");
239 showConsensus = Boolean.valueOf(param).booleanValue();
242 param = applet.getParameter("showUnconserved");
245 this.showUnconserved = Boolean.valueOf(param).booleanValue();
248 param = applet.getParameter("upperCase");
251 if (param.equalsIgnoreCase("bold"))
253 upperCasebold = true;
256 param = applet.getParameter("sortByTree");
259 sortByTree = Boolean.valueOf(param).booleanValue();
261 param = applet.getParameter("automaticScrolling");
263 followHighlight = Boolean.valueOf(param).booleanValue();
264 followSelection = followHighlight;
270 String colour = applet.getParameter("defaultColour");
274 colour = applet.getParameter("userDefinedColour");
277 colour = "User Defined";
283 globalColourScheme = ColourSchemeProperty.getColour(alignment,
285 if (globalColourScheme != null)
287 globalColourScheme.setConsensus(hconsensus);
291 if (applet.getParameter("userDefinedColour") != null)
293 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
294 .getParameter("userDefinedColour"));
297 if (hconsensus == null)
299 if (!alignment.isNucleotide())
301 conservation = new AlignmentAnnotation("Conservation",
302 "Conservation of total alignment less than " + ConsPercGaps
303 + "% gaps", new Annotation[1], 0f, 11f,
304 AlignmentAnnotation.BAR_GRAPH);
305 conservation.hasText = true;
306 conservation.autoCalculated = true;
308 if (showConservation)
310 alignment.addAnnotation(conservation);
315 quality = new AlignmentAnnotation("Quality",
316 "Alignment Quality based on Blosum62 scores",
317 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
318 quality.hasText = true;
319 quality.autoCalculated = true;
321 alignment.addAnnotation(quality);
325 consensus = new AlignmentAnnotation("Consensus", "PID",
326 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
327 consensus.hasText = true;
328 consensus.autoCalculated = true;
332 alignment.addAnnotation(consensus);
338 public void showSequenceFeatures(boolean b)
340 showSequenceFeatures = b;
343 public boolean getShowSequenceFeatures()
345 return showSequenceFeatures;
348 class ConservationThread extends Thread
352 public ConservationThread(AlignmentPanel ap)
361 updatingConservation = true;
363 while (UPDATING_CONSERVATION)
369 ap.paintAlignment(false);
372 } catch (Exception ex)
374 ex.printStackTrace();
378 UPDATING_CONSERVATION = true;
380 int alWidth = (alignment==null) ? -1 : alignment.getWidth();
383 updatingConservation = false;
384 UPDATING_CONSERVATION = false;
388 Conservation cons = new jalview.analysis.Conservation("All",
389 jalview.schemes.ResidueProperties.propHash, 3,
390 alignment.getSequences(), 0, alWidth - 1);
393 cons.verdict(false, ConsPercGaps);
400 char[] sequence = cons.getConsSequence().getSequence();
412 maxB = 0f - minB; // scalable range for colouring both Conservation and
422 conservation.annotations = new Annotation[alWidth];
426 quality.graphMax = cons.qualityRange[1].floatValue();
427 quality.annotations = new Annotation[alWidth];
428 qmin = cons.qualityRange[0].floatValue();
429 qmax = cons.qualityRange[1].floatValue();
432 for (int i = 0; i < alWidth; i++)
438 if (Character.isDigit(c))
440 value = (int) (c - '0');
450 // TODO - refactor to use a graduatedColorScheme to calculate the
452 float vprop = value - min;
454 conservation.annotations[i] = new Annotation(String.valueOf(c),
455 String.valueOf(value), ' ', value, new Color(minR
456 + (maxR * vprop), minG + (maxG * vprop), minB
462 value = ((Double) cons.quality.elementAt(i)).floatValue();
463 vprop = value - qmin;
465 quality.annotations[i] = new Annotation(" ",
466 String.valueOf(value), ' ', value, new Color(minR
467 + (maxR * vprop), minG + (maxG * vprop), minB
471 } catch (OutOfMemoryError error)
473 System.out.println("Out of memory calculating conservation!!");
479 UPDATING_CONSERVATION = false;
480 updatingConservation = false;
484 ap.paintAlignment(true);
490 ConservationThread conservationThread;
492 ConsensusThread consensusThread;
494 boolean consUpdateNeeded = false;
496 static boolean UPDATING_CONSENSUS = false;
498 static boolean UPDATING_CONSERVATION = false;
500 boolean updatingConsensus = false;
502 boolean updatingConservation = false;
507 public void updateConservation(final AlignmentPanel ap)
509 if (alignment.isNucleotide() || conservation == null)
514 conservationThread = new ConservationThread(ap);
515 conservationThread.start();
521 public void updateConsensus(final AlignmentPanel ap)
523 consensusThread = new ConsensusThread(ap);
524 consensusThread.start();
527 class ConsensusThread extends Thread
531 public ConsensusThread(AlignmentPanel ap)
538 updatingConsensus = true;
539 while (UPDATING_CONSENSUS)
545 ap.paintAlignment(false);
549 } catch (Exception ex)
551 ex.printStackTrace();
555 UPDATING_CONSENSUS = true;
559 int aWidth = alignment==null ? -1 : alignment.getWidth();
562 UPDATING_CONSENSUS = false;
563 updatingConsensus = false;
567 consensus.annotations = null;
568 consensus.annotations = new Annotation[aWidth];
570 hconsensus = new Hashtable[aWidth];
571 AAFrequency.calculate(alignment.getSequencesArray(), 0,
572 alignment.getWidth(), hconsensus, true); // always calculate the
574 AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
575 ignoreGapsInConsensusCalculation,
576 includeAllConsensusSymbols);
578 if (globalColourScheme != null)
580 globalColourScheme.setConsensus(hconsensus);
583 } catch (OutOfMemoryError error)
585 alignment.deleteAnnotation(consensus);
589 System.out.println("Out of memory calculating consensus!!");
592 UPDATING_CONSENSUS = false;
593 updatingConsensus = false;
597 ap.paintAlignment(true);
603 * get the consensus sequence as displayed under the PID consensus annotation
606 * @return consensus sequence as a new sequence object
608 public SequenceI getConsensusSeq()
610 if (consensus == null)
614 StringBuffer seqs = new StringBuffer();
615 for (int i = 0; i < consensus.annotations.length; i++)
617 if (consensus.annotations[i] != null)
619 if (consensus.annotations[i].description.charAt(0) == '[')
621 seqs.append(consensus.annotations[i].description.charAt(1));
625 seqs.append(consensus.annotations[i].displayCharacter);
629 SequenceI sq = new Sequence("Consensus", seqs.toString());
630 sq.setDescription("Percentage Identity Consensus "
631 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
635 public SequenceGroup getSelectionGroup()
637 return selectionGroup;
640 public void setSelectionGroup(SequenceGroup sg)
645 public boolean getConservationSelected()
647 return conservationColourSelected;
650 public void setConservationSelected(boolean b)
652 conservationColourSelected = b;
655 public boolean getAbovePIDThreshold()
657 return abovePIDThreshold;
660 public void setAbovePIDThreshold(boolean b)
662 abovePIDThreshold = b;
665 public int getStartRes()
670 public int getEndRes()
675 public int getStartSeq()
680 public void setGlobalColourScheme(ColourSchemeI cs)
682 globalColourScheme = cs;
685 public ColourSchemeI getGlobalColourScheme()
687 return globalColourScheme;
690 public void setStartRes(int res)
695 public void setStartSeq(int seq)
700 public void setEndRes(int res)
702 if (res > alignment.getWidth() - 1)
704 // log.System.out.println(" Corrected res from " + res + " to maximum " +
705 // (alignment.getWidth()-1));
706 res = alignment.getWidth() - 1;
715 public void setEndSeq(int seq)
717 if (seq > alignment.getHeight())
719 seq = alignment.getHeight();
728 public int getEndSeq()
733 java.awt.Frame nullFrame;
735 protected FeatureSettings featureSettings = null;
737 private float heightScale = 1, widthScale = 1;
739 public void setFont(Font f)
742 if (nullFrame == null)
744 nullFrame = new java.awt.Frame();
745 nullFrame.addNotify();
748 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
749 setCharHeight((int) (heightScale * fm.getHeight()));
750 charWidth = (int) (widthScale * fm.charWidth('M'));
754 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
755 fm = nullFrame.getGraphics().getFontMetrics(f2);
756 charWidth = (int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10));
760 public Font getFont()
765 public int getCharWidth()
770 public void setCharHeight(int h)
775 public int getCharHeight()
780 public void setWrappedWidth(int w)
782 this.wrappedWidth = w;
785 public int getwrappedWidth()
790 public AlignmentI getAlignment()
795 public void setAlignment(AlignmentI align)
797 this.alignment = align;
800 public void setWrapAlignment(boolean state)
802 wrapAlignment = state;
805 public void setShowText(boolean state)
810 public void setRenderGaps(boolean state)
815 public boolean getColourText()
817 return showColourText;
820 public void setColourText(boolean state)
822 showColourText = state;
825 public void setShowBoxes(boolean state)
830 public boolean getWrapAlignment()
832 return wrapAlignment;
835 public boolean getShowText()
840 public boolean getShowBoxes()
845 public char getGapCharacter()
847 return getAlignment().getGapCharacter();
850 public void setGapCharacter(char gap)
852 if (getAlignment() != null)
854 getAlignment().setGapCharacter(gap);
858 public void setThreshold(int thresh)
863 public int getThreshold()
868 public void setIncrement(int inc)
873 public int getIncrement()
878 public void setHiddenColumns(ColumnSelection colsel)
880 this.colSel = colsel;
881 if (colSel.getHiddenColumns() != null)
883 hasHiddenColumns = true;
887 public ColumnSelection getColumnSelection()
892 public void resetSeqLimits(int height)
894 setEndSeq(height / getCharHeight());
897 public void setCurrentTree(NJTree tree)
902 public NJTree getCurrentTree()
907 public void setColourAppliesToAllGroups(boolean b)
909 colourAppliesToAllGroups = b;
912 public boolean getColourAppliesToAllGroups()
914 return colourAppliesToAllGroups;
917 public boolean getShowJVSuffix()
922 public void setShowJVSuffix(boolean b)
927 public boolean getShowAnnotation()
929 return showAnnotation;
932 public void setShowAnnotation(boolean b)
937 public boolean getScaleAboveWrapped()
939 return scaleAboveWrapped;
942 public boolean getScaleLeftWrapped()
944 return scaleLeftWrapped;
947 public boolean getScaleRightWrapped()
949 return scaleRightWrapped;
952 public void setScaleAboveWrapped(boolean b)
954 scaleAboveWrapped = b;
957 public void setScaleLeftWrapped(boolean b)
959 scaleLeftWrapped = b;
962 public void setScaleRightWrapped(boolean b)
964 scaleRightWrapped = b;
967 public void setIgnoreGapsConsensus(boolean b)
969 ignoreGapsInConsensusCalculation = b;
970 updateConsensus(null);
971 if (globalColourScheme != null)
973 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
974 ignoreGapsInConsensusCalculation);
980 * Property change listener for changes in alignment
985 public void addPropertyChangeListener(
986 java.beans.PropertyChangeListener listener)
988 changeSupport.addPropertyChangeListener(listener);
997 public void removePropertyChangeListener(
998 java.beans.PropertyChangeListener listener)
1000 changeSupport.removePropertyChangeListener(listener);
1004 * Property change listener for changes in alignment
1013 public void firePropertyChange(String prop, Object oldvalue,
1016 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1019 public boolean getIgnoreGapsConsensus()
1021 return ignoreGapsInConsensusCalculation;
1024 public void hideSelectedColumns()
1026 if (colSel.size() < 1)
1031 colSel.hideSelectedColumns();
1032 setSelectionGroup(null);
1034 hasHiddenColumns = true;
1037 public void invertColumnSelection()
1039 for (int i = 0; i < alignment.getWidth(); i++)
1041 if (colSel.contains(i))
1043 colSel.removeElement(i);
1047 if (!hasHiddenColumns || colSel.isVisible(i))
1049 colSel.addElement(i);
1055 public void hideColumns(int start, int end)
1059 colSel.hideColumns(start);
1063 colSel.hideColumns(start, end);
1066 hasHiddenColumns = true;
1069 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1071 int sSize = sg.getSize();
1077 if (hiddenRepSequences == null)
1079 hiddenRepSequences = new Hashtable();
1082 hiddenRepSequences.put(repSequence, sg);
1084 // Hide all sequences except the repSequence
1085 SequenceI[] seqs = new SequenceI[sSize - 1];
1087 for (int i = 0; i < sSize; i++)
1089 if (sg.getSequenceAt(i) != repSequence)
1091 if (index == sSize - 1)
1096 seqs[index++] = sg.getSequenceAt(i);
1104 public void hideAllSelectedSeqs()
1106 if (selectionGroup == null || selectionGroup.getSize() < 1)
1111 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1115 setSelectionGroup(null);
1118 public void hideSequence(SequenceI[] seq)
1122 for (int i = 0; i < seq.length; i++)
1124 alignment.getHiddenSequences().hideSequence(seq[i]);
1127 hasHiddenRows = true;
1128 firePropertyChange("alignment", null, alignment.getSequences());
1131 public void showSequence(int index)
1133 Vector tmp = alignment.getHiddenSequences().showSequence(index,
1134 hiddenRepSequences);
1137 if (selectionGroup == null)
1139 selectionGroup = new SequenceGroup();
1140 selectionGroup.setEndRes(alignment.getWidth() - 1);
1143 for (int t = 0; t < tmp.size(); t++)
1145 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1147 firePropertyChange("alignment", null, alignment.getSequences());
1151 if (alignment.getHiddenSequences().getSize() < 1)
1153 hasHiddenRows = false;
1156 public void showColumn(int col)
1158 colSel.revealHiddenColumns(col);
1159 if (colSel.getHiddenColumns() == null)
1161 hasHiddenColumns = false;
1165 public void showAllHiddenColumns()
1167 colSel.revealAllHiddenColumns();
1168 hasHiddenColumns = false;
1171 public void showAllHiddenSeqs()
1173 if (alignment.getHiddenSequences().getSize() > 0)
1175 if (selectionGroup == null)
1177 selectionGroup = new SequenceGroup();
1178 selectionGroup.setEndRes(alignment.getWidth() - 1);
1180 Vector tmp = alignment.getHiddenSequences().showAll(
1181 hiddenRepSequences);
1182 for (int t = 0; t < tmp.size(); t++)
1184 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1186 firePropertyChange("alignment", null, alignment.getSequences());
1187 hasHiddenRows = false;
1188 hiddenRepSequences = null;
1193 public int adjustForHiddenSeqs(int alignmentIndex)
1195 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1200 * This method returns the a new SequenceI [] with the selection sequence and
1201 * start and end points adjusted
1205 public SequenceI[] getSelectionAsNewSequence()
1207 SequenceI[] sequences;
1209 if (selectionGroup == null)
1211 sequences = alignment.getSequencesArray();
1215 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1222 * get the currently selected sequence objects or all the sequences in the
1225 * @return array of references to sequence objects
1227 public SequenceI[] getSequenceSelection()
1229 SequenceI[] sequences = null;
1230 if (selectionGroup != null)
1232 sequences = selectionGroup.getSequencesInOrder(alignment);
1234 if (sequences == null)
1236 sequences = alignment.getSequencesArray();
1242 * This method returns the visible alignment as text, as seen on the GUI, ie
1243 * if columns are hidden they will not be returned in the result. Use this for
1244 * calculating trees, PCA, redundancy etc on views which contain hidden
1249 public jalview.datamodel.CigarArray getViewAsCigars(
1250 boolean selectedRegionOnly)
1252 return new jalview.datamodel.CigarArray(alignment, (hasHiddenColumns ? colSel : null), (selectedRegionOnly ? selectionGroup : null));
1256 * return a compact representation of the current alignment selection to pass
1257 * to an analysis function
1259 * @param selectedOnly
1260 * boolean true to just return the selected view
1261 * @return AlignmentView
1263 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1265 return getAlignmentView(selectedOnly, false);
1269 * return a compact representation of the current alignment selection to pass
1270 * to an analysis function
1272 * @param selectedOnly
1273 * boolean true to just return the selected view
1275 * boolean true to annotate the alignment view with groups on the alignment (and intersecting with selected region if selectedOnly is true)
1276 * @return AlignmentView
1278 public jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups)
1280 return new AlignmentView(alignment, colSel, selectionGroup, hasHiddenColumns, selectedOnly, markGroups);
1283 * This method returns the visible alignment as text, as seen on the GUI, ie
1284 * if columns are hidden they will not be returned in the result. Use this for
1285 * calculating trees, PCA, redundancy etc on views which contain hidden
1290 public String[] getViewAsString(boolean selectedRegionOnly)
1292 String[] selection = null;
1293 SequenceI[] seqs = null;
1295 int start = 0, end = 0;
1296 if (selectedRegionOnly && selectionGroup != null)
1298 iSize = selectionGroup.getSize();
1299 seqs = selectionGroup.getSequencesInOrder(alignment);
1300 start = selectionGroup.getStartRes();
1301 end = selectionGroup.getEndRes() + 1;
1305 iSize = alignment.getHeight();
1306 seqs = alignment.getSequencesArray();
1307 end = alignment.getWidth();
1310 selection = new String[iSize];
1312 for (i = 0; i < iSize; i++)
1314 if (hasHiddenColumns)
1316 StringBuffer visibleSeq = new StringBuffer();
1317 Vector regions = colSel.getHiddenColumns();
1319 int blockStart = start, blockEnd = end;
1321 int hideStart, hideEnd;
1323 for (int j = 0; j < regions.size(); j++)
1325 region = (int[]) regions.elementAt(j);
1326 hideStart = region[0];
1327 hideEnd = region[1];
1329 if (hideStart < start)
1334 blockStart = Math.min(blockStart, hideEnd + 1);
1335 blockEnd = Math.min(blockEnd, hideStart);
1337 if (blockStart > blockEnd)
1342 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1344 blockStart = hideEnd + 1;
1348 if (end > blockStart)
1350 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1353 selection[i] = visibleSeq.toString();
1357 selection[i] = seqs[i].getSequenceAsString(start, end);
1364 public boolean getShowHiddenMarkers()
1366 return showHiddenMarkers;
1369 public void setShowHiddenMarkers(boolean show)
1371 showHiddenMarkers = show;
1374 public Color getSequenceColour(SequenceI seq)
1376 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1382 return (Color) sequenceColours.get(seq);
1386 public void setSequenceColour(SequenceI seq, Color col)
1388 if (sequenceColours == null)
1390 sequenceColours = new Hashtable();
1395 sequenceColours.remove(seq);
1399 sequenceColours.put(seq, col);
1403 public String getSequenceSetId()
1405 if (sequenceSetID == null)
1407 sequenceSetID = alignment.hashCode() + "";
1410 return sequenceSetID;
1413 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1416 private String viewId = null;
1418 public String getViewId()
1422 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1427 public void alignmentChanged(AlignmentPanel ap)
1429 alignment.padGaps();
1431 if (hconsensus != null && autocalculateConsensus)
1433 updateConsensus(ap);
1434 updateConservation(ap);
1437 // Reset endRes of groups if beyond alignment width
1438 int alWidth = alignment.getWidth();
1439 Vector groups = alignment.getGroups();
1442 for (int i = 0; i < groups.size(); i++)
1444 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1445 if (sg.getEndRes() > alWidth)
1447 sg.setEndRes(alWidth - 1);
1452 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1454 selectionGroup.setEndRes(alWidth - 1);
1457 resetAllColourSchemes();
1459 // AW alignment.adjustSequenceAnnotations();
1462 void resetAllColourSchemes()
1464 ColourSchemeI cs = globalColourScheme;
1467 if (cs instanceof ClustalxColourScheme)
1469 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1470 alignment.getWidth());
1473 cs.setConsensus(hconsensus);
1474 if (cs.conservationApplied())
1476 Alignment al = (Alignment) alignment;
1477 Conservation c = new Conservation("All",
1478 ResidueProperties.propHash, 3, al.getSequences(), 0,
1481 c.verdict(false, ConsPercGaps);
1483 cs.setConservation(c);
1487 int s, sSize = alignment.getGroups().size();
1488 for (s = 0; s < sSize; s++)
1490 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1491 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1493 ((ClustalxColourScheme) sg.cs).resetClustalX(
1494 sg.getSequences(hiddenRepSequences), sg.getWidth());
1496 sg.recalcConservation();
1500 boolean centreColumnLabels;
1502 public boolean getCentreColumnLabels()
1504 return centreColumnLabels;
1507 public void updateSequenceIdColours()
1509 Vector groups = alignment.getGroups();
1510 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1512 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1513 if (sg.idColour != null)
1515 Vector sqs = sg.getSequences(hiddenRepSequences);
1516 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1518 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1524 public boolean followHighlight = false;
1526 public boolean getFollowHighlight()
1528 return followHighlight;
1531 public boolean followSelection = true;
1534 * @return true if view selection should always follow the selections
1535 * broadcast by other selection sources
1537 public boolean getFollowSelection()
1539 return followSelection;
1542 private long sgrouphash = -1, colselhash = -1;
1545 * checks current SelectionGroup against record of last hash value, and
1548 * @return true if SelectionGroup changed since last call
1550 boolean isSelectionGroupChanged()
1552 int hc = (selectionGroup == null) ? -1 : selectionGroup.hashCode();
1553 if (hc != sgrouphash)
1562 * checks current colsel against record of last hash value, and updates
1565 * @return true if colsel changed since last call
1567 boolean isColSelChanged()
1569 int hc = (colSel == null) ? -1 : colSel.hashCode();
1570 if (hc != colselhash)
1579 * show non-conserved residues only
1581 public boolean showUnconserved = false;
1584 * when set, alignment should be reordered according to a newly opened tree
1586 public boolean sortByTree = false;
1589 * @return the showUnconserved
1591 public boolean getShowunconserved()
1593 return showUnconserved;
1597 * @param showNonconserved
1598 * the showUnconserved to set
1600 public void setShowunconserved(boolean displayNonconserved)
1602 this.showUnconserved = displayNonconserved;
1606 * consensus annotation includes all percentage for all symbols in column
1607 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1
1610 private boolean includeAllConsensusSymbols = false;
1613 * should conservation rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1616 boolean showGroupConservation = false;
1619 * should consensus rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1622 boolean showGroupConsensus = false;
1625 * should consensus profile be rendered by default DISABLED FOR 2.5 RELEASE
1626 * (bug #60064 logo rendering is not AWT 1.1 compatible)
1628 public boolean showSequenceLogo = false;
1631 * should consensus histograms be rendered by default
1633 public boolean showConsensusHistogram = true;
1636 * @return the showConsensusProfile
1638 public boolean isShowSequenceLogo()
1640 return showSequenceLogo;
1644 * @param showSequenceLogo
1645 * the new value public void setShowSequenceLogo(boolean
1646 * showSequenceLogo) { this.showSequenceLogo = showSequenceLogo; }
1649 * @param showGroupConsensus
1650 * the showGroupConsensus to set
1652 public void setShowGroupConsensus(boolean showGroupConsensus)
1654 this.showGroupConsensus = showGroupConsensus;
1658 * @return the includeAllConsensusSymbols
1660 public boolean isIncludeAllConsensusSymbols()
1667 * @return flag to indicate if the consensus histogram should be rendered by
1670 public boolean isShowConsensusHistogram()
1672 return this.showConsensusHistogram;
1676 * synthesize a column selection if none exists so it covers the given
1677 * selection group. if wholewidth is false, no column selection is made if the
1678 * selection group covers the whole alignment width.
1683 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
1687 && (sgs = sg.getStartRes()) >= 0
1688 && sg.getStartRes() <= (sge = sg.getEndRes())
1689 && (colSel == null || colSel.getSelected() == null || colSel
1690 .getSelected().size() == 0))
1692 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
1699 colSel = new ColumnSelection();
1701 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
1703 colSel.addElement(cspos);
1707 public void sendSelection()
1709 jalview.structure.StructureSelectionManager
1710 .getStructureSelectionManager().sendSelection(
1711 new SequenceGroup(getSelectionGroup()),
1712 new ColumnSelection(getColumnSelection()), this);