AlignPanel RefreshPanels put into paintComponent
authoramwaterhouse <Andrew Waterhouse>
Sat, 16 Apr 2005 13:46:56 +0000 (13:46 +0000)
committeramwaterhouse <Andrew Waterhouse>
Sat, 16 Apr 2005 13:46:56 +0000 (13:46 +0000)
12 files changed:
src/jalview/analysis/SequenceFeatureFetcher.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/FontChooser.java
src/jalview/gui/IdwidthAdjuster.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/ScalePanel.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/UserDefinedColours.java

index 667a2dd..2c0aaac 100755 (executable)
@@ -99,7 +99,7 @@ public class SequenceFeatureFetcher implements Runnable
     }\r
   }catch(Exception ex){ex.printStackTrace();}\r
 \r
-  ap.RefreshPanels();\r
+  ap.repaint();\r
   findMissingIds(align);\r
   if(sbuffer.length()>0)\r
   {\r
index 3625e45..c12cf09 100755 (executable)
@@ -247,8 +247,7 @@ public class AlignFrame extends GAlignFrame
       viewport.setAlignment( new Alignment(seq) );\r
       updateEditMenuBar();\r
       viewport.updateConsensus();\r
-      alignPanel.RefreshPanels();\r
-      alignPanel.RefreshPanels();\r
+      alignPanel.repaint();\r
   }\r
 \r
   public void moveSelectedSequences(boolean up)\r
@@ -290,7 +289,7 @@ public class AlignFrame extends GAlignFrame
       }\r
     }\r
 \r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
 \r
@@ -365,7 +364,7 @@ public class AlignFrame extends GAlignFrame
         viewport.alignment.getWidth();\r
         viewport.updateConservation();\r
         viewport.updateConsensus();\r
-        alignPanel.RefreshPanels();\r
+        alignPanel.repaint();\r
       }\r
 \r
     }catch(Exception ex){}// could be anything being pasted in here\r
@@ -408,7 +407,7 @@ public class AlignFrame extends GAlignFrame
      }catch(Exception ex){}\r
    viewport.updateConservation();\r
    viewport.updateConsensus();\r
-     alignPanel.RefreshPanels();\r
+     alignPanel.repaint();\r
 \r
   }\r
 \r
@@ -421,8 +420,8 @@ public class AlignFrame extends GAlignFrame
      viewport.setAlignment( new Alignment(seq) );\r
      updateEditMenuBar();\r
      viewport.updateConsensus();\r
-     alignPanel.RefreshPanels();\r
-     alignPanel.RefreshPanels();\r
+     alignPanel.repaint();\r
+     alignPanel.repaint();\r
   }\r
 \r
 \r
@@ -431,7 +430,7 @@ public class AlignFrame extends GAlignFrame
     viewport.alignment.deleteAllGroups();\r
     viewport.setSelectionGroup(null);\r
 \r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
 \r
@@ -489,7 +488,7 @@ public class AlignFrame extends GAlignFrame
           viewport.alignment.deleteGroup(sg);\r
       }\r
 \r
-      alignPanel.RefreshPanels();\r
+      alignPanel.repaint();\r
     }\r
   }\r
 \r
@@ -514,7 +513,7 @@ public class AlignFrame extends GAlignFrame
 \r
 \r
 \r
-      alignPanel.RefreshPanels();\r
+      alignPanel.repaint();\r
     }\r
 \r
   }\r
@@ -525,7 +524,7 @@ public class AlignFrame extends GAlignFrame
     viewport.getAlignment().removeGaps();\r
     viewport.updateConservation();\r
     viewport.updateConsensus();\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)\r
@@ -547,7 +546,7 @@ public class AlignFrame extends GAlignFrame
     }\r
     viewport.updateConservation();\r
     viewport.updateConsensus();\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void setGapCharMenuItem_actionPerformed(ActionEvent e)\r
@@ -561,7 +560,7 @@ public class AlignFrame extends GAlignFrame
     }\r
     setGapCharMenuItem.setText("Set gap character to \""+nextChar+"\"");\r
     viewport.setGapCharacter(thisChar);\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void findMenuItem_actionPerformed(ActionEvent e)\r
