package jalview.gui;
import jalview.analysis.NJTree;
+import jalview.analysis.scoremodels.ScoreMatrix;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.api.analysis.DistanceScoreModelI;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
import jalview.util.MessageManager;
JRadioButton averageDistance;
- JComboBox<String> matrixNames;
+ JComboBox<String> modelNames;
private JInternalFrame frame;
/*
* score model drop-down
*/
- matrixNames = new JComboBox<String>();
+ modelNames = new JComboBox<String>();
ScoreModels scoreModels = ScoreModels.getInstance();
for (ScoreModelI sm : scoreModels.getModels())
{
boolean nucleotide = af.getViewport().getAlignment().isNucleotide();
if (sm.isDNA() && nucleotide || sm.isProtein() && !nucleotide)
{
- matrixNames.addItem(sm.getName());
+ modelNames.addItem(sm.getName());
}
}
+ modelNames.addItemListener(new ItemListener()
+ {
+
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (e.getStateChange() == ItemEvent.SELECTED)
+ {
+ scoreModelChanged((String) e.getItem());
+ }
+ }
+ });
JPanel scoreModelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
scoreModelPanel.setOpaque(false);
- scoreModelPanel.add(matrixNames, FlowLayout.LEFT);
+ scoreModelPanel.add(modelNames, FlowLayout.LEFT);
/*
* score model parameters
paramsPanel.add(matchGaps);
paramsPanel.add(includeGappedColumns);
paramsPanel.add(shorterSequence);
+ // configure initial state of options
+ scoreModelChanged(modelNames.getItemAt(0));
/*
* OK / Cancel buttons
}
/**
+ * Action on selection of score model
+ *
+ * @param item
+ */
+ protected void scoreModelChanged(String modelName)
+ {
+ /*
+ * enable/disable options appropriate to score model
+ * NB this is temporary - will get score models to provide
+ * their own parameters
+ */
+ includeGaps.setEnabled(true);
+ matchGaps.setEnabled(true);
+ includeGappedColumns.setEnabled(true);
+ shorterSequence.setEnabled(true);
+
+ ScoreModelI sm = ScoreModels.getInstance().forName(modelName);
+ if (sm instanceof DistanceScoreModelI)
+ {
+ matchGaps.setEnabled(false);
+ includeGappedColumns.setEnabled(false);
+ shorterSequence.setEnabled(false);
+ }
+ if (sm instanceof ScoreMatrix)
+ {
+ matchGaps.setEnabled(false);
+ }
+ }
+
+ /**
* Open and calculate the selected tree on 'OK'
*
* @param e
protected void ok_actionPerformed(ActionEvent e)
{
ScoreModelI sm = ScoreModels.getInstance().forName(
- matrixNames.getSelectedItem().toString());
+ modelNames.getSelectedItem().toString());
SimilarityParamsI params = getSimilarityParameters();
if (pca.isSelected())