From: amwaterhouse Date: Thu, 17 Mar 2005 10:39:36 +0000 (+0000) Subject: new class X-Git-Tag: Release_2_0~581 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b0a355457f5bff7fa7d16233311c1b8649f1e0a1;p=jalview.git new class --- diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java new file mode 100755 index 0000000..5d8fa0d --- /dev/null +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -0,0 +1,61 @@ +package jalview.gui; + +import javax.swing.*; +import java.awt.event.*; +import java.awt.*; + + +public class IdwidthAdjuster extends JPanel implements MouseListener, MouseMotionListener +{ + boolean active = false; + int oldX=0; + Image image; + AlignmentPanel ap ; + + public IdwidthAdjuster(AlignmentPanel ap) + { + this.ap = ap; + java.net.URL url = getClass().getResource("/images/idwidth.gif"); + if (url != null) + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + + addMouseListener(this); + addMouseMotionListener(this); + } + + public void mousePressed(MouseEvent evt) + { oldX = evt.getX(); } + + public void mouseReleased(MouseEvent evt){ } + public void mouseEntered(MouseEvent evt) { active = true; repaint();} + public void mouseExited(MouseEvent evt) { active = false; repaint();} + public void mouseDragged(MouseEvent evt) + { + active = true; + Dimension d = ap.idPanel.idCanvas.getPreferredSize(); + int dif = evt.getX() - oldX; + + if(d.width>20 || dif>0) + { + ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif,d.height)); + ap.RefreshPanels(); + } + + oldX = evt.getX(); + } + + public void mouseMoved(MouseEvent evt) {} + public void mouseClicked(MouseEvent evt) {} + + public void paintComponent(Graphics g) + { + g.setColor(Color.white); + g.fillRect(0,0, getWidth(), getHeight()); + if(active) + { + if(image!=null) + g.drawImage(image, getWidth()-20, 2, this); + } + } + +}