2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.datamodel.AlignmentAnnotation;
24 import jalview.datamodel.Annotation;
25 import jalview.datamodel.ColumnSelection;
26 import jalview.datamodel.HiddenColumns;
27 import jalview.datamodel.SequenceI;
28 import jalview.renderer.AnnotationRenderer;
29 import jalview.renderer.AwtRenderPanelI;
30 import jalview.schemes.ResidueProperties;
31 import jalview.util.Comparison;
32 import jalview.util.MessageManager;
33 import jalview.util.Platform;
34 import jalview.viewmodel.ViewportListenerI;
35 import jalview.viewmodel.ViewportRanges;
37 import java.awt.AlphaComposite;
38 import java.awt.Color;
39 import java.awt.Dimension;
40 import java.awt.FontMetrics;
41 import java.awt.Graphics;
42 import java.awt.Graphics2D;
43 import java.awt.Image;
44 import java.awt.Rectangle;
45 import java.awt.RenderingHints;
46 import java.awt.event.ActionEvent;
47 import java.awt.event.ActionListener;
48 import java.awt.event.AdjustmentEvent;
49 import java.awt.event.AdjustmentListener;
50 import java.awt.event.MouseEvent;
51 import java.awt.event.MouseListener;
52 import java.awt.event.MouseMotionListener;
53 import java.awt.event.MouseWheelEvent;
54 import java.awt.event.MouseWheelListener;
55 import java.awt.image.BufferedImage;
56 import java.beans.PropertyChangeEvent;
57 import java.util.ArrayList;
58 import java.util.Collections;
59 import java.util.List;
61 import javax.swing.JColorChooser;
62 import javax.swing.JMenuItem;
63 import javax.swing.JPanel;
64 import javax.swing.JPopupMenu;
65 import javax.swing.Scrollable;
66 import javax.swing.ToolTipManager;
69 * AnnotationPanel displays visible portion of annotation rows below unwrapped
75 public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
76 MouseListener, MouseWheelListener, MouseMotionListener,
77 ActionListener, AdjustmentListener, Scrollable, ViewportListenerI
79 String HELIX = MessageManager.getString("label.helix");
81 String SHEET = MessageManager.getString("label.sheet");
84 * For RNA secondary structure "stems" aka helices
86 String STEM = MessageManager.getString("label.rna_helix");
88 String LABEL = MessageManager.getString("label.label");
90 String REMOVE = MessageManager.getString("label.remove_annotation");
92 String COLOUR = MessageManager.getString("action.colour");
94 public final Color HELIX_COLOUR = Color.red.darker();
96 public final Color SHEET_COLOUR = Color.green.darker().darker();
98 public final Color STEM_COLOUR = Color.blue.darker();
101 public AlignViewport av;
105 public int activeRow = -1;
107 public BufferedImage image;
109 public volatile BufferedImage fadedImage;
113 public FontMetrics fm;
115 public int imgWidth = 0;
117 boolean fastPaint = false;
119 // Used For mouse Dragging and resizing graphs
120 int graphStretch = -1;
122 int graphStretchY = -1;
124 int min; // used by mouseDragged to see if user
126 int max; // used by mouseDragged to see if user
128 boolean mouseDragging = false;
130 // for editing cursor
135 public final AnnotationRenderer renderer;
137 private MouseWheelListener[] _mwl;
140 * Creates a new AnnotationPanel object.
145 public AnnotationPanel(AlignmentPanel ap)
147 ToolTipManager.sharedInstance().registerComponent(this);
148 ToolTipManager.sharedInstance().setInitialDelay(0);
149 ToolTipManager.sharedInstance().setDismissDelay(10000);
152 this.setLayout(null);
153 addMouseListener(this);
154 addMouseMotionListener(this);
155 ap.annotationScroller.getVerticalScrollBar()
156 .addAdjustmentListener(this);
157 // save any wheel listeners on the scroller, so we can propagate scroll
159 _mwl = ap.annotationScroller.getMouseWheelListeners();
160 // and then set our own listener to consume all mousewheel events
161 ap.annotationScroller.addMouseWheelListener(this);
162 renderer = new AnnotationRenderer();
164 av.getRanges().addPropertyChangeListener(this);
167 public AnnotationPanel(AlignViewport av)
170 renderer = new AnnotationRenderer();
174 public void mouseWheelMoved(MouseWheelEvent e)
179 double wheelRotation = e.getPreciseWheelRotation();
180 if (wheelRotation > 0)
182 av.getRanges().scrollRight(true);
184 else if (wheelRotation < 0)
186 av.getRanges().scrollRight(false);
191 // TODO: find the correct way to let the event bubble up to
192 // ap.annotationScroller
193 for (MouseWheelListener mwl : _mwl)
197 mwl.mouseWheelMoved(e);
208 public Dimension getPreferredScrollableViewportSize()
210 Dimension ps = getPreferredSize();
211 return new Dimension(ps.width, adjustForAlignFrame(false, ps.height));
215 public int getScrollableBlockIncrement(Rectangle visibleRect,
216 int orientation, int direction)
222 public boolean getScrollableTracksViewportHeight()
228 public boolean getScrollableTracksViewportWidth()
234 public int getScrollableUnitIncrement(Rectangle visibleRect,
235 int orientation, int direction)
244 * java.awt.event.AdjustmentListener#adjustmentValueChanged(java.awt.event
248 public void adjustmentValueChanged(AdjustmentEvent evt)
250 // update annotation label display
251 ap.getAlabels().setScrollOffset(-evt.getValue());
255 * Calculates the height of the annotation displayed in the annotation panel.
256 * Callers should normally call the ap.adjustAnnotationHeight method to ensure
257 * all annotation associated components are updated correctly.
260 public int adjustPanelHeight()
262 int height = av.calcPanelHeight();
263 this.setPreferredSize(new Dimension(1, height));
266 // revalidate only when the alignment panel is fully constructed
280 public void actionPerformed(ActionEvent evt)
282 AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
287 Annotation[] anot = aa[activeRow].annotations;
289 if (anot.length < av.getColumnSelection().getMax())
291 Annotation[] temp = new Annotation[av.getColumnSelection().getMax()
293 System.arraycopy(anot, 0, temp, 0, anot.length);
295 aa[activeRow].annotations = anot;
298 String action = evt.getActionCommand();
299 if (action.equals(REMOVE))
301 for (int index : av.getColumnSelection().getSelected())
303 if (av.getAlignment().getHiddenColumns().isVisible(index))
309 else if (action.equals(LABEL))
311 String exMesg = collectAnnotVals(anot, LABEL);
312 String label = JvOptionPane.showInputDialog(this,
313 MessageManager.getString("label.enter_label"), exMesg);
320 if ((label.length() > 0) && !aa[activeRow].hasText)
322 aa[activeRow].hasText = true;
325 for (int index : av.getColumnSelection().getSelected())
327 if (!av.getAlignment().getHiddenColumns().isVisible(index))
332 if (anot[index] == null)
334 anot[index] = new Annotation(label, "", ' ', 0);
338 anot[index].displayCharacter = label;
342 else if (action.equals(COLOUR))
344 Color col = JColorChooser.showDialog(this,
345 MessageManager.getString("label.select_foreground_colour"),
348 for (int index : av.getColumnSelection().getSelected())
350 if (!av.getAlignment().getHiddenColumns().isVisible(index))
355 if (anot[index] == null)
357 anot[index] = new Annotation("", "", ' ', 0);
360 anot[index].colour = col;
364 // HELIX, SHEET or STEM
367 String symbol = "\u03B1"; // alpha
369 if (action.equals(HELIX))
373 else if (action.equals(SHEET))
376 symbol = "\u03B2"; // beta
379 // Added by LML to color stems
380 else if (action.equals(STEM))
383 int column = av.getColumnSelection().getSelectedRanges().get(0)[0];
384 symbol = aa[activeRow].getDefaultRnaHelixSymbol(column);
387 if (!aa[activeRow].hasIcons)
389 aa[activeRow].hasIcons = true;
392 String label = JvOptionPane.showInputDialog(MessageManager
393 .getString("label.enter_label_for_the_structure"), symbol);
400 if ((label.length() > 0) && !aa[activeRow].hasText)
402 aa[activeRow].hasText = true;
403 if (action.equals(STEM))
405 aa[activeRow].showAllColLabels = true;
408 for (int index : av.getColumnSelection().getSelected())
410 if (!av.getAlignment().getHiddenColumns().isVisible(index))
415 if (anot[index] == null)
417 anot[index] = new Annotation(label, "", type, 0);
420 anot[index].secondaryStructure = type != 'S' ? type
421 : label.length() == 0 ? ' ' : label.charAt(0);
422 anot[index].displayCharacter = label;
427 av.getAlignment().validateAnnotation(aa[activeRow]);
428 ap.alignmentChanged();
429 ap.alignFrame.setMenusForViewport();
437 * Returns any existing annotation concatenated as a string. For each
438 * annotation, takes the description, if any, else the secondary structure
439 * character (if type is HELIX, SHEET or STEM), else the display character (if
446 private String collectAnnotVals(Annotation[] anots, String type)
448 // TODO is this method wanted? why? 'last' is not used
450 StringBuilder collatedInput = new StringBuilder(64);
452 ColumnSelection viscols = av.getColumnSelection();
453 HiddenColumns hidden = av.getAlignment().getHiddenColumns();
456 * the selection list (read-only view) is in selection order, not
457 * column order; make a copy so we can sort it
459 List<Integer> selected = new ArrayList<>(viscols.getSelected());
460 Collections.sort(selected);
461 for (int index : selected)
463 // always check for current display state - just in case
464 if (!hidden.isVisible(index))
468 String tlabel = null;
469 if (anots[index] != null)
470 { // LML added stem code
471 if (type.equals(HELIX) || type.equals(SHEET) || type.equals(STEM)
472 || type.equals(LABEL))
474 tlabel = anots[index].description;
475 if (tlabel == null || tlabel.length() < 1)
477 if (type.equals(HELIX) || type.equals(SHEET)
478 || type.equals(STEM))
480 tlabel = "" + anots[index].secondaryStructure;
484 tlabel = "" + anots[index].displayCharacter;
488 if (tlabel != null && !tlabel.equals(last))
490 if (last.length() > 0)
492 collatedInput.append(" ");
494 collatedInput.append(tlabel);
498 return collatedInput.toString();
508 public void mousePressed(MouseEvent evt)
511 AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
520 final int y = evt.getY();
521 for (int i = 0; i < aa.length; i++)
525 height += aa[i].height;
534 else if (aa[i].graph > 0)
546 * isPopupTrigger fires in mousePressed on Mac,
547 * not until mouseRelease on Windows
549 if (evt.isPopupTrigger() && activeRow != -1)
551 showPopupMenu(y, evt.getX());
555 ap.getScalePanel().mousePressed(evt);
559 * Construct and display a context menu at the right-click position
564 void showPopupMenu(final int y, int x)
566 if (av.getColumnSelection() == null
567 || av.getColumnSelection().isEmpty())
572 JPopupMenu pop = new JPopupMenu(
573 MessageManager.getString("label.structure_type"));
576 * Just display the needed structure options
578 if (av.getAlignment().isNucleotide())
580 item = new JMenuItem(STEM);
581 item.addActionListener(this);
586 item = new JMenuItem(HELIX);
587 item.addActionListener(this);
589 item = new JMenuItem(SHEET);
590 item.addActionListener(this);
593 item = new JMenuItem(LABEL);
594 item.addActionListener(this);
596 item = new JMenuItem(COLOUR);
597 item.addActionListener(this);
599 item = new JMenuItem(REMOVE);
600 item.addActionListener(this);
602 pop.show(this, x, y);
612 public void mouseReleased(MouseEvent evt)
616 mouseDragging = false;
617 ap.getScalePanel().mouseReleased(evt);
620 * isPopupTrigger is set in mouseReleased on Windows
621 * (in mousePressed on Mac)
623 if (evt.isPopupTrigger() && activeRow != -1)
625 showPopupMenu(evt.getY(), evt.getX());
637 public void mouseEntered(MouseEvent evt)
639 ap.getScalePanel().mouseEntered(evt);
649 public void mouseExited(MouseEvent evt)
651 ap.getScalePanel().mouseExited(evt);
661 public void mouseDragged(MouseEvent evt)
663 if (graphStretch > -1)
666 .getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
668 if (av.getAlignment()
669 .getAlignmentAnnotation()[graphStretch].graphHeight < 0)
672 .getAlignmentAnnotation()[graphStretch].graphHeight = 0;
674 graphStretchY = evt.getY();
676 ap.paintAlignment(false, false);
680 ap.getScalePanel().mouseDragged(evt);
685 * Constructs the tooltip, and constructs and displays a status message, for
686 * the current mouse position
691 public void mouseMoved(MouseEvent evt)
693 AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
697 this.setToolTipText(null);
704 for (int i = 0; i < aa.length; i++)
708 height += aa[i].height;
711 if (evt.getY() < height)
720 this.setToolTipText(null);
724 int column = (evt.getX() / av.getCharWidth())
725 + av.getRanges().getStartRes();
726 column = Math.min(column, av.getRanges().getEndRes());
728 if (av.hasHiddenColumns())
730 column = av.getAlignment().getHiddenColumns()
731 .visibleToAbsoluteColumn(column);
734 AlignmentAnnotation ann = aa[row];
735 if (row > -1 && ann.annotations != null
736 && column < ann.annotations.length)
738 buildToolTip(ann, column, aa);
739 setStatusMessage(column, ann);
743 this.setToolTipText(null);
744 ap.alignFrame.statusBar.setText(" ");
749 * Builds a tooltip for the annotation at the current mouse position.
755 void buildToolTip(AlignmentAnnotation ann, int column,
756 AlignmentAnnotation[] anns)
758 if (ann.graphGroup > -1)
760 StringBuilder tip = new StringBuilder(32);
761 tip.append("<html>");
762 for (int i = 0; i < anns.length; i++)
764 if (anns[i].graphGroup == ann.graphGroup
765 && anns[i].annotations[column] != null)
767 tip.append(anns[i].label);
768 String description = anns[i].annotations[column].description;
769 if (description != null && description.length() > 0)
771 tip.append(" ").append(description);
776 if (tip.length() != 6)
778 tip.setLength(tip.length() - 4);
779 this.setToolTipText(tip.toString() + "</html>");
782 else if (ann.annotations[column] != null)
784 String description = ann.annotations[column].description;
785 if (description != null && description.length() > 0)
787 this.setToolTipText(JvSwingUtils.wrapTooltip(true, description));
791 this.setToolTipText(null); // no tooltip if null or empty description
796 // clear the tooltip.
797 this.setToolTipText(null);
802 * Constructs and displays the status bar message
807 void setStatusMessage(int column, AlignmentAnnotation ann)
810 * show alignment column and annotation description if any
812 StringBuilder text = new StringBuilder(32);
813 text.append(MessageManager.getString("label.column")).append(" ")
816 if (ann.annotations[column] != null)
818 String description = ann.annotations[column].description;
819 if (description != null && description.trim().length() > 0)
821 text.append(" ").append(description);
826 * if the annotation is sequence-specific, show the sequence number
827 * in the alignment, and (if not a gap) the residue and position
829 SequenceI seqref = ann.sequenceRef;
832 int seqIndex = av.getAlignment().findIndex(seqref);
835 text.append(", ").append(MessageManager.getString("label.sequence"))
836 .append(" ").append(seqIndex + 1);
837 char residue = seqref.getCharAt(column);
838 if (!Comparison.isGap(residue))
842 if (av.getAlignment().isNucleotide())
844 name = ResidueProperties.nucleotideName
845 .get(String.valueOf(residue));
846 text.append(" Nucleotide: ")
847 .append(name != null ? name : residue);
851 name = 'X' == residue ? "X"
852 : ('*' == residue ? "STOP"
853 : ResidueProperties.aa2Triplet
854 .get(String.valueOf(residue)));
855 text.append(" Residue: ").append(name != null ? name : residue);
857 int residuePos = seqref.findPosition(column);
858 text.append(" (").append(residuePos).append(")");
863 ap.alignFrame.statusBar.setText(text.toString());
873 public void mouseClicked(MouseEvent evt)
875 // if (activeRow != -1)
877 // AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
878 // AlignmentAnnotation anot = aa[activeRow];
882 // TODO mouseClicked-content and drawCursor are quite experimental!
883 public void drawCursor(Graphics graphics, SequenceI seq, int res, int x1,
886 int pady = av.getCharHeight() / 5;
888 graphics.setColor(Color.black);
889 graphics.fillRect(x1, y1, av.getCharWidth(), av.getCharHeight());
891 if (av.validCharWidth)
893 graphics.setColor(Color.white);
895 char s = seq.getCharAt(res);
897 charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2;
898 graphics.drawString(String.valueOf(s), charOffset + x1,
899 (y1 + av.getCharHeight()) - pady);
904 private volatile boolean imageFresh = false;
913 public void paintComponent(Graphics g)
915 super.paintComponent(g);
917 g.setColor(Color.white);
918 g.fillRect(0, 0, getWidth(), getHeight());
922 if (fastPaint || (getVisibleRect().width != g.getClipBounds().width)
923 || (getVisibleRect().height != g.getClipBounds().height))
925 g.drawImage(image, 0, 0, this);
930 imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
931 + 1) * av.getCharWidth();
936 if (image == null || imgWidth != image.getWidth(this)
937 || image.getHeight(this) != getHeight())
941 image = new BufferedImage(imgWidth,
942 ap.getAnnotationPanel().getHeight(),
943 BufferedImage.TYPE_INT_RGB);
944 } catch (OutOfMemoryError oom)
949 } catch (Exception x)
954 "Couldn't allocate memory to redraw screen. Please restart Jalview",
958 gg = (Graphics2D) image.getGraphics();
962 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
963 RenderingHints.VALUE_ANTIALIAS_ON);
966 gg.setFont(av.getFont());
967 fm = gg.getFontMetrics();
968 gg.setColor(Color.white);
969 gg.fillRect(0, 0, imgWidth, image.getHeight());
973 drawComponent(gg, av.getRanges().getStartRes(),
974 av.getRanges().getEndRes() + 1);
976 g.drawImage(image, 0, 0, this);
980 * set true to enable redraw timing debug output on stderr
982 private final boolean debugRedraw = false;
985 * non-Thread safe repaint
988 * repaint with horizontal shift in alignment
990 public void fastPaint(int horizontal)
992 if ((horizontal == 0) || gg == null
993 || av.getAlignment().getAlignmentAnnotation() == null
994 || av.getAlignment().getAlignmentAnnotation().length < 1
995 || av.isCalcInProgress())
1001 int sr = av.getRanges().getStartRes();
1002 int er = av.getRanges().getEndRes() + 1;
1005 gg.copyArea(0, 0, imgWidth, getHeight(),
1006 -horizontal * av.getCharWidth(), 0);
1008 if (horizontal > 0) // scrollbar pulled right, image to the left
1010 transX = (er - sr - horizontal) * av.getCharWidth();
1011 sr = er - horizontal;
1013 else if (horizontal < 0)
1015 er = sr - horizontal;
1018 gg.translate(transX, 0);
1020 drawComponent(gg, sr, er);
1022 gg.translate(-transX, 0);
1026 // Call repaint on alignment panel so that repaints from other alignment
1027 // panel components can be aggregated. Otherwise performance of the overview
1028 // window and others may be adversely affected.
1029 av.getAlignPanel().repaint();
1032 private volatile boolean lastImageGood = false;
1044 public void drawComponent(Graphics g, int startRes, int endRes)
1046 BufferedImage oldFaded = fadedImage;
1047 if (av.isCalcInProgress())
1051 lastImageGood = false;
1054 // We'll keep a record of the old image,
1055 // and draw a faded image until the calculation
1058 && (fadedImage == null || fadedImage.getWidth() != imgWidth
1059 || fadedImage.getHeight() != image.getHeight()))
1061 // System.err.println("redraw faded image ("+(fadedImage==null ?
1062 // "null image" : "") + " lastGood="+lastImageGood+")");
1063 fadedImage = new BufferedImage(imgWidth, image.getHeight(),
1064 BufferedImage.TYPE_INT_RGB);
1066 Graphics2D fadedG = (Graphics2D) fadedImage.getGraphics();
1068 fadedG.setColor(Color.white);
1069 fadedG.fillRect(0, 0, imgWidth, image.getHeight());
1071 fadedG.setComposite(
1072 AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .3f));
1073 fadedG.drawImage(image, 0, 0, this);
1076 // make sure we don't overwrite the last good faded image until all
1077 // calculations have finished
1078 lastImageGood = false;
1083 if (fadedImage != null)
1085 oldFaded = fadedImage;
1090 g.setColor(Color.white);
1091 g.fillRect(0, 0, (endRes - startRes) * av.getCharWidth(), getHeight());
1093 g.setFont(av.getFont());
1096 fm = g.getFontMetrics();
1099 if ((av.getAlignment().getAlignmentAnnotation() == null)
1100 || (av.getAlignment().getAlignmentAnnotation().length < 1))
1102 g.setColor(Color.white);
1103 g.fillRect(0, 0, getWidth(), getHeight());
1104 g.setColor(Color.black);
1105 if (av.validCharWidth)
1107 g.drawString(MessageManager
1108 .getString("label.alignment_has_no_annotations"), 20, 15);
1113 lastImageGood = renderer.drawComponent(this, av, g, activeRow, startRes,
1115 if (!lastImageGood && fadedImage == null)
1117 fadedImage = oldFaded;
1122 public FontMetrics getFontMetrics()
1128 public Image getFadedImage()
1134 public int getFadedImageWidth()
1139 private int[] bounds = new int[2];
1142 public int[] getVisibleVRange()
1144 if (ap != null && ap.getAlabels() != null)
1146 int sOffset = -ap.getAlabels().getScrollOffset();
1147 int visHeight = sOffset + ap.annotationSpaceFillerHolder.getHeight();
1148 bounds[0] = sOffset;
1149 bounds[1] = visHeight;
1159 * Try to ensure any references held are nulled
1161 public void dispose()
1171 * I created the renderer so I will dispose of it
1173 if (renderer != null)
1180 public void propertyChange(PropertyChangeEvent evt)
1182 // Respond to viewport range changes (e.g. alignment panel was scrolled)
1183 // Both scrolling and resizing change viewport ranges: scrolling changes
1184 // both start and end points, but resize only changes end values.
1185 // Here we only want to fastpaint on a scroll, with resize using a normal
1186 // paint, so scroll events are identified as changes to the horizontal or
1187 // vertical start value.
1188 if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
1190 fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
1192 else if (evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ))
1194 fastPaint(((int[]) evt.getNewValue())[0]
1195 - ((int[]) evt.getOldValue())[0]);
1197 else if (evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT))
1204 * computes the visible height of the annotation panel
1206 * @param adjustPanelHeight
1207 * - when false, just adjust existing height according to other
1209 * @param annotationHeight
1210 * @return height to use for the ScrollerPreferredVisibleSize
1212 public int adjustForAlignFrame(boolean adjustPanelHeight,
1213 int annotationHeight)
1216 * Estimate available height in the AlignFrame for alignment +
1217 * annotations. Deduct an estimate for title bar, menu bar, scale panel,
1218 * hscroll, status bar, insets.
1220 int stuff = (ap.getViewName() != null ? 30 : 0)
1221 + (Platform.isAMac() ? 120 : 140);
1222 int availableHeight = ap.alignFrame.getHeight() - stuff;
1223 int rowHeight = av.getCharHeight();
1225 if (adjustPanelHeight)
1227 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
1230 * If not enough vertical space, maximize annotation height while keeping
1231 * at least two rows of alignment visible
1233 if (annotationHeight + alignmentHeight > availableHeight)
1235 annotationHeight = Math.min(annotationHeight,
1236 availableHeight - 2 * rowHeight);
1241 // maintain same window layout whilst updating sliders
1242 annotationHeight = Math.min(ap.annotationScroller.getSize().height,
1243 availableHeight - 2 * rowHeight);
1245 return annotationHeight;