X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSliderPanel.java;h=8507331806f0ae0d12f19917ec579b30b1f53293;hb=ccc0d91abe38690088a6050faba8ef66cde1f271;hp=a53e9dd613151de2acd56978ceb0012f9ee6758b;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git diff --git a/src/jalview/appletgui/SliderPanel.java b/src/jalview/appletgui/SliderPanel.java index a53e9dd..8507331 100755 --- a/src/jalview/appletgui/SliderPanel.java +++ b/src/jalview/appletgui/SliderPanel.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,7 +27,10 @@ import java.awt.event.*; import jalview.datamodel.*; import jalview.schemes.*; -public class SliderPanel extends Panel +public class SliderPanel + extends Panel implements ActionListener, + AdjustmentListener, + MouseListener { AlignmentPanel ap; boolean forConservation = true; @@ -151,11 +154,14 @@ public class SliderPanel extends Panel public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, ColourSchemeI cs) { - try { - jbInit(); - } catch (Exception e) { - e.printStackTrace(); - } + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } this.ap = ap; this.cs = cs; forConservation = forConserve; @@ -176,14 +182,8 @@ public class SliderPanel extends Panel slider.setBlockIncrement(1); } - slider.addAdjustmentListener(new AdjustmentListener() - { - public void adjustmentValueChanged(AdjustmentEvent evt) - { - valueField.setText(slider.getValue() + ""); - valueChanged(slider.getValue()); - } - }); + slider.addAdjustmentListener(this); + slider.addMouseListener(this); slider.setValue(value); valueField.setText(value + ""); @@ -238,7 +238,29 @@ public class SliderPanel extends Panel allGroupsCheck.setEnabled(b); } - public void valueField_actionPerformed(ActionEvent e) + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == applyButton) + { + applyButton_actionPerformed(); + } + else if (evt.getSource() == undoButton) + { + undoButton_actionPerformed(); + } + else if (evt.getSource() == valueField) + { + valueField_actionPerformed(); + } + } + + public void adjustmentValueChanged(AdjustmentEvent evt) + { + valueField.setText(slider.getValue() + ""); + valueChanged(slider.getValue()); + } + + public void valueField_actionPerformed() { try { @@ -275,62 +297,67 @@ public class SliderPanel extends Panel BorderLayout borderLayout2 = new BorderLayout(); FlowLayout flowLayout2 = new FlowLayout(); - private void jbInit() throws Exception { - this.setLayout(borderLayout2); - - // slider.setMajorTickSpacing(10); - // slider.setMinorTickSpacing(1); - // slider.setPaintTicks(true); - slider.setBackground(Color.white); - slider.setFont(new java.awt.Font("Verdana", 0, 11)); - slider.setOrientation(0); - valueField.setFont(new java.awt.Font("Verdana", 0, 11)); - valueField.setText(" "); - valueField.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - valueField_actionPerformed(e); - } - }); - label.setFont(new java.awt.Font("Verdana", 0, 11)); - label.setText("set this label text"); - jPanel1.setLayout(borderLayout1); - jPanel2.setLayout(flowLayout1); - applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); - applyButton.setLabel("Apply"); - applyButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - applyButton_actionPerformed(e); - } - }); - undoButton.setEnabled(false); - undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); - undoButton.setLabel("Undo"); - undoButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - undoButton_actionPerformed(e); - } - }); - allGroupsCheck.setEnabled(false); - allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); - allGroupsCheck.setLabel("Apply threshold to all groups"); - allGroupsCheck.setName("Apply to all Groups"); - this.setBackground(Color.white); - this.setForeground(Color.black); - jPanel2.add(label, null); - jPanel2.add(applyButton, null); - jPanel2.add(undoButton, null); - jPanel2.add(allGroupsCheck); - jPanel1.add(valueField, java.awt.BorderLayout.EAST); - jPanel1.add(slider, java.awt.BorderLayout.CENTER); - this.add(jPanel1, java.awt.BorderLayout.SOUTH); - this.add(jPanel2, java.awt.BorderLayout.CENTER); - } - - protected void applyButton_actionPerformed(ActionEvent e) + private void jbInit() + throws Exception { + this.setLayout(borderLayout2); + + // slider.setMajorTickSpacing(10); + // slider.setMinorTickSpacing(1); + // slider.setPaintTicks(true); + slider.setBackground(Color.white); + slider.setFont(new java.awt.Font("Verdana", 0, 11)); + slider.setOrientation(0); + valueField.setFont(new java.awt.Font("Verdana", 0, 11)); + valueField.setText(" "); + valueField.addActionListener(this); + label.setFont(new java.awt.Font("Verdana", 0, 11)); + label.setText("set this label text"); + jPanel1.setLayout(borderLayout1); + jPanel2.setLayout(flowLayout1); + applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); + applyButton.setLabel("Apply"); + applyButton.addActionListener(this); + undoButton.setEnabled(false); + undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); + undoButton.setLabel("Undo"); + undoButton.addActionListener(this); + allGroupsCheck.setEnabled(false); + allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); + allGroupsCheck.setLabel("Apply threshold to all groups"); + allGroupsCheck.setName("Apply to all Groups"); + this.setBackground(Color.white); + this.setForeground(Color.black); + jPanel2.add(label, null); + jPanel2.add(applyButton, null); + jPanel2.add(undoButton, null); + jPanel2.add(allGroupsCheck); + jPanel1.add(valueField, java.awt.BorderLayout.EAST); + jPanel1.add(slider, java.awt.BorderLayout.CENTER); + this.add(jPanel1, java.awt.BorderLayout.SOUTH); + this.add(jPanel2, java.awt.BorderLayout.CENTER); } - protected void undoButton_actionPerformed(ActionEvent e) + protected void applyButton_actionPerformed() + {} + + protected void undoButton_actionPerformed() + {} + + public void mousePressed(MouseEvent evt) + {} + + public void mouseReleased(MouseEvent evt) { + ap.paintAlignment(true); } + + public void mouseClicked(MouseEvent evt) + {} + + public void mouseEntered(MouseEvent evt) + {} + + public void mouseExited(MouseEvent evt) + {} }