2020 */
2121package org .biojava .nbio .structure .align .gui .jmol ;
2222
23+ import java .awt .BorderLayout ;
2324import java .awt .Color ;
2425import java .awt .Container ;
2526import java .awt .Dimension ;
4041import javax .swing .JFrame ;
4142import javax .swing .JLabel ;
4243import javax .swing .JMenuBar ;
44+ import javax .swing .JPanel ;
4345import javax .swing .JTextField ;
4446
4547import org .biojava .nbio .structure .Atom ;
5658import org .biojava .nbio .structure .align .multiple .util .MultipleAlignmentTools ;
5759import org .biojava .nbio .structure .align .multiple .util .MultipleAlignmentWriter ;
5860import org .biojava .nbio .structure .align .webstart .AligUIManager ;
61+ import org .biojava .nbio .structure .gui .WrapLayout ;
5962import org .biojava .nbio .structure .jama .Matrix ;
6063import org .forester .archaeopteryx .Archaeopteryx ;
6164import org .forester .phylogeny .Phylogeny ;
@@ -137,14 +140,13 @@ public void windowClosing(WindowEvent e) {
137140 });
138141
139142 Container contentPane = frame .getContentPane ();
140- Box vBox = Box .createVerticalBox ();
141143
142144 jmolPanel .addMouseMotionListener (this );
143145 jmolPanel .addMouseListener (this );
144- jmolPanel
145- . setPreferredSize ( new Dimension ( DEFAULT_WIDTH , DEFAULT_HEIGHT ) );
146+ jmolPanel . setPreferredSize ( new Dimension ( DEFAULT_WIDTH , DEFAULT_HEIGHT ));
147+ contentPane . add ( jmolPanel , BorderLayout . CENTER );
146148
147- vBox . add ( jmolPanel );
149+ Box vBox = Box . createVerticalBox ( );
148150
149151 // / USER SCRIPTING COMMAND
150152 JTextField field = new JTextField ();
@@ -162,8 +164,10 @@ public void windowClosing(WindowEvent e) {
162164 // / STRUCTURE SELECTION
163165 if (multAln != null ) {
164166
165- Box hBox00 = Box .createHorizontalBox ();
166- hBox00 .setMaximumSize (new Dimension (Short .MAX_VALUE , 30 ));
167+ JPanel modelSelection = new JPanel ();
168+ modelSelection .setLayout (new WrapLayout (WrapLayout .LEFT ));
169+ modelSelection .setSize (new Dimension (DEFAULT_WIDTH ,30 ));
170+ vBox .add (modelSelection );
167171
168172 JButton show = new JButton ("Show Only: " );
169173 show .addActionListener (new ActionListener () {
@@ -184,27 +188,16 @@ public void actionPerformed(ActionEvent e) {
184188 jmolPanel .executeCmd (cmd + " restore selection;" );
185189 }
186190 });
187- hBox00 .add (show );
188- hBox00 .add (Box .createGlue ());
189- vBox .add (hBox00 );
191+ modelSelection .add (show );
190192
191- // A line of structures of maximum 5
192- for (int line = 0 ; line < 1 + (multAln .size () / 5 ); line ++) {
193- Box hBox0 = Box .createHorizontalBox ();
194- hBox0 .setMaximumSize (new Dimension (Short .MAX_VALUE , 30 ));
195-
196- for (int str = line * 5 ; str < Math .min ((line + 1 ) * 5 ,
197- multAln .size ()); str ++) {
198- JCheckBox structureSelection = new JCheckBox (multAln
199- .getEnsemble ().getStructureIdentifiers ().get (str )
200- .getIdentifier ());
201- hBox0 .add (structureSelection );
202- hBox0 .add (Box .createGlue ());
203- structureSelection .setSelected (true );
204- selectedStructures .add (structureSelection );
205- }
206-
207- vBox .add (hBox0 );
193+ // Check boxes for all models
194+ for (int str = 0 ; str < multAln .size ();str ++) {
195+ JCheckBox structureSelection = new JCheckBox (multAln
196+ .getEnsemble ().getStructureIdentifiers ().get (str )
197+ .getIdentifier ());
198+ modelSelection .add (structureSelection );
199+ structureSelection .setSelected (true );
200+ selectedStructures .add (structureSelection );
208201 }
209202 }
210203
@@ -214,35 +207,35 @@ public void actionPerformed(ActionEvent e) {
214207
215208 String [] styles = new String [] { "Cartoon" , "Backbone" , "CPK" ,
216209 "Ball and Stick" , "Ligands" , "Ligands and Pocket" };
217- JComboBox style = new JComboBox (styles );
210+ JComboBox < String > style = new JComboBox <> (styles );
218211
219212 hBox1 .setMaximumSize (new Dimension (Short .MAX_VALUE , 30 ));
220213
221214 hBox1 .add (new JLabel ("Style" ));
222215 hBox1 .add (style );
223216 vBox .add (hBox1 );
224- contentPane .add (vBox );
225217
226218 style .addActionListener (jmolPanel );
227219
228220 String [] colorModes = new String [] { "Secondary Structure" , "By Chain" ,
229221 "Rainbow" , "By Element" , "By Amino Acid" , "Hydrophobicity" ,
230222 "Suggest Domains" , "Show SCOP Domains" };
231- JComboBox jcolors = new JComboBox (colorModes );
223+ JComboBox < String > jcolors = new JComboBox <> (colorModes );
232224 jcolors .addActionListener (jmolPanel );
233225
234226 hBox1 .add (Box .createGlue ());
235227 hBox1 .add (new JLabel ("Color" ));
236228 hBox1 .add (jcolors );
237229
238230 String [] cPalette = { "Spectral" , "Set1" , "Set2" , "Pastel" };
239- JComboBox palette = new JComboBox (cPalette );
231+ JComboBox < String > palette = new JComboBox <> (cPalette );
240232
241233 palette .addActionListener (new ActionListener () {
242234 @ Override
243235 public void actionPerformed (ActionEvent e ) {
244236
245- JComboBox source = (JComboBox ) e .getSource ();
237+ @ SuppressWarnings ("unchecked" )
238+ JComboBox <String > source = (JComboBox <String >) e .getSource ();
246239 String value = source .getSelectedItem ().toString ();
247240 evalString ("save selection; select *; color grey; "
248241 + "select ligand; color CPK;" );
@@ -268,6 +261,7 @@ public void actionPerformed(ActionEvent e) {
268261
269262 // / CHECK BOXES
270263 Box hBox2 = Box .createHorizontalBox ();
264+ hBox2 .setMaximumSize (new Dimension (Short .MAX_VALUE , 30 ));
271265
272266 JButton resetDisplay = new JButton ("Reset Display" );
273267 resetDisplay .addActionListener (new ActionListener () {
@@ -337,7 +331,7 @@ public void itemStateChanged(ItemEvent e) {
337331
338332 vBox .add (hBox );
339333
340- contentPane .add (vBox );
334+ contentPane .add (vBox , BorderLayout . SOUTH );
341335 MyJmolStatusListener li = (MyJmolStatusListener ) jmolPanel
342336 .getStatusListener ();
343337
0 commit comments