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();
727 if (av.hasHiddenColumns())
729 column = av.getAlignment().getHiddenColumns()
730 .visibleToAbsoluteColumn(column);
733 AlignmentAnnotation ann = aa[row];
734 if (row > -1 && ann.annotations != null
735 && column < ann.annotations.length)
737 buildToolTip(ann, column, aa);
738 setStatusMessage(column, ann);
742 this.setToolTipText(null);
743 ap.alignFrame.statusBar.setText(" ");
748 * Builds a tooltip for the annotation at the current mouse position.
754 void buildToolTip(AlignmentAnnotation ann, int column,
755 AlignmentAnnotation[] anns)
757 if (ann.graphGroup > -1)
759 StringBuilder tip = new StringBuilder(32);
760 tip.append("<html>");
761 for (int i = 0; i < anns.length; i++)
763 if (anns[i].graphGroup == ann.graphGroup
764 && anns[i].annotations[column] != null)
766 tip.append(anns[i].label);
767 String description = anns[i].annotations[column].description;
768 if (description != null && description.length() > 0)
770 tip.append(" ").append(description);
775 if (tip.length() != 6)
777 tip.setLength(tip.length() - 4);
778 this.setToolTipText(tip.toString() + "</html>");
781 else if (ann.annotations[column] != null)
783 String description = ann.annotations[column].description;
784 if (description != null && description.length() > 0)
786 this.setToolTipText(JvSwingUtils.wrapTooltip(true, description));
790 this.setToolTipText(null); // no tooltip if null or empty description
795 // clear the tooltip.
796 this.setToolTipText(null);
801 * Constructs and displays the status bar message
806 void setStatusMessage(int column, AlignmentAnnotation ann)
809 * show alignment column and annotation description if any
811 StringBuilder text = new StringBuilder(32);
812 text.append(MessageManager.getString("label.column")).append(" ")
815 if (ann.annotations[column] != null)
817 String description = ann.annotations[column].description;
818 if (description != null && description.trim().length() > 0)
820 text.append(" ").append(description);
825 * if the annotation is sequence-specific, show the sequence number
826 * in the alignment, and (if not a gap) the residue and position
828 SequenceI seqref = ann.sequenceRef;
831 int seqIndex = av.getAlignment().findIndex(seqref);
834 text.append(", ").append(MessageManager.getString("label.sequence"))
835 .append(" ").append(seqIndex + 1);
836 char residue = seqref.getCharAt(column);
837 if (!Comparison.isGap(residue))
841 if (av.getAlignment().isNucleotide())
843 name = ResidueProperties.nucleotideName
844 .get(String.valueOf(residue));
845 text.append(" Nucleotide: ")
846 .append(name != null ? name : residue);
850 name = 'X' == residue ? "X"
851 : ('*' == residue ? "STOP"
852 : ResidueProperties.aa2Triplet
853 .get(String.valueOf(residue)));
854 text.append(" Residue: ").append(name != null ? name : residue);
856 int residuePos = seqref.findPosition(column);
857 text.append(" (").append(residuePos).append(")");
862 ap.alignFrame.statusBar.setText(text.toString());
872 public void mouseClicked(MouseEvent evt)
874 // if (activeRow != -1)
876 // AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
877 // AlignmentAnnotation anot = aa[activeRow];
881 // TODO mouseClicked-content and drawCursor are quite experimental!
882 public void drawCursor(Graphics graphics, SequenceI seq, int res, int x1,
885 int pady = av.getCharHeight() / 5;
887 graphics.setColor(Color.black);
888 graphics.fillRect(x1, y1, av.getCharWidth(), av.getCharHeight());
890 if (av.validCharWidth)
892 graphics.setColor(Color.white);
894 char s = seq.getCharAt(res);
896 charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2;
897 graphics.drawString(String.valueOf(s), charOffset + x1,
898 (y1 + av.getCharHeight()) - pady);
903 private volatile boolean imageFresh = false;
912 public void paintComponent(Graphics g)
914 super.paintComponent(g);
916 g.setColor(Color.white);
917 g.fillRect(0, 0, getWidth(), getHeight());
921 if (fastPaint || (getVisibleRect().width != g.getClipBounds().width)
922 || (getVisibleRect().height != g.getClipBounds().height))
924 g.drawImage(image, 0, 0, this);
929 imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
930 + 1) * av.getCharWidth();
935 if (image == null || imgWidth != image.getWidth(this)
936 || image.getHeight(this) != getHeight())
940 image = new BufferedImage(imgWidth,
941 ap.getAnnotationPanel().getHeight(),
942 BufferedImage.TYPE_INT_RGB);
943 } catch (OutOfMemoryError oom)
948 } catch (Exception x)
953 "Couldn't allocate memory to redraw screen. Please restart Jalview",
957 gg = (Graphics2D) image.getGraphics();
961 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
962 RenderingHints.VALUE_ANTIALIAS_ON);
965 gg.setFont(av.getFont());
966 fm = gg.getFontMetrics();
967 gg.setColor(Color.white);
968 gg.fillRect(0, 0, imgWidth, image.getHeight());
972 drawComponent(gg, av.getRanges().getStartRes(),
973 av.getRanges().getEndRes() + 1);
975 g.drawImage(image, 0, 0, this);
979 * set true to enable redraw timing debug output on stderr
981 private final boolean debugRedraw = false;
984 * non-Thread safe repaint
987 * repaint with horizontal shift in alignment
989 public void fastPaint(int horizontal)
991 if ((horizontal == 0) || gg == null
992 || av.getAlignment().getAlignmentAnnotation() == null
993 || av.getAlignment().getAlignmentAnnotation().length < 1
994 || av.isCalcInProgress())
1000 int sr = av.getRanges().getStartRes();
1001 int er = av.getRanges().getEndRes() + 1;
1004 gg.copyArea(0, 0, imgWidth, getHeight(),
1005 -horizontal * av.getCharWidth(), 0);
1007 if (horizontal > 0) // scrollbar pulled right, image to the left
1009 transX = (er - sr - horizontal) * av.getCharWidth();
1010 sr = er - horizontal;
1012 else if (horizontal < 0)
1014 er = sr - horizontal;
1017 gg.translate(transX, 0);
1019 drawComponent(gg, sr, er);
1021 gg.translate(-transX, 0);
1025 // Call repaint on alignment panel so that repaints from other alignment
1026 // panel components can be aggregated. Otherwise performance of the overview
1027 // window and others may be adversely affected.
1028 av.getAlignPanel().repaint();
1031 private volatile boolean lastImageGood = false;
1043 public void drawComponent(Graphics g, int startRes, int endRes)
1045 BufferedImage oldFaded = fadedImage;
1046 if (av.isCalcInProgress())
1050 lastImageGood = false;
1053 // We'll keep a record of the old image,
1054 // and draw a faded image until the calculation
1057 && (fadedImage == null || fadedImage.getWidth() != imgWidth
1058 || fadedImage.getHeight() != image.getHeight()))
1060 // System.err.println("redraw faded image ("+(fadedImage==null ?
1061 // "null image" : "") + " lastGood="+lastImageGood+")");
1062 fadedImage = new BufferedImage(imgWidth, image.getHeight(),
1063 BufferedImage.TYPE_INT_RGB);
1065 Graphics2D fadedG = (Graphics2D) fadedImage.getGraphics();
1067 fadedG.setColor(Color.white);
1068 fadedG.fillRect(0, 0, imgWidth, image.getHeight());
1070 fadedG.setComposite(
1071 AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .3f));
1072 fadedG.drawImage(image, 0, 0, this);
1075 // make sure we don't overwrite the last good faded image until all
1076 // calculations have finished
1077 lastImageGood = false;
1082 if (fadedImage != null)
1084 oldFaded = fadedImage;
1089 g.setColor(Color.white);
1090 g.fillRect(0, 0, (endRes - startRes) * av.getCharWidth(), getHeight());
1092 g.setFont(av.getFont());
1095 fm = g.getFontMetrics();
1098 if ((av.getAlignment().getAlignmentAnnotation() == null)
1099 || (av.getAlignment().getAlignmentAnnotation().length < 1))
1101 g.setColor(Color.white);
1102 g.fillRect(0, 0, getWidth(), getHeight());
1103 g.setColor(Color.black);
1104 if (av.validCharWidth)
1106 g.drawString(MessageManager
1107 .getString("label.alignment_has_no_annotations"), 20, 15);
1112 lastImageGood = renderer.drawComponent(this, av, g, activeRow, startRes,
1114 if (!lastImageGood && fadedImage == null)
1116 fadedImage = oldFaded;
1121 public FontMetrics getFontMetrics()
1127 public Image getFadedImage()
1133 public int getFadedImageWidth()
1138 private int[] bounds = new int[2];
1141 public int[] getVisibleVRange()
1143 if (ap != null && ap.getAlabels() != null)
1145 int sOffset = -ap.getAlabels().getScrollOffset();
1146 int visHeight = sOffset + ap.annotationSpaceFillerHolder.getHeight();
1147 bounds[0] = sOffset;
1148 bounds[1] = visHeight;
1158 * Try to ensure any references held are nulled
1160 public void dispose()
1170 * I created the renderer so I will dispose of it
1172 if (renderer != null)
1179 public void propertyChange(PropertyChangeEvent evt)
1181 // Respond to viewport range changes (e.g. alignment panel was scrolled)
1182 // Both scrolling and resizing change viewport ranges: scrolling changes
1183 // both start and end points, but resize only changes end values.
1184 // Here we only want to fastpaint on a scroll, with resize using a normal
1185 // paint, so scroll events are identified as changes to the horizontal or
1186 // vertical start value.
1187 if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
1189 fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
1191 else if (evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ))
1193 fastPaint(((int[]) evt.getNewValue())[0]
1194 - ((int[]) evt.getOldValue())[0]);
1196 else if (evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT))
1203 * computes the visible height of the annotation panel
1205 * @param adjustPanelHeight
1206 * - when false, just adjust existing height according to other
1208 * @param annotationHeight
1209 * @return height to use for the ScrollerPreferredVisibleSize
1211 public int adjustForAlignFrame(boolean adjustPanelHeight,
1212 int annotationHeight)
1215 * Estimate available height in the AlignFrame for alignment +
1216 * annotations. Deduct an estimate for title bar, menu bar, scale panel,
1217 * hscroll, status bar, insets.
1219 int stuff = (ap.getViewName() != null ? 30 : 0)
1220 + (Platform.isAMac() ? 120 : 140);
1221 int availableHeight = ap.alignFrame.getHeight() - stuff;
1222 int rowHeight = av.getCharHeight();
1224 if (adjustPanelHeight)
1226 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
1229 * If not enough vertical space, maximize annotation height while keeping
1230 * at least two rows of alignment visible
1232 if (annotationHeight + alignmentHeight > availableHeight)
1234 annotationHeight = Math.min(annotationHeight,
1235 availableHeight - 2 * rowHeight);
1240 // maintain same window layout whilst updating sliders
1241 annotationHeight = Math.min(ap.annotationScroller.getSize().height,
1242 availableHeight - 2 * rowHeight);
1244 return annotationHeight;