From e61e2b53cc88a6dd4dd5abe857b19172f253ba11 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 15 Mar 2005 16:33:36 +0000 Subject: [PATCH] initial label width bug might be fixed at last --- src/jalview/gui/AlignmentPanel.java | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 15f1a1f..296bb80 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -38,6 +38,24 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene secondaryPanelHolder.add(ssPanel, BorderLayout.CENTER); idPanelHolder.add(idPanel, BorderLayout.CENTER); idPanel.addNotify(); + + javax.swing.JFrame f = new javax.swing.JFrame(); + f.addNotify(); + FontMetrics fm = f.getGraphics().getFontMetrics(av.font); + AlignmentI al = av.getAlignment(); + + int i = 0; + int idWidth = 0; + while (i < al.getHeight() && al.getSequenceAt(i) != null) + { + SequenceI s = al.getSequenceAt(i); + String str = s.getDisplayId(); + if (fm.stringWidth(str) > idWidth) + idWidth = fm.stringWidth(str); + i++; + } + hscrollFillerPanel.setPreferredSize(new Dimension(idWidth, 12)); + scalePanelHolder.add(scalePanel, BorderLayout.CENTER); scorePanelHolder.add(scorePanel, BorderLayout.CENTER); seqPanelHolder.add(seqPanel, BorderLayout.CENTER); @@ -179,16 +197,11 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene public void RefreshPanels() { - javax.swing.SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - requestFocus(); invalidate(); idPanelHolder.setPreferredSize(idPanel.idCanvas.getPreferredSize()); - hscrollFillerPanel.setPreferredSize(new Dimension(idPanel.idCanvas. - getPreferredSize().width, 12)); + if(idPanel.idCanvas.getPreferredSize()!=null) + hscrollFillerPanel.setPreferredSize(new Dimension(idPanel.idCanvas.getPreferredSize().width, 12)); idSpaceFillerPanel1.setPreferredSize(new Dimension(500, av.charHeight / 2 + 12)); scalePanelHolder.setPreferredSize(new Dimension(500, @@ -209,9 +222,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene if (overviewPanel != null) overviewPanel.updateOverviewImage(); - } - }); - validate(); repaint(); } -- 1.7.10.2