+ /**
+ * hides or shows dynamic annotation rows based on groups and av state flags
+ */
+ public void updateAnnotation()
+ {
+ updateAnnotation(false);
+ }
+
+ public void updateAnnotation(boolean applyGlobalSettings)
+ {
+ // TODO: this should be merged with other annotation update stuff - that
+ // sits on AlignViewport
+ boolean updateCalcs = false;
+ boolean conv = av.isShowGroupConservation();
+ boolean cons = av.isShowGroupConsensus();
+ boolean showprf = av.isShowSequenceLogo();
+ boolean showConsHist = av.isShowConsensusHistogram();
+
+ boolean sortg = true;
+
+ // remove old automatic annotation
+ // add any new annotation
+
+ Vector gr = av.alignment.getGroups(); // OrderedBy(av.alignment.getSequencesArray());
+ // intersect alignment annotation with alignment groups
+
+ AlignmentAnnotation[] aan = av.alignment.getAlignmentAnnotation();
+ Hashtable oldrfs = new Hashtable();
+ if (aan != null)
+ {
+ for (int an = 0; an < aan.length; an++)
+ {
+ if (aan[an].autoCalculated && aan[an].groupRef != null)
+ {
+ oldrfs.put(aan[an].groupRef, aan[an].groupRef);
+ av.alignment.deleteAnnotation(aan[an]);
+ aan[an] = null;
+ }
+ }
+ }
+ SequenceGroup sg;
+ if (gr != null)
+ {
+ for (int g = 0; g < gr.size(); g++)
+ {
+ updateCalcs = false;
+ sg = (SequenceGroup) gr.elementAt(g);
+ if (applyGlobalSettings || !oldrfs.containsKey(sg))
+ {
+ // set defaults for this group's conservation/consensus
+ sg.setshowSequenceLogo(showprf);
+ sg.setShowConsensusHistogram(showConsHist);
+ }
+ if (conv)
+ {
+ updateCalcs = true;
+ av.alignment.addAnnotation(sg.getConservationRow(), 0);
+ }
+ if (cons)
+ {
+ updateCalcs = true;
+ av.alignment.addAnnotation(sg.getConsensus(), 0);
+ }
+ // refresh the annotation rows
+ if (updateCalcs)
+ {
+ sg.recalcConservation();
+ }
+ }
+ }
+ oldrfs.clear();
+ adjustAnnotationHeight();
+ }
+
+ /**
+ * automatically adjust annotation panel height for new annotation whilst
+ * ensuring the alignment is still visible.
+ */
+ public void adjustAnnotationHeight()
+ {
+ // TODO: display vertical annotation scrollbar if necessary
+ // this is called after loading new annotation onto alignment
+ if (alignFrame.getSize().height == 0)
+ {
+ System.out.println("NEEDS FIXING");
+ }
+ fontChanged();
+ validateAnnotationDimensions(true);
+ apvscroll.addNotify();
+ hscroll.addNotify();
+ validate();
+ addNotify();
+ repaint();
+ }
+ /**
+ * calculate the annotation dimensions and refresh slider values accordingly.
+ * need to do repaints/notifys afterwards.
+ */
+ protected void validateAnnotationDimensions(boolean adjustPanelHeight) {
+ int height = annotationPanel.calcPanelHeight();
+ if (hscroll.isVisible())
+ {
+ height += hscroll.getPreferredSize().height;
+ }
+ int mheight = height;
+ // sets initial preferred height
+ if ((height+40) > getSize().height / 2)
+ {
+ height = getSize().height / 2;
+ }
+ if (!adjustPanelHeight)
+ {
+ // maintain same window layout whilst updating sliders
+ height=seqPanelHolder.getSize().height;
+ }
+ Dimension d=seqPanelHolder.getSize(),e=idPanel.getSize();
+ annotationPanel.setSize(new Dimension(d.width,height));
+ alabels.setSize(e.width,height);
+ annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
+ annotationPanelHolder.setSize(new Dimension(d.width, height));
+ seqPanelHolder.setSize(d.width,d.height-height);
+ int s=apvscroll.getValue();
+ if (s>mheight-height)
+ {
+ s = 0;
+ }
+ apvscroll.setValues(apvscroll.getValue(), height, 0, mheight);
+ annotationPanel.setScrollOffset(apvscroll.getValue());
+ alabels.setScrollOffset(apvscroll.getValue());
+ }
+
+ @Override
+ public AlignmentI getAlignment()
+ {
+ return av.alignment;
+ }
+