JAL-3113 override minimum frame size in a way that works in JalviewJS
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 11 Sep 2018 16:37:30 +0000 (17:37 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 11 Sep 2018 16:37:30 +0000 (17:37 +0100)
src/jalview/gui/Finder.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/SliderPanel.java
src/jalview/jbgui/GSliderPanel.java

index 0d35add..2bad006 100755 (executable)
@@ -28,7 +28,6 @@ import jalview.jbgui.GFinder;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 
-import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.util.ArrayList;
@@ -112,8 +111,7 @@ public class Finder extends GFinder
             });
     addEscapeHandler();
     Desktop.addInternalFrame(frame, MessageManager.getString("label.find"),
-            MY_WIDTH, MY_HEIGHT);
-    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
+            true, MY_WIDTH, MY_HEIGHT, true, true);
     searchBox.getComponent().requestFocus();
   }
 
index c4390c0..6ed3248 100755 (executable)
@@ -104,7 +104,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
     Desktop.addInternalFrame(frame,
             MessageManager
                     .getString("label.redundancy_threshold_selection"),
-            400, 100, false);
+            true, FRAME_WIDTH, FRAME_HEIGHT, false, true);
     frame.addInternalFrameListener(new InternalFrameAdapter()
     {
       @Override
@@ -214,7 +214,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
   @Override
   public void applyButton_actionPerformed(ActionEvent e)
   {
-    Vector del = new Vector();
+    List<SequenceI> del = new ArrayList<>();
 
     undoButton.setEnabled(true);
 
@@ -225,13 +225,12 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
     {
       if (value <= redundancy[i])
       {
-        del.addElement(originalSequences[i]);
+        del.add(originalSequences[i]);
       }
     }
 
     // This has to be done before the restoreHistoryItem method of alignFrame
-    // will
-    // actually restore these sequences.
+    // will actually restore these sequences.
     if (del.size() > 0)
     {
       SequenceI[] deleted = new SequenceI[del.size()];
@@ -239,7 +238,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
       int width = 0;
       for (int i = 0; i < del.size(); i++)
       {
-        deleted[i] = (SequenceI) del.elementAt(i);
+        deleted[i] = del.get(i);
         if (deleted[i].getLength() > width)
         {
           width = deleted[i].getLength();
index 93a2457..e2bb7ab 100755 (executable)
@@ -117,7 +117,7 @@ public class SliderPanel extends GSliderPanel
       @Override
       public void stateChanged(ChangeEvent evt)
       {
-        valueField.setText(slider.getValue() + "");
+        valueField.setText(String.valueOf(slider.getValue()));
         valueChanged(slider.getValue());
       }
     });
@@ -132,7 +132,7 @@ public class SliderPanel extends GSliderPanel
     });
 
     slider.setValue(value);
-    valueField.setText(value + "");
+    valueField.setText(String.valueOf(value));
   }
 
   /**
@@ -230,7 +230,8 @@ public class SliderPanel extends GSliderPanel
     if (!conservationSlider.isVisible())
     {
       Desktop.addInternalFrame(conservationSlider,
-              conservationSlider.getTitle(), 420, 90, false);
+              conservationSlider.getTitle(), true, FRAME_WIDTH,
+              FRAME_HEIGHT, false, true);
       conservationSlider.addInternalFrameListener(new InternalFrameAdapter()
       {
         @Override
@@ -305,8 +306,8 @@ public class SliderPanel extends GSliderPanel
 
     if (!PIDSlider.isVisible())
     {
-      Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90,
-              false);
+      Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), true,
+              FRAME_WIDTH, FRAME_HEIGHT, false, true);
       PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
       PIDSlider.addInternalFrameListener(new InternalFrameAdapter()
       {
index 356c294..d841be5 100755 (executable)
@@ -26,6 +26,7 @@ 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;
@@ -50,6 +51,12 @@ import javax.swing.SwingConstants;
  */
 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();
 
@@ -59,24 +66,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.
    */
@@ -92,19 +87,15 @@ 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()
     {
@@ -114,7 +105,7 @@ public class GSliderPanel extends JPanel
         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("");
@@ -135,17 +126,15 @@ public class GSliderPanel extends JPanel
         valueField_actionPerformed();
       }
     });
-    label.setFont(new java.awt.Font("Verdana", 0, 11));
+    label.setFont(VERDANA_11);
     label.setOpaque(false);
     label.setHorizontalAlignment(SwingConstants.CENTER);
     label.setText(MessageManager.getString("label.set_this_label_text"));
-    southPanel.setLayout(borderLayout1);
-    gridLayout1.setRows(2);
-    jPanel2.setLayout(flowLayout1);
-    applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
+
+    applyButton.setFont(VERDANA_11);
     applyButton.setOpaque(false);
     applyButton.setText(MessageManager.getString("action.apply"));
-    applyButton.addActionListener(new java.awt.event.ActionListener()
+    applyButton.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -154,10 +143,10 @@ public class GSliderPanel extends JPanel
       }
     });
     undoButton.setEnabled(false);
-    undoButton.setFont(new java.awt.Font("Verdana", 0, 11));
+    undoButton.setFont(VERDANA_11);
     undoButton.setOpaque(false);
     undoButton.setText(MessageManager.getString("action.undo"));
-    undoButton.addActionListener(new java.awt.event.ActionListener()
+    undoButton.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -166,33 +155,31 @@ public class GSliderPanel extends JPanel
       }
     });
     allGroupsCheck.setEnabled(false);
-    allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11));
+    allGroupsCheck.setFont(VERDANA_11);
     allGroupsCheck.setOpaque(false);
     allGroupsCheck
             .setText(MessageManager.getString("action.apply_all_groups"));
-    allGroupsCheck.addActionListener(new java.awt.event.ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        allGroupsCheck_actionPerformed(e);
-      }
-    });
+
+    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);
   }
 
   /**
@@ -230,16 +217,6 @@ public class GSliderPanel extends JPanel
   {
   }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  protected void allGroupsCheck_actionPerformed(ActionEvent e)
-  {
-  }
-
   public void slider_mouseReleased(MouseEvent e)
   {