From 2cd1aa94f5fbcdc8a5facf3ee34447fee96ac5be Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 22 Mar 2005 12:17:56 +0000 Subject: [PATCH] add swing runnable to refresh panel on startup --- src/jalview/gui/AlignmentPanel.java | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index ac0862e..95a8e7c 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -52,7 +52,22 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene scalePanelHolder.add(scalePanel, BorderLayout.CENTER); scorePanelHolder.add(scorePanel, BorderLayout.CENTER); seqPanelHolder.add(seqPanel, BorderLayout.CENTER); - setScrollValues(0,0); + + + if(seqPanel.seqCanvas.getWidth()==0) + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + setScrollValues(0,0); + Dimension d = calculateIdWidth(); + d.setSize( d.width+4, d.height); + idPanel.idCanvas.setPreferredSize( d ); + hscrollFillerPanel.setPreferredSize( d ); + RefreshPanels(); + } + }); + hscroll.addAdjustmentListener(this); vscroll.addAdjustmentListener(this); @@ -61,16 +76,11 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene { public void componentResized(ComponentEvent evt) { - if(seqPanel.getWidth()>0 && seqPanel.getHeight()>0) RefreshPanels(); } }); - - // hscroll.setFocusable(false); - // vscroll.setFocusable(false); setFocusable(true); - addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) @@ -224,6 +234,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene public void RefreshPanels() { + requestFocus(); invalidate(); idPanelHolder.setPreferredSize(idPanel.idCanvas.getPreferredSize()); @@ -244,12 +255,12 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene } else - setScrollValues(av.getStartRes(), av.getStartSeq()); av.getConsensus(true); if (overviewPanel != null) overviewPanel.updateOverviewImage(); validate(); + setScrollValues(av.getStartRes(), av.getStartSeq()); repaint(); } int hextent = 0; @@ -296,8 +307,13 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene public void setScrollValues(int x, int y) { - hextent = seqPanel.seqCanvas.getWidth()/av.getCharWidth(); - vextent = seqPanel.seqCanvas.getHeight()/av.getCharHeight(); + hextent = seqPanel.seqCanvas.getWidth()/av.charWidth; + vextent = seqPanel.seqCanvas.getHeight()/av.charHeight; + + if(hextent > av.alignment.getWidth()) + hextent = av.alignment.getWidth(); + if(vextent > av.alignment.getHeight()) + vextent = av.alignment.getHeight(); if(hextent+x > av.getAlignment().getWidth()) x = av.getAlignment().getWidth()- hextent; @@ -314,7 +330,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene hscroll.setValues(x,hextent,0,av.getAlignment().getWidth()); vscroll.setValues(y,vextent,0,av.getAlignment().getHeight() ); - repaint(); } -- 1.7.10.2