From 8e67558df4403377d98e3efb232a10bf72fbcdbf Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 18 Apr 2005 08:03:41 +0000 Subject: [PATCH] fontChanged method added, componentListener removed --- src/jalview/gui/AlignmentPanel.java | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 9b57ae1..02330a5 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -51,10 +51,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene annotationScroller.setViewportView(annotationPanel); annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER); - Dimension d = calculateIdWidth(); - d.setSize( d.width+4, d.height); - idPanel.idCanvas.setPreferredSize( d ); - hscrollFillerPanel.setPreferredSize( d ); + fontChanged(); scalePanelHolder.add(scalePanel, BorderLayout.CENTER); seqPanelHolder.add(seqPanel, BorderLayout.CENTER); @@ -64,14 +61,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene hscroll.addAdjustmentListener(this); vscroll.addAdjustmentListener(this); - addComponentListener(new ComponentAdapter() - { - public void componentResized(ComponentEvent evt) - { - repaint(); - } - }); - setFocusable(true); addKeyListener(new KeyAdapter() { @@ -114,6 +103,20 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene }); } + public void fontChanged() + { + // set idCanvas bufferedImage to null + // to prevent drawing old image + idPanel.idCanvas.gg = null; + annotationPanel.adjustPanelHeight(); + Dimension d = calculateIdWidth(); + d.setSize(d.width + 4, d.height); + idPanel.idCanvas.setPreferredSize(d); + hscrollFillerPanel.setPreferredSize(d); + repaint(); + } + + Dimension calculateIdWidth() { Graphics g = this.getGraphics(); @@ -344,9 +347,10 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene repaint(); else { + idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY); seqPanel.seqCanvas.fastPaint(av.getStartRes() - oldX, av.getStartSeq() - oldY); - idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY); + scalePanel.repaint(); if (av.getShowAnnotation()) annotationPanel.fastPaint(av.getStartRes() - oldX); @@ -354,13 +358,14 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene } + public void paintComponent(Graphics g) { invalidate(); - Dimension d = idPanel.idCanvas.getPreferredSize(); idPanelHolder.setPreferredSize(d); hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12)); + validate(); if (av.getWrapAlignment()) { @@ -376,7 +381,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene setScrollValues(av.getStartRes(), av.getStartSeq()); } - validate(); + } -- 1.7.10.2