@@ -589,13 +588,13 @@ public class AlignFrame extends GAlignFrame
     viewport.setShowFullId( fullSeqId.isSelected() );\r
 \r
     alignPanel.idPanel.idCanvas.setPreferredSize( alignPanel.calculateIdWidth() );\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   protected void colourTextMenuItem_actionPerformed(ActionEvent e)\r
   {\r
       viewport.setColourText( colourTextMenuItem.isSelected() );\r
-      alignPanel.RefreshPanels();\r
+      alignPanel.repaint();\r
   }\r
 \r
   protected void wrapMenuItem_actionPerformed(ActionEvent e)\r
@@ -605,7 +604,7 @@ public class AlignFrame extends GAlignFrame
     scaleAbove.setVisible( wrapMenuItem.isSelected() );\r
     scaleLeft.setVisible( wrapMenuItem.isSelected() );\r
     scaleRight.setVisible( wrapMenuItem.isSelected() );\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   protected void scaleAbove_actionPerformed(ActionEvent e)\r
@@ -631,20 +630,20 @@ public class AlignFrame extends GAlignFrame
   public void viewBoxesMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setShowBoxes( viewBoxesMenuItem.isSelected() );\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void viewTextMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setShowText( viewTextMenuItem.isSelected() );\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
 \r
   protected void renderGapsMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setRenderGaps(renderGapsMenuItem.isSelected());\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void sequenceFeatures_actionPerformed(ActionEvent evt)\r
@@ -655,7 +654,7 @@ public class AlignFrame extends GAlignFrame
          AlignmentUtil.fetchSequenceFeatures( viewport.alignment , alignPanel);\r
          ((Alignment)viewport.alignment).featuresAdded = true;\r
     }\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void annotationPanelMenuItem_actionPerformed(ActionEvent e)\r
@@ -870,7 +869,7 @@ public class AlignFrame extends GAlignFrame
 \r
 \r
 \r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   protected void modifyPID_actionPerformed(ActionEvent e)\r
@@ -952,14 +951,14 @@ public class AlignFrame extends GAlignFrame
   {\r
     addHistoryItem("sort");\r
     AlignmentSorter.sortByPID(viewport.getAlignment(), viewport.getAlignment().getSequenceAt(0));\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void sortIDMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     addHistoryItem("sort");\r
     AlignmentSorter.sortByID( viewport.getAlignment() );\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void sortGroupMenuItem_actionPerformed(ActionEvent e)\r
@@ -967,7 +966,7 @@ public class AlignFrame extends GAlignFrame
     addHistoryItem("sort");\r
     AlignmentSorter.sortByGroup(viewport.getAlignment());\r
     AlignmentSorter.sortGroups(viewport.getAlignment());\r
-    alignPanel.RefreshPanels();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)\r
@@ -1078,7 +1077,7 @@ public class AlignFrame extends GAlignFrame
       {\r
         addHistoryItem("sort");\r
         AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());\r
-        alignPanel.RefreshPanels();\r
+        alignPanel.repaint();\r
       }\r
     });\r
 \r
index 0cbdfbe..98eb180 100755 (executable)
@@ -59,19 +59,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
     scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
     seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
 \r
-    javax.swing.SwingUtilities.invokeLater(new Runnable()\r
-     {\r
-       public void run()\r
-       {\r
-         invalidate();\r
-         setScrollValues(0,0);\r
-         Dimension d = calculateIdWidth();\r
-         d.setSize( d.width+4, d.height);\r
-         idPanel.idCanvas.setPreferredSize( d );\r
-         RefreshPanels();\r
-       }\r
-    });\r
-\r
+    setScrollValues(0, 0);\r
 \r
     hscroll.addAdjustmentListener(this);\r
     vscroll.addAdjustmentListener(this);\r
@@ -80,7 +68,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
    {\r
      public void componentResized(ComponentEvent evt)\r
      {\r
-          RefreshPanels();\r
+          repaint();\r
      }\r
    });\r
 \r
