X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSliderPanel.java;h=9154aa03bdf685982c7c2cab1fcc804ca11bf018;hb=ba61fc7a3397ce6b57640e0b19c76392a983768a;hp=9335e2f8163f21ec456ba711854cc08777f9fb2a;hpb=8e1be43e250107a4d86898bd554cf03098fa5957;p=jalview.git diff --git a/src/jalview/appletgui/SliderPanel.java b/src/jalview/appletgui/SliderPanel.java index 9335e2f..9154aa0 100644 --- a/src/jalview/appletgui/SliderPanel.java +++ b/src/jalview/appletgui/SliderPanel.java @@ -21,7 +21,7 @@ package jalview.appletgui; import jalview.datamodel.SequenceGroup; -import jalview.schemes.CollectionColourSchemeI; +import jalview.renderer.ResidueShaderI; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -38,6 +38,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.WindowAdapter; @@ -47,39 +49,39 @@ import java.util.Iterator; public class SliderPanel extends Panel implements ActionListener, AdjustmentListener, MouseListener { + private static final String BACKGROUND = "Background"; + AlignmentPanel ap; boolean forConservation = true; - CollectionColourSchemeI cs; + ResidueShaderI cs; static Frame conservationSlider; static Frame PIDSlider; public static int setConservationSlider(AlignmentPanel ap, - CollectionColourSchemeI collectionColourSchemeI, String source) + ResidueShaderI ccs, String source) { SliderPanel sp = null; if (conservationSlider == null) { - sp = new SliderPanel(ap, - collectionColourSchemeI.getConservationInc(), true, - collectionColourSchemeI); + sp = new SliderPanel(ap, ccs.getConservationInc(), true, ccs); conservationSlider = new Frame(); conservationSlider.add(sp); } else { sp = (SliderPanel) conservationSlider.getComponent(0); - sp.cs = collectionColourSchemeI; + sp.cs = ccs; + sp.valueField.setText(String.valueOf(ccs.getConservationInc())); } - conservationSlider - .setTitle(MessageManager.formatMessage( - "label.conservation_colour_increment", - new String[] { source })); + conservationSlider.setTitle(MessageManager.formatMessage( + "label.conservation_colour_increment", + new String[] { source == null ? BACKGROUND : source })); if (ap.av.getAlignment().getGroups() != null) { sp.setAllGroupsCheckEnabled(true); @@ -120,24 +122,24 @@ public class SliderPanel extends Panel implements ActionListener, } public static int setPIDSliderSource(AlignmentPanel ap, - CollectionColourSchemeI collectionColourSchemeI, String source) + ResidueShaderI ccs, String source) { SliderPanel pid = null; if (PIDSlider == null) { - pid = new SliderPanel(ap, 50, false, collectionColourSchemeI); + pid = new SliderPanel(ap, ccs.getThreshold(), false, ccs); PIDSlider = new Frame(); PIDSlider.add(pid); } else { pid = (SliderPanel) PIDSlider.getComponent(0); - pid.cs = collectionColourSchemeI; + pid.cs = ccs; + pid.valueField.setText(String.valueOf(ccs.getThreshold())); } - PIDSlider - .setTitle(MessageManager.formatMessage( - "label.percentage_identity_threshold", - new String[] { source })); + PIDSlider.setTitle(MessageManager.formatMessage( + "label.percentage_identity_threshold", + new String[] { source == null ? BACKGROUND : source })); if (ap.av.getAlignment().getGroups() != null) { @@ -178,8 +180,31 @@ public class SliderPanel extends Panel implements ActionListener, } + /** + * Hides the PID slider panel if it is shown + */ + public static void hidePIDSlider() + { + if (PIDSlider != null) + { + PIDSlider.setVisible(false); + PIDSlider = null; + } + } + + /** + * Hides the Conservation slider panel if it is shown + */ + public static void hideConservationSlider() + { + if (conservationSlider != null) + { + conservationSlider.setVisible(false); + conservationSlider = null; + } + } public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, - CollectionColourSchemeI collectionColourSchemeI) + ResidueShaderI shader) { try { @@ -189,7 +214,7 @@ public class SliderPanel extends Panel implements ActionListener, e.printStackTrace(); } this.ap = ap; - this.cs = collectionColourSchemeI; + this.cs = shader; forConservation = forConserve; undoButton.setVisible(false); applyButton.setVisible(false); @@ -204,7 +229,7 @@ public class SliderPanel extends Panel implements ActionListener, else { label.setText(MessageManager - .getString("label.colour_residues_above_occurence")); + .getString("label.colour_residues_above_occurrence")); slider.setMinimum(0); slider.setMaximum(100 + slider.getVisibleAmount()); slider.setBlockIncrement(1); @@ -224,7 +249,7 @@ public class SliderPanel extends Panel implements ActionListener, return; } - CollectionColourSchemeI toChange = cs; + ResidueShaderI toChange = cs; Iterator allGroups = null; if (allGroupsCheck.getState()) @@ -293,11 +318,11 @@ public class SliderPanel extends Panel implements ActionListener, { try { - int i = Integer.parseInt(valueField.getText()); + int i = Integer.valueOf(valueField.getText()); slider.setValue(i); - } catch (Exception ex) + } catch (NumberFormatException ex) { - valueField.setText(slider.getValue() + ""); + valueField.setText(String.valueOf(slider.getValue())); } } @@ -350,6 +375,16 @@ public class SliderPanel extends Panel implements ActionListener, valueField.setText(" "); valueField.addActionListener(this); valueField.setColumns(3); + valueField.addFocusListener(new FocusAdapter() + { + @Override + public void focusLost(FocusEvent e) + { + valueField_actionPerformed(); + valueChanged(slider.getValue()); + } + }); + label.setFont(new java.awt.Font("Verdana", 0, 11)); label.setText(MessageManager.getString("label.set_this_label_text")); jPanel1.setLayout(borderLayout1);