import jalview.analysis.AlignmentSorter;
import jalview.analysis.NJTree;
import jalview.analysis.scoremodels.ScoreModels;
-import jalview.api.analysis.DistanceModelI;
+import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.ViewBasedAnalysisI;
import jalview.bin.Cache;
import jalview.commands.CommandI;
seqs = av.getSelectionGroup().getSequencesInOrder(
av.getAlignment());
}
- DistanceModelI sm = ScoreModels.getInstance().forName(pwtype);
- if (sm instanceof ViewBasedAnalysisI)
- {
- try
- {
- sm = sm.getClass().newInstance();
- ((ViewBasedAnalysisI) sm)
- .configureFromAlignmentView(treeCanvas.ap);
- } catch (Exception q)
- {
- Cache.log.error("Couldn't create a scoremodel instance for "
- + sm.getName());
- }
- tree = new NJTree(seqs, seqStrings, type, pwtype, sm, start, end);
- }
- else
- {
- tree = new NJTree(seqs, seqStrings, type, pwtype, null, start,
- end);
- }
+ ScoreModelI sm = ScoreModels.getInstance().forName(pwtype);
+ sm = configureScoreModel(sm);
+ tree = new NJTree(seqs, seqStrings, type, pwtype, sm, start, end);
showDistances(true);
}
treecalcnm, smn);
return ttl;
}
+
+ /**
+ * If the score model is one that requires to get state data from the current
+ * view, allow it to do so
+ *
+ * @param sm
+ * @return
+ */
+ protected ScoreModelI configureScoreModel(ScoreModelI sm)
+ {
+ if (sm instanceof ViewBasedAnalysisI)
+ {
+ try
+ {
+ sm = sm.getClass().newInstance();
+ ((ViewBasedAnalysisI) sm).configureFromAlignmentView(treeCanvas.ap);
+ } catch (Exception q)
+ {
+ Cache.log.error("Couldn't create a scoremodel instance for "
+ + sm.getName());
+ }
+ }
+ return sm;
+ }
}