@@ -93,7 +81,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
        {\r
          case  27: // escape key\r
            av.setSelectionGroup(null);\r
-           RefreshPanels();\r
+           repaint();\r
            break;\r
          case KeyEvent.VK_X:\r
            if(evt.isControlDown())\r
@@ -203,14 +191,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
   {\r
     annotationSpaceFillerHolder.setVisible(b);\r
     annotationScroller.setVisible(b);\r
-    javax.swing.SwingUtilities.invokeLater(new Runnable()\r
-     {\r
-       public void run()\r
-       {\r
-         RefreshPanels();\r
-       }\r
-    });\r
-\r
   }\r
 \r
 \r
@@ -224,13 +204,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
     annotationScroller.setVisible(!wrap);\r
     annotationSpaceFillerHolder.setVisible(!wrap);\r
     idSpaceFillerPanel1.setVisible(!wrap);\r
-    javax.swing.SwingUtilities.invokeLater(new Runnable()\r
-     {\r
-       public void run()\r
-       {\r
-         RefreshPanels();\r
-       }\r
-    });\r
+\r
+    repaint();\r
 \r
   }\r
 \r
@@ -255,30 +230,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
 \r
     }\r
 \r
-    RefreshPanels();\r
-  }\r
-\r
-\r
-  public void RefreshPanels()\r
-  {\r
-\r
-    Dimension d = idPanel.idCanvas.getPreferredSize();\r
-    idPanelHolder.setPreferredSize(d);\r
-    hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));\r
-\r
-    if (av.getWrapAlignment())\r
-    {\r
-      int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
-      vscroll.setValues(0, 1, 0, max);\r
-    }\r
-    else\r
-    {\r
-      if (overviewPanel != null)\r
-        overviewPanel.updateOverviewImage();\r
-      setScrollValues(av.getStartRes(), av.getStartSeq());\r
-    }\r
-\r
-    validate();\r
     repaint();\r
   }\r
 \r
@@ -403,6 +354,31 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
 \r
   }\r
 \r
+  public void paintComponent(Graphics g)\r
+  {\r
+    invalidate();\r
+\r
+    Dimension d = idPanel.idCanvas.getPreferredSize();\r
+    idPanelHolder.setPreferredSize(d);\r
+    hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));\r
+\r
+    if (av.getWrapAlignment())\r
+    {\r
+      int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
+      vscroll.setMaximum(max);\r
+      vscroll.setUnitIncrement(1);\r
+    }\r
+    else\r
+    {\r
+      if (overviewPanel != null)\r
+        overviewPanel.updateOverviewImage();\r
+      setScrollValues(av.getStartRes(), av.getStartSeq());\r
+    }\r
+\r
+    validate();\r
+\r
+  }\r
+\r
   public int print(Graphics pg, PageFormat pf, int pi) throws PrinterException\r
   {\r
     pg.translate((int)pf.getImageableX(), (int)pf.getImageableY());\r
index 3332f08..26cba7a 100755 (executable)
@@ -84,7 +84,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, MouseMoti
    }\r
 \r
    ap.annotationPanel.adjustPanelHeight();\r
-   ap.RefreshPanels();\r
+   ap.repaint();\r
 \r
   }\r
 \r
@@ -156,7 +156,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, MouseMoti
       ap.annotationScroller.setPreferredSize(new Dimension(d.width,d.height - dif));\r
       d = ap.annotationSpaceFillerHolder.getPreferredSize();\r
       ap.annotationSpaceFillerHolder.setPreferredSize(new Dimension(d.width,d.height - dif));\r
-      ap.RefreshPanels();\r
+      ap.repaint();\r
     }\r
     ap.addNotify();\r
   }\r
index 3edbdb6..e04c177 100755 (executable)
@@ -52,7 +52,7 @@ public class FontChooser extends GFontChooser
   protected void cancel_actionPerformed(ActionEvent e)\r
   {\r
     ap.av.setFont(oldFont);\r
-    ap.RefreshPanels();\r
+    ap.repaint();\r
     fontName.setSelectedItem(oldFont.getName());\r
     fontSize.setSelectedItem(oldFont.getSize()+"");\r
     fontStyle.setSelectedIndex(oldFont.getStyle());\r
index 81e9da7..6872136 100755 (executable)
@@ -38,8 +38,7 @@ public class IdwidthAdjuster extends JPanel implements MouseListener, MouseMotio
     if(d.width+dif>20 || dif>0)\r
     {\r
       ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif,d.height));\r
