*/
package jalview.appletgui;
+import jalview.analysis.AnnotationSorter;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.bin.JalviewLite;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceI;
+import jalview.structure.StructureSelectionManager;
+
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
-import java.awt.Frame;
+import awt2swing.Frame;
import java.awt.Graphics;
-import java.awt.Panel;
-import java.awt.Scrollbar;
+import awt2swing.Panel;
+import awt2swing.Scrollbar;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.List;
-import jalview.analysis.AnnotationSorter;
-import jalview.api.AlignViewportI;
-import jalview.api.AlignmentViewPanel;
-import jalview.bin.JalviewLite;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SearchResults;
-import jalview.datamodel.SequenceI;
-import jalview.structure.StructureSelectionManager;
-
public class AlignmentPanel extends Panel implements AdjustmentListener,
AlignmentViewPanel
{
{
av.nullFrame = new Frame();
av.nullFrame.addNotify();
+ av.nullFrame.setFont(av.font);
}
-
Graphics g = av.nullFrame.getGraphics();
-
FontMetrics fm = g.getFontMetrics(av.font);
AlignmentI al = av.getAlignment();
}
/**
- * calculate the annotation dimensions and refresh slider values accordingly.
- * need to do repaints/notifys afterwards.
+ * 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;
+ int rowHeight = av.getCharHeight();
+ int alignmentHeight = rowHeight * av.getAlignment().getHeight();
+ int annotationHeight = av.calcPanelHeight();
+
+ int mheight = annotationHeight;
+ Dimension d = sequenceHolderPanel.getSize();
+
+ int availableHeight = d.height - scalePanelHolder.getHeight();
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
+ /*
+ * If not enough vertical space, maximize annotation height while keeping
+ * at least two rows of alignment visible
+ */
+ if (annotationHeight + alignmentHeight > availableHeight)
{
- // otherwise just set the panel so that one row of sequence is visible
- height = -av.getCharHeight() * 1
- + (int) (seqandannot * (1 - sscaling));
+ annotationHeight = Math.min(annotationHeight, availableHeight - 2
+ * rowHeight);
}
}
else
{
// maintain same window layout whilst updating sliders
- height = annotationPanelHolder.getSize().height;
+ annotationHeight = annotationPanelHolder.getSize().height;
}
- if (seqandannot - height < 5)
+ if (availableHeight - annotationHeight < 5)
{
- height = seqandannot;
+ annotationHeight = availableHeight;
}
- 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));
+
+ annotationPanel.setSize(new Dimension(d.width, annotationHeight));
+ annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight));
// seqPanelHolder.setSize(d.width, seqandannot - height);
seqPanel.seqCanvas
.setSize(d.width, seqPanel.seqCanvas.getSize().height);
+
+ Dimension e = idPanel.getSize();
+ alabels.setSize(new Dimension(e.width, annotationHeight));
+ annotationSpaceFillerHolder.setSize(new Dimension(e.width,
+ annotationHeight));
+
int s = apvscroll.getValue();
- if (s > mheight - height)
+ if (s > mheight - annotationHeight)
{
s = 0;
}
- apvscroll.setValues(s, height, 0, mheight);
+ apvscroll.setValues(s, annotationHeight, 0, mheight);
annotationPanel.setScrollOffset(apvscroll.getValue(), false);
alabels.setScrollOffset(apvscroll.getValue(), false);
}
public void adjustmentValueChanged(AdjustmentEvent evt)
{
+ if (annotationPanel == null)
+ return; // BH in process of loading
int oldX = av.getStartRes();
int oldY = av.getStartSeq();
if (updateOverview)
{
- jalview.structure.StructureSelectionManager
- .getStructureSelectionManager(av.applet)
+ StructureSelectionManager.getStructureSelectionManager(av.applet)
.sequenceColoursChanged(this);
if (overviewPanel != null)
paint(g);
}
- public void paint(Graphics g)
+ public void paintComponent(Graphics g)
{
+ System.out.println("alignframe paintcomp");
invalidate();
Dimension d = idPanel.idCanvas.getSize();
final int canvasHeight = seqPanel.seqCanvas.getSize().height;
setScrollValues(av.getStartRes(), av.getStartSeq());
}
- seqPanel.seqCanvas.repaint();
- idPanel.idCanvas.repaint();
+//bh seqPanel.seqCanvas.repaint();
+//bh idPanel.idCanvas.repaint();
if (!av.getWrapAlignment())
{
if (av.isShowAnnotation())
{
- alabels.repaint();
- annotationPanel.repaint();
+//bh alabels.repaint();
+//bh annotationPanel.repaint();
}
- scalePanel.repaint();
+//bh scalePanel.repaint();
}
}