+ * enable calculations applicable for the current alignment or selection.
+ */
+ protected void validateCalcTypes()
+ {
+ int size = af.getViewport().getAlignment().getHeight();
+ if (af.getViewport().getSelectionGroup() != null)
+ {
+ size = af.getViewport().getSelectionGroup().getSize();
+ }
+
+ /*
+ * disable calc options for which there is insufficient input data
+ * return value of true means enabled and selected
+ */
+ boolean checkPca = checkEnabled(pca, size, MIN_PCA_SELECTION);
+ boolean checkNeighbourJoining = checkEnabled(neighbourJoining, size,
+ MIN_TREE_SELECTION);
+ boolean checkAverageDistance = checkEnabled(averageDistance, size,
+ MIN_TREE_SELECTION);
+
+ if (checkPca || checkNeighbourJoining || checkAverageDistance)
+ {
+ calculate.setToolTipText(null);
+ calculate.setEnabled(true);
+ }
+ else
+ {
+ calculate.setEnabled(false);
+ }
+ updateScoreModels(modelNames, tips);
+ }
+
+ /**
+ * Check the input and disable a calculation's radio button if necessary. A
+ * tooltip is shown for disabled calculations.
+ *
+ * @param calc
+ * - radio button for the calculation being validated
+ * @param size
+ * - size of input to calculation
+ * @param minsize
+ * - minimum size for calculation
+ * @return true if size >= minsize and calc.isSelected
+ */
+ private boolean checkEnabled(JRadioButton calc, int size, int minsize)
+ {
+ String ttip = MessageManager
+ .formatMessage("label.you_need_at_least_n_sequences", minsize);
+
+ calc.setEnabled(size >= minsize);
+ if (!calc.isEnabled())
+ {
+ calc.setToolTipText(ttip);
+ }
+ else
+ {
+ calc.setToolTipText(null);
+ }
+ if (calc.isSelected())
+ {
+ modelNames.setEnabled(calc.isEnabled());
+ if (calc.isEnabled())
+ {
+ return true;
+ }
+ else
+ {
+ calculate.setToolTipText(ttip);
+ }
+ }
+ return false;
+ }
+
+ /**