From: gmungoc Date: Mon, 27 Mar 2017 10:48:49 +0000 (+0100) Subject: JAL-2416 add score model description field for tooltip in PCA panel X-Git-Tag: Release_2_10_2~3^2~105^2~2^2~49 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5c45059a31d5f2ed14a8898d700ead9b3431bccf;p=jalview.git JAL-2416 add score model description field for tooltip in PCA panel --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 0e30064..6ca43b0 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -177,6 +177,8 @@ label.select_score_model = Select score model label.score_model_pid = % Identity label.score_model_blosum62 = BLOSUM62 label.score_model_pam250 = PAM 250 +label.score_model_smithwatermanscore = Score between two sequences aligned with Smith-Waterman with default Peptide/Nucleotide matrix +label.score_model_sequencefeaturesimilarity = Distance measure of average number of features not shared at sequence positions label.score_model_conservation = Physicochemical property conservation label.score_model_enhconservation = Physicochemical property conservation label.status_bar = Status bar diff --git a/src/jalview/analysis/scoremodels/FeatureDistanceModel.java b/src/jalview/analysis/scoremodels/FeatureDistanceModel.java index b44b4cf..5bf4b11 100644 --- a/src/jalview/analysis/scoremodels/FeatureDistanceModel.java +++ b/src/jalview/analysis/scoremodels/FeatureDistanceModel.java @@ -41,8 +41,19 @@ import java.util.Set; public class FeatureDistanceModel implements DistanceScoreModelI, ViewBasedAnalysisI { + private static final String NAME = "Sequence Feature Similarity"; + + private String description; + FeatureRenderer fr; + /** + * Constructor + */ + public FeatureDistanceModel() + { + } + @Override public boolean configureFromAlignmentView(AlignmentViewPanel view) @@ -183,7 +194,13 @@ public class FeatureDistanceModel implements DistanceScoreModelI, @Override public String getName() { - return "Sequence Feature Similarity"; + return NAME; + } + + @Override + public String getDescription() + { + return description; } @Override diff --git a/src/jalview/analysis/scoremodels/PIDModel.java b/src/jalview/analysis/scoremodels/PIDModel.java index a3358aa..3e940af 100644 --- a/src/jalview/analysis/scoremodels/PIDModel.java +++ b/src/jalview/analysis/scoremodels/PIDModel.java @@ -14,11 +14,27 @@ import jalview.util.Comparison; public class PIDModel implements SimilarityScoreModelI, PairwiseScoreModelI { + private static final String NAME = "PID"; + + private String description; + + /** + * Constructor + */ + public PIDModel() + { + } @Override public String getName() { - return "% Identity (PID)"; + return NAME; + } + + @Override + public String getDescription() + { + return description; } @Override diff --git a/src/jalview/analysis/scoremodels/ScoreMatrix.java b/src/jalview/analysis/scoremodels/ScoreMatrix.java index 6a74dfc..b73f826 100644 --- a/src/jalview/analysis/scoremodels/ScoreMatrix.java +++ b/src/jalview/analysis/scoremodels/ScoreMatrix.java @@ -51,10 +51,16 @@ public class ScoreMatrix implements SimilarityScoreModelI, /* * the name of the model as shown in menus + * each score model in use should have a unique name */ private String name; /* + * a description for the model as shown in tooltips + */ + private String description; + + /* * the characters that the model provides scores for */ private char[] symbols; @@ -165,6 +171,12 @@ public class ScoreMatrix implements SimilarityScoreModelI, } @Override + public String getDescription() + { + return description; + } + + @Override public boolean isDNA() { return !peptide; @@ -487,4 +499,9 @@ public class ScoreMatrix implements SimilarityScoreModelI, { return new String(symbols); } + + public void setDescription(String desc) + { + description = desc; + } } diff --git a/src/jalview/analysis/scoremodels/SmithWatermanModel.java b/src/jalview/analysis/scoremodels/SmithWatermanModel.java index eec08ed..190b88f 100644 --- a/src/jalview/analysis/scoremodels/SmithWatermanModel.java +++ b/src/jalview/analysis/scoremodels/SmithWatermanModel.java @@ -37,6 +37,15 @@ public class SmithWatermanModel implements SimilarityScoreModelI { private static final String NAME = "Smith Waterman Score"; + private String description; + + /** + * Constructor + */ + public SmithWatermanModel() + { + } + @Override public MatrixI findSimilarities(AlignmentView seqData, SimilarityParamsI options) @@ -88,8 +97,8 @@ public class SmithWatermanModel implements SimilarityScoreModelI } @Override - public String toString() + public String getDescription() { - return "Score between two sequences aligned with Smith Waterman with default Peptide/Nucleotide matrix"; + return description; } } diff --git a/src/jalview/api/analysis/ScoreModelI.java b/src/jalview/api/analysis/ScoreModelI.java index 4433cea..7352a71 100644 --- a/src/jalview/api/analysis/ScoreModelI.java +++ b/src/jalview/api/analysis/ScoreModelI.java @@ -12,6 +12,15 @@ public interface ScoreModelI String getName(); /** + * Answers an informative description of the model, suitable for use in + * tooltips. Descriptions may be internationalised, and need not be unique + * (but should be). + * + * @return + */ + String getDescription(); + + /** * Answers true if this model is applicable for nucleotide data (so should be * shown in menus in that context) * diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 3b73c5a..885c3bf 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -195,10 +195,19 @@ public class PCAPanel extends GPCAPanel implements Runnable, for (final ScoreModelI sm : ScoreModels.getInstance().getModels()) { final String name = sm.getName(); - // create an entry for this score matrix for use in PCA - JCheckBoxMenuItem jm = new JCheckBoxMenuItem(); - jm.setText(MessageManager.getStringOrReturn("label.score_model_", - name)); + JCheckBoxMenuItem jm = new JCheckBoxMenuItem(name); + + /* + * if the score model doesn't provide a description, try to look one + * up in the text bundle, falling back on its name + */ + String tooltip = sm.getDescription(); + if (tooltip == null) + { + tooltip = MessageManager.getStringOrReturn("label.score_model_", + name); + } + jm.setToolTipText(tooltip); jm.setSelected(pcaModel.getScoreModelName().equals(name)); if ((pcaModel.isNucleotide() && sm.isDNA()) || (!pcaModel.isNucleotide() && sm.isProtein())) diff --git a/test/jalview/analysis/scoremodels/ScoreModelsTest.java b/test/jalview/analysis/scoremodels/ScoreModelsTest.java index 8265cd8..03513f1 100644 --- a/test/jalview/analysis/scoremodels/ScoreModelsTest.java +++ b/test/jalview/analysis/scoremodels/ScoreModelsTest.java @@ -47,7 +47,7 @@ public class ScoreModelsTest assertTrue(sm instanceof SimilarityScoreModelI); assertTrue(sm instanceof PairwiseScoreModelI); assertFalse(sm instanceof DistanceScoreModelI); - assertEquals(sm.getName(), "% Identity (PID)"); + assertEquals(sm.getName(), "PID"); assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'C'), 0f); assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'r'), 1f);