*/
public AlignmentPanel(AlignFrame af, final AlignViewport av)
{
+ setName("AligmentPanel");
// setBackground(Color.white); // BH 2019
alignFrame = af;
this.av = av;
{
// BH 2018.04.18 comment: addNotify() is not appropriate here. We
// are not changing ancestors, and keyboard action listeners do
- // not need to be reset. addNotify() is a very expensive operation,
+ // not need to be reset, and most importantly, we can't be sure we are actually
+ // connected to resources.
+
+ // addNotify() is a very expensive operation,
// requiring a full re-layout of all parents and children.
+
// Note in JComponent:
+
// This method is called by the toolkit internally and should
// not be called directly by programs.
+
// I note that addNotify() is called in several areas of Jalview.
int annotationHeight = getAnnotationPanel().adjustPanelHeight();
annotationHeight = getAnnotationPanel()
.adjustForAlignFrame(adjustPanelHeight, annotationHeight);
+ // BH no!!
hscroll.addNotify();
annotationScroller.setPreferredSize(
new Dimension(annotationScroller.getWidth(), annotationHeight));
/**
* update alignment layout for viewport settings
- *
- * @param wrap
- * DOCUMENT ME!
*/
public void updateLayout()
{
{
annotationScroller.setVisible(true);
annotationSpaceFillerHolder.setVisible(true);
- validateAnnotationDimensions(false);
}
+ idSpaceFillerPanel1.setVisible(!wrap);
+
+ /*
+ * defer dimension calculations if panel not yet added to a Window
+ * BH 2020.06.09
+ */
+ if (getTopLevelAncestor() == null)
+ {
+ repaint();
+ return;
+ }
+
+ if (!wrap && av.isShowAnnotation())
+ {
+ validateAnnotationDimensions(false);
+ }
int canvasWidth = getSeqPanel().seqCanvas.getWidth();
if (canvasWidth > 0)
{ // may not yet be laid out
}
}
- idSpaceFillerPanel1.setVisible(!wrap);
+ // System.out.println("ap dim = " + getSize());
+ // these values will go negative if getSize() returns (0,0):
+ // System.out.println("seqpan dim = " + getSeqPanel().getSize());
+ // System.out.println("seqcan dim = " + getSeqPanel().seqCanvas.getSize());
repaint();
}
* visible row to scroll to
*
*/
- public void setScrollValues(int xpos, int ypos)
+ public void setScrollValues(int x, int y)
{
-
- System.out.println("AlignmentPanel.setScrollValues " + xpos + "_" + ypos);
- int x = xpos;
- int y = ypos;
if (av == null || av.getAlignment() == null)
{
{
int width = av.getAlignment().getVisibleWidth();
int height = av.getAlignment().getHeight();
-
- hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
- vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
-
- System.out.println("AlignmentPanel.setScrollValues found hext=" + hextent + " vext=" + vextent + " width=" + width + " height=" + height
- );
-
- if (hextent > width)
- {
- hextent = width;
- }
-
- if (vextent > height)
- {
- vextent = height;
- }
-
+ hextent = Math.min(getSeqPanel().seqCanvas.getWidth() / av.getCharWidth(), width);
+ vextent = Math.min(getSeqPanel().seqCanvas.getHeight() / av.getCharHeight(), height);
+
+ x = Math.max(0, Math.min(x, width - hextent));
+ y = Math.max(0, Math.min(y, height - vextent));
-
- if ((hextent + x) > width)
- {
- x = width - hextent;
- }
-
- if ((vextent + y) > height)
- {
- y = height - vextent;
- }
-
-
- System.out.println("AlignmentPanel.setScrollValues resetting these to " + x + "_" + y
- + " based on hext=" + hextent + " vext=" + vextent + " width=" + width + " height=" + height
- );
-
- if (y < 0)
- {
- y = 0;
- }
-
- if (x < 0)
- {
- x = 0;
- }
-
updateRanges(x, y);
updateScrollBars(x, y, width, height);
}
if (updateOverview)
{
alignFrame.repaint();
-
if (overviewPanel != null)
{
overviewPanel.updateOverviewImage();
}
} else {
+ invalidate(); // needed so that the id width adjuster works correctly
repaint();
}
}
@Override
public void paintComponent(Graphics g)
{
+ // BH OUCH!
invalidate(); // needed so that the id width adjuster works correctly
Dimension d = getIdPanel().getIdCanvas().getPreferredSize();
}
av.setSelectionGroup(null);
av.getColumnSelection().clear();
- av.setSelectionGroup(null);
+ av.setSearchResults(null);
getIdPanel().getIdCanvas().searchResults = null;
av.sendSelection();
// JAL-2034 - should delegate to