new class
authoramwaterhouse <Andrew Waterhouse>
Thu, 17 Mar 2005 10:39:36 +0000 (10:39 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 17 Mar 2005 10:39:36 +0000 (10:39 +0000)
src/jalview/gui/IdwidthAdjuster.java [new file with mode: 0755]

diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java
new file mode 100755 (executable)
index 0000000..5d8fa0d
--- /dev/null
@@ -0,0 +1,61 @@
+package jalview.gui;\r
+\r
+import javax.swing.*;\r
+import java.awt.event.*;\r
+import java.awt.*;\r
+\r
+\r
+public class IdwidthAdjuster extends JPanel implements MouseListener, MouseMotionListener\r
+{\r
+  boolean active = false;\r
+  int oldX=0;\r
+  Image image;\r
+  AlignmentPanel ap ;\r
+\r
+  public IdwidthAdjuster(AlignmentPanel ap)\r
+  {\r
+    this.ap = ap;\r
+    java.net.URL url = getClass().getResource("/images/idwidth.gif");\r
+       if (url != null)\r
+         image = java.awt.Toolkit.getDefaultToolkit().createImage(url);\r
+\r
+    addMouseListener(this);\r
+    addMouseMotionListener(this);\r
+  }\r
+\r
+  public void mousePressed(MouseEvent evt)\r
+  { oldX = evt.getX(); }\r
+\r
+  public void mouseReleased(MouseEvent evt){  }\r
+  public void mouseEntered(MouseEvent evt) { active = true;  repaint();}\r
+  public void mouseExited(MouseEvent evt)  { active = false; repaint();}\r
+  public void mouseDragged(MouseEvent evt)\r
+  {\r
+    active = true;\r
+    Dimension d = ap.idPanel.idCanvas.getPreferredSize();\r
+    int dif = evt.getX() - oldX;\r
+\r
+    if(d.width>20 || dif>0)\r
+    {\r
+      ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif,d.height));\r
+      ap.RefreshPanels();\r
+    }\r
+\r
+    oldX = evt.getX();\r
+  }\r
+\r
+  public void mouseMoved(MouseEvent evt)   {}\r
+  public void mouseClicked(MouseEvent evt) {}\r
+\r
+  public void paintComponent(Graphics g)\r
+  {\r
+    g.setColor(Color.white);\r
+    g.fillRect(0,0, getWidth(), getHeight());\r
+    if(active)\r
+    {\r
+      if(image!=null)\r
+        g.drawImage(image, getWidth()-20, 2, this);\r
+    }\r
+  }\r
+\r
+}\r