X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGSliderPanel.java;h=2dabd1b5384422ecabdde8c86119da9c1b16b40c;hb=a7169b1c72607f3c9357195b4999869650a2a891;hp=b3663fe8be09f5d045f2c7899138dd2b043fe39c;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git
diff --git a/src/jalview/jbgui/GSliderPanel.java b/src/jalview/jbgui/GSliderPanel.java
index b3663fe..2dabd1b 100755
--- a/src/jalview/jbgui/GSliderPanel.java
+++ b/src/jalview/jbgui/GSliderPanel.java
@@ -1,25 +1,47 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.jbgui;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
+import jalview.util.MessageManager;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
/**
* DOCUMENT ME!
@@ -29,6 +51,13 @@ import javax.swing.*;
*/
public class GSliderPanel extends JPanel
{
+ private static final Font VERDANA_11 = new java.awt.Font("Verdana", 0,
+ 11);
+
+ protected static final int FRAME_WIDTH = 420;
+
+ protected static final int FRAME_HEIGHT = 120;
+
// this is used for conservation colours, PID colours and redundancy threshold
protected JSlider slider = new JSlider();
@@ -38,24 +67,12 @@ public class GSliderPanel extends JPanel
protected JPanel southPanel = new JPanel();
- GridLayout gridLayout1 = new GridLayout();
-
- JPanel jPanel2 = new JPanel();
-
protected JButton applyButton = new JButton();
protected JButton undoButton = new JButton();
- FlowLayout flowLayout1 = new FlowLayout();
-
protected JCheckBox allGroupsCheck = new JCheckBox();
- BorderLayout borderLayout1 = new BorderLayout();
-
- JPanel jPanel1 = new JPanel();
-
- BorderLayout borderLayout2 = new BorderLayout();
-
/**
* Creates a new GSliderPanel object.
*/
@@ -71,103 +88,114 @@ public class GSliderPanel extends JPanel
}
/**
- * DOCUMENT ME!
- *
- * @throws Exception
- * DOCUMENT ME!
+ * Constructs and lays out the controls
*/
- private void jbInit() throws Exception
+ private void jbInit()
{
- this.setLayout(gridLayout1);
slider.setMajorTickSpacing(10);
slider.setMinorTickSpacing(1);
slider.setPaintTicks(true);
slider.setBackground(Color.white);
- slider.setFont(new java.awt.Font("Verdana", 0, 11));
+ slider.setFont(VERDANA_11);
slider.setDoubleBuffered(true);
slider.addMouseListener(new MouseAdapter()
{
+ @Override
public void mouseReleased(MouseEvent e)
{
slider_mouseReleased(e);
}
});
- valueField.setFont(new java.awt.Font("Verdana", 0, 11));
+ valueField.setFont(VERDANA_11);
valueField.setMinimumSize(new Dimension(6, 14));
valueField.setPreferredSize(new Dimension(50, 12));
valueField.setText("");
valueField.setHorizontalAlignment(SwingConstants.CENTER);
- valueField.addActionListener(new java.awt.event.ActionListener()
+ valueField.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- valueField_actionPerformed(e);
+ valueField_actionPerformed();
}
});
- label.setFont(new java.awt.Font("Verdana", 0, 11));
+ valueField.addFocusListener(new FocusAdapter()
+ {
+ @Override
+ public void focusLost(FocusEvent e)
+ {
+ valueField_actionPerformed();
+ }
+ });
+ label.setFont(VERDANA_11);
label.setOpaque(false);
label.setHorizontalAlignment(SwingConstants.CENTER);
- label.setText("set this label text");
- southPanel.setLayout(borderLayout1);
- gridLayout1.setRows(2);
- jPanel2.setLayout(flowLayout1);
- applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
+ label.setText(MessageManager.getString("label.set_this_label_text"));
+
+ applyButton.setFont(VERDANA_11);
applyButton.setOpaque(false);
- applyButton.setText("Apply");
- applyButton.addActionListener(new java.awt.event.ActionListener()
+ applyButton.setText(MessageManager.getString("action.apply"));
+ applyButton.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
applyButton_actionPerformed(e);
}
});
undoButton.setEnabled(false);
- undoButton.setFont(new java.awt.Font("Verdana", 0, 11));
+ undoButton.setFont(VERDANA_11);
undoButton.setOpaque(false);
- undoButton.setText("Undo");
- undoButton.addActionListener(new java.awt.event.ActionListener()
+ undoButton.setText(MessageManager.getString("action.undo"));
+ undoButton.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
undoButton_actionPerformed(e);
}
});
allGroupsCheck.setEnabled(false);
- allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11));
+ allGroupsCheck.setFont(VERDANA_11);
allGroupsCheck.setOpaque(false);
- allGroupsCheck.setText("Apply to all Groups");
- allGroupsCheck.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- allGroupsCheck_actionPerformed(e);
- }
- });
+ allGroupsCheck
+ .setText(MessageManager.getString("action.apply_all_groups"));
+
+ this.setLayout(new GridLayout(2, 0));
this.setBackground(Color.white);
- this.setPreferredSize(new Dimension(415, 84));
- jPanel2.setOpaque(false);
- southPanel.setOpaque(false);
- jPanel1.setLayout(borderLayout2);
+
+ JPanel firstRow = new JPanel(new FlowLayout());
+ firstRow.setOpaque(false);
+ firstRow.add(label);
+ firstRow.add(applyButton);
+ firstRow.add(undoButton);
+ this.add(firstRow);
+
+ JPanel jPanel1 = new JPanel(new BorderLayout());
jPanel1.setOpaque(false);
- this.add(jPanel2, null);
- jPanel2.add(label, null);
- jPanel2.add(applyButton, null);
- jPanel2.add(undoButton, null);
- this.add(southPanel, null);
- southPanel.add(jPanel1, java.awt.BorderLayout.EAST);
- southPanel.add(slider, java.awt.BorderLayout.CENTER);
- jPanel1.add(valueField, java.awt.BorderLayout.CENTER);
- jPanel1.add(allGroupsCheck, java.awt.BorderLayout.EAST);
+ jPanel1.add(valueField, BorderLayout.CENTER);
+ jPanel1.add(allGroupsCheck, BorderLayout.EAST);
+
+ southPanel.setLayout(new BorderLayout());
+ southPanel.setOpaque(false);
+ southPanel.add(jPanel1, BorderLayout.EAST);
+ southPanel.add(slider, BorderLayout.CENTER);
+ this.add(southPanel);
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action on changing the slider text field value
*/
- protected void valueField_actionPerformed(ActionEvent e)
+ protected void valueField_actionPerformed()
{
+ try
+ {
+ int i = Integer.valueOf(valueField.getText());
+ slider.setValue(i);
+ } catch (NumberFormatException ex)
+ {
+ valueField.setText(String.valueOf(slider.getValue()));
+ }
}
/**
@@ -190,16 +218,6 @@ public class GSliderPanel extends JPanel
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- protected void allGroupsCheck_actionPerformed(ActionEvent e)
- {
- }
-
public void slider_mouseReleased(MouseEvent e)
{