+ /**
+ * 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();
+ paintAlignment(true);
+ }
+
+ /**
+ * calculate the annotation dimensions and refresh slider values accordingly.
+ * need to do repaints/notifys afterwards.
+ */
+ protected void validateAnnotationDimensions(boolean adjustPanelHeight)
+ {
+ boolean modified = false;
+ int height = av.calcPanelHeight();
+ int minsize = 0;
+ if (hscroll.isVisible())
+ {
+ height += (minsize = hscroll.getPreferredSize().height);
+ }
+ if (apvscroll.isVisible())
+ {
+ minsize += apvscroll.getPreferredSize().height;
+ }
+ int mheight = height;
+ Dimension d = sequenceHolderPanel.getSize(), e = idPanel.getSize();
+ int seqandannot = d.height - scalePanelHolder.getSize().height;
+
+ if (adjustPanelHeight)
+ {
+ // NOTE: this logic is different in the application. Need a better
+ // algorithm to define behaviour
+ // sets initial preferred height
+ // try and set height according to alignment
+ float sscaling = (float) ((av.getCharHeight() * av.getAlignment()
+ .getHeight()) / (1.0 * mheight));
+ if (sscaling > 0.5)
+ {
+ // if the alignment is too big then
+ // default is 0.5 split
+ height = seqandannot / 2;
+ }
+ else
+ {
+ // otherwise just set the panel so that one row of sequence is visible
+ height = -av.getCharHeight() * 1
+ + (int) (seqandannot * (1 - sscaling));
+ }
+ }
+ else
+ {
+ // maintain same window layout whilst updating sliders
+ height = annotationPanelHolder.getSize().height;
+ }
+
+ if (seqandannot - height < 5)
+ {
+ height = seqandannot;
+ }
+ annotationPanel.setSize(new Dimension(d.width, height));
+ alabels.setSize(new Dimension(e.width, height));
+ annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
+ annotationPanelHolder.setSize(new Dimension(d.width, height));
+ // seqPanelHolder.setSize(d.width, seqandannot - height);
+ seqPanel.seqCanvas
+ .setSize(d.width, seqPanel.seqCanvas.getSize().height);
+ int s = apvscroll.getValue();
+ if (s > mheight - height)
+ {
+ s = 0;
+ }
+ apvscroll.setValues(s, height, 0, mheight);
+ annotationPanel.setScrollOffset(apvscroll.getValue(), false);
+ alabels.setScrollOffset(apvscroll.getValue(), false);
+ }
+