-      ap.invalidate();\r
-      ap.RefreshPanels();\r
+      ap.repaint();\r
     }\r
 \r
     oldX = evt.getX();\r
index b04530c..b07dce8 100755 (executable)
@@ -546,7 +546,7 @@ public class PopupMenu extends JPopupMenu
     if(s!=null)\r
     {\r
       sequence.setName(s);\r
-      ap.RefreshPanels();\r
+      ap.repaint();\r
     }\r
 \r
   }\r
@@ -556,7 +556,7 @@ public class PopupMenu extends JPopupMenu
      SequenceGroup sg = ap.av.getSelectionGroup();\r
      ap.av.alignment.deleteGroup(sg);\r
      ap.av.setSelectionGroup(null);\r
-     ap.RefreshPanels();\r
+     ap.repaint();\r
   }\r
 \r
   void pdbMenuItem_actionPerformed(ActionEvent e)\r
index 3eec476..93ffd9c 100755 (executable)
@@ -76,7 +76,7 @@ public class RedundancyPanel extends GSliderPanel
            }\r
          }\r
 \r
-         ap.RefreshPanels();\r
+         ap.repaint();\r
 \r
   }\r
 \r
@@ -85,7 +85,7 @@ public class RedundancyPanel extends GSliderPanel
       undoButton.setEnabled(false);\r
       ap.av.setAlignment( new Alignment(oldAlignment) );\r
       oldAlignment = null;\r
-      ap.RefreshPanels();\r
+      ap.repaint();\r
   }\r
 \r
 \r
index 01ba119..e49eb17 100755 (executable)
@@ -65,7 +65,7 @@ public class ScalePanel extends JPanel
       ap.annotationPanel.addEditableColumn(res);\r
     }\r
     av.setSelectionGroup(sg);\r
-    ap.RefreshPanels();\r
+    ap.repaint();\r
   }\r
 \r
   public void doMouseReleased(MouseEvent evt)\r
@@ -87,7 +87,7 @@ public class ScalePanel extends JPanel
      sg.setStartRes(res);\r
 \r
    stretchingGroup = false;\r
-   ap.RefreshPanels();\r
+   ap.repaint();\r
   }\r
 \r
   public void doMouseDragged(MouseEvent evt)\r
@@ -105,7 +105,7 @@ public class ScalePanel extends JPanel
         sg.setStartRes(res);\r
 \r
        ap.annotationPanel.addEditableColumn(res);\r
-      ap.RefreshPanels();\r
+      ap.repaint();\r
     }\r
   }\r
 \r
index 6dc2acd..c243a2e 100755 (executable)
@@ -133,11 +133,19 @@ public void fastPaint(int horizontal, int vertical)
 \r
     else if (vertical > 0) // scroll down\r
     {\r
-      transY = imgHeight - vertical * av.charHeight;\r
       ss = es - vertical;\r
+      if(ss<av.startSeq) // ie scrolling too fast, more than a page at a time\r
+        ss = av.startSeq;\r
+      else\r
+        transY = imgHeight - vertical * av.charHeight;\r
     }\r
     else if (vertical < 0)\r
+    {\r
       es = ss - vertical;\r
+      if(es > av.endSeq)\r
+        es = av.endSeq;\r
+    }\r
+\r
 \r
     gg.translate(transX, transY);\r
 \r
index 0fa6d17..0b84fa5 100755 (executable)
@@ -115,8 +115,7 @@ public class SeqPanel extends JPanel
 \r
     seqEditOccurred = -1;\r
 \r
-    ap.RefreshPanels();\r
-    repaint();\r
+    ap.repaint();\r
 \r
   }\r
 \r
index 05edac5..25820c9 100755 (executable)
@@ -119,7 +119,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
     else\r
       ap.av.setGlobalColourScheme(ucs);\r
 \r
-    ap.RefreshPanels();\r
+    ap.repaint();\r
   }\r
 \r
   protected void loadbutton_actionPerformed(ActionEvent e)\r
@@ -200,7 +200,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
     else\r
       ap.av.setGlobalColourScheme(ucs);\r
 \r
-    ap.RefreshPanels();\r
+    ap.repaint();\r
 \r
   }\r
 \r