package jalview.gui;\r
\r
+import jalview.datamodel.*;\r
import java.awt.*;\r
import java.awt.event.*;\r
-\r
import javax.swing.*;\r
\r
public class ScalePanel extends JPanel\r
public int width;\r
\r
protected AlignViewport av;\r
+ AlignmentPanel ap;\r
\r
- public ScalePanel(AlignViewport av) {\r
+ public ScalePanel(AlignViewport av, AlignmentPanel ap)\r
+ {\r
this.av = av;\r
+ this.ap = ap;\r
\r
scaleCanvas = new ScaleCanvas(av);\r
setLayout(new BorderLayout());\r
{\r
doMousePressed(evt);\r
}\r
+ public void mouseReleased(MouseEvent evt)\r
+ {\r
+ doMouseReleased(evt);\r
+ }\r
+\r
+ });\r
+ addMouseMotionListener(new MouseMotionAdapter()\r
+ {\r
+ public void mouseDragged(MouseEvent evt)\r
+ {\r
+ doMouseDragged(evt);\r
+ }\r
});\r
+\r
}\r
\r
public Dimension getMinimumSize() {\r
\r
if (! av.getColumnSelection().contains(res))\r
av.getColumnSelection().addElement(res);\r
- else\r
- av.getColumnSelection().removeElement(res);\r
+ else\r
+ return;\r
+\r
+ SequenceGroup sg = new SequenceGroup();\r
+ for(int i=0; i<av.alignment.getSequences().size(); i++)\r
+ sg.addSequence(av.alignment.getSequenceAt(i));\r
+\r
+ sg.setStartRes(res);\r
+ sg.setEndRes(res);\r
+ av.setRubberbandGroup(sg);\r
+ ap.RefreshPanels();\r
+ }\r
+\r
+ public void doMouseReleased(MouseEvent evt)\r
+ {\r
+ int x = evt.getX();\r
+ int res = x/av.getCharWidth() + av.getStartRes();\r
+\r
+ if (! av.getColumnSelection().contains(res))\r
+ av.getColumnSelection().addElement(res);\r
+\r
+ SequenceGroup sg = av.getRubberbandGroup();\r
+\r
+ if(res>sg.getStartRes())\r
+ sg.setEndRes(res);\r
+ else if(res<sg.getStartRes())\r
+ sg.setStartRes(res);\r
+\r
+ ap.RefreshPanels();\r
+ }\r
+\r
+ public void doMouseDragged(MouseEvent evt)\r
+ {\r
+ int x = evt.getX();\r
+ int res = x/av.getCharWidth() + av.getStartRes();\r
+\r
+ SequenceGroup sg = av.getRubberbandGroup();\r
+\r
+ if(res>sg.getStartRes())\r
+ sg.setEndRes(res);\r
+ else if(res<sg.getStartRes())\r
+ sg.setStartRes(res);\r
+\r
+\r
+ ap.RefreshPanels();\r
\r
- repaint();\r
}\r
}\r