From 28c2ec20b26a85cc5634238f1261a14930550594 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 15 Mar 2016 14:49:13 +0000 Subject: [PATCH] JAL-2016 FeatureSettingsI now FeatureSettingsModelI --- src/jalview/api/FeatureSettingsI.java | 69 ---------------------- src/jalview/api/FeatureSettingsModelI.java | 66 ++++++++++++++++++++- src/jalview/ext/ensembl/EnsemblGene.java | 14 ++++- src/jalview/gui/AlignFrame.java | 6 +- src/jalview/gui/AlignViewport.java | 6 +- src/jalview/gui/SequenceFetcher.java | 10 ++-- src/jalview/schemes/FeatureSettingsAdapter.java | 4 +- src/jalview/ws/seqfetcher/DbSourceProxy.java | 4 +- src/jalview/ws/seqfetcher/DbSourceProxyImpl.java | 4 +- 9 files changed, 94 insertions(+), 89 deletions(-) delete mode 100644 src/jalview/api/FeatureSettingsI.java diff --git a/src/jalview/api/FeatureSettingsI.java b/src/jalview/api/FeatureSettingsI.java deleted file mode 100644 index ddb5edc..0000000 --- a/src/jalview/api/FeatureSettingsI.java +++ /dev/null @@ -1,69 +0,0 @@ -package jalview.api; - -import java.util.Comparator; - -/** - * An interface that describes the settings configurable in the Feature Settings - * dialog. - * - * @author gmcarstairs - * - */ -public interface FeatureSettingsI extends Comparator -{ - // note Java 8 will allow default implementations of these methods in the - // interface, simplifying instantiating classes - - /** - * Answers true if the specified feature type is displayed - * - * @param type - * @return - */ - boolean isFeatureDisplayed(String type); - - /** - * Answers true if the specified feature group is displayed - * - * @param group - * @return - */ - boolean isGroupDisplayed(String group); - - /** - * Returns the colour (or graduated colour) for the feature type, or null if - * not known - * - * @param type - * @return - */ - FeatureColourI getFeatureColour(String type); - - /** - * Returns the transparency value, from 0 (fully transparent) to 1 (fully - * opaque) - * - * @return - */ - float getTransparency(); - - /** - * Returns -1 if feature1 'precedes' (is displayed on top of) feature 2, +1 if - * feature2 is on top of feature1, or 0 if we don't care - * - * @param feature1 - * @param feature2 - * @return - */ - @Override - int compare(String feature1, String feature2); - - /** - * Answers true if features should be initially sorted so that features with a - * shorter average length are displayed on top of those with a longer average - * length - * - * @return - */ - boolean optimiseOrder(); -} diff --git a/src/jalview/api/FeatureSettingsModelI.java b/src/jalview/api/FeatureSettingsModelI.java index 5474f4e..28f5c77 100644 --- a/src/jalview/api/FeatureSettingsModelI.java +++ b/src/jalview/api/FeatureSettingsModelI.java @@ -20,7 +20,71 @@ */ package jalview.api; -public interface FeatureSettingsModelI +import java.util.Comparator; + +/** + * An interface that describes the settings configurable in the Feature Settings + * dialog. + * + * @author gmcarstairs + */ +public interface FeatureSettingsModelI extends Comparator { + // note Java 8 will allow default implementations of these methods in the + // interface, simplifying instantiating classes + + /** + * Answers true if the specified feature type is displayed + * + * @param type + * @return + */ + boolean isFeatureDisplayed(String type); + + /** + * Answers true if the specified feature group is displayed + * + * @param group + * @return + */ + boolean isGroupDisplayed(String group); + + /** + * Returns the colour (or graduated colour) for the feature type, or null if + * not known + * + * @param type + * @return + */ + FeatureColourI getFeatureColour(String type); + + /** + * Returns the transparency value, from 0 (fully transparent) to 1 (fully + * opaque) + * + * @return + */ + float getTransparency(); + + /** + * Returns -1 if feature1 'precedes' (is displayed on top of) feature 2, +1 if + * feature2 is on top of feature1, or 0 if we don't care + * + * @param feature1 + * @param feature2 + * @return + */ + @Override + int compare(String feature1, String feature2); + + /** + * Answers true if features should be initially sorted so that features with a + * shorter average length are displayed on top of those with a longer average + * length + * + * @return + */ + boolean optimiseOrder(); + } diff --git a/src/jalview/ext/ensembl/EnsemblGene.java b/src/jalview/ext/ensembl/EnsemblGene.java index 0cecc59..fa1e474 100644 --- a/src/jalview/ext/ensembl/EnsemblGene.java +++ b/src/jalview/ext/ensembl/EnsemblGene.java @@ -1,7 +1,7 @@ package jalview.ext.ensembl; import jalview.api.FeatureColourI; -import jalview.api.FeatureSettingsI; +import jalview.api.FeatureSettingsModelI; import jalview.datamodel.AlignmentI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; @@ -489,8 +489,18 @@ public class EnsemblGene extends EnsemblSeqProxy return ACCESSION_REGEX; } + /** + * Returns a descriptor for suitable feature display settings with + *
    + *
  • only exon or sequence_variant features (or their subtypes in the + * Sequence Ontology) visible
  • + *
  • variant features coloured red
  • + *
  • exon features coloured by label (exon name)
  • + *
  • variants displayed above (on top of) exons
  • + *
+ */ @Override - public FeatureSettingsI getFeatureColourScheme() + public FeatureSettingsModelI getFeatureColourScheme() { return new FeatureSettingsAdapter() { diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 0d6efe4..5438ce8 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -32,7 +32,7 @@ import jalview.api.AlignViewControllerI; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.api.FeatureSettingsControllerI; -import jalview.api.FeatureSettingsI; +import jalview.api.FeatureSettingsModelI; import jalview.api.SplitContainerI; import jalview.api.ViewStyleI; import jalview.api.analysis.ScoreModelI; @@ -4737,10 +4737,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ ASequenceFetcher sftch = new SequenceFetcher(); List proxies = sftch.getSourceProxy(source); - FeatureSettingsI featureColourScheme = null; + FeatureSettingsModelI featureColourScheme = null; for (DbSourceProxy proxy : proxies) { - FeatureSettingsI preferredColours = proxy + FeatureSettingsModelI preferredColours = proxy .getFeatureColourScheme(); if (preferredColours != null) { diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index f754eb9..7d8d4fe 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -44,7 +44,7 @@ import jalview.analysis.NJTree; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.api.FeatureColourI; -import jalview.api.FeatureSettingsI; +import jalview.api.FeatureSettingsModelI; import jalview.api.FeaturesDisplayedI; import jalview.api.ViewStyleI; import jalview.bin.Cache; @@ -75,7 +75,6 @@ import java.awt.Rectangle; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import java.util.Map; import java.util.Vector; import javax.swing.JInternalFrame; @@ -1137,7 +1136,7 @@ public class AlignViewport extends AlignmentViewport implements * * @param featureSettings */ - public void applyFeaturesStyle(FeatureSettingsI featureSettings) + public void applyFeaturesStyle(FeatureSettingsModelI featureSettings) { if (featureSettings == null) { @@ -1146,7 +1145,6 @@ public class AlignViewport extends AlignmentViewport implements FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas .getFeatureRenderer(); - Map featureColours = fr.getFeatureColours(); fr.findAllFeatures(true); List renderOrder = fr.getRenderOrder(); FeaturesDisplayedI displayed = fr.getFeaturesDisplayed(); diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index a33fdc3..784474e 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -20,7 +20,7 @@ */ package jalview.gui; -import jalview.api.FeatureSettingsI; +import jalview.api.FeatureSettingsModelI; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.SequenceFeature; @@ -527,7 +527,7 @@ public class SequenceFetcher extends JPanel implements Runnable Iterator en = Arrays.asList(new String[0]).iterator(); int nqueries = qries.length; - FeatureSettingsI preferredFeatureColours = null; + FeatureSettingsModelI preferredFeatureColours = null; while (proxies.hasNext() && (en.hasNext() || nextfetch.size() > 0)) { if (!en.hasNext() && nextfetch.size() > 0) @@ -694,7 +694,8 @@ public class SequenceFetcher extends JPanel implements Runnable // Stack results ready for opening in alignment windows if (aresult != null && aresult.size() > 0) { - FeatureSettingsI proxyColourScheme = proxy.getFeatureColourScheme(); + FeatureSettingsModelI proxyColourScheme = proxy + .getFeatureColourScheme(); if (proxyColourScheme != null) { preferredFeatureColours = proxyColourScheme; @@ -790,7 +791,8 @@ public class SequenceFetcher extends JPanel implements Runnable } AlignmentI parseResult(AlignmentI al, String title, - String currentFileFormat, FeatureSettingsI preferredFeatureColours) + String currentFileFormat, + FeatureSettingsModelI preferredFeatureColours) { if (al != null && al.getHeight() > 0) diff --git a/src/jalview/schemes/FeatureSettingsAdapter.java b/src/jalview/schemes/FeatureSettingsAdapter.java index 52b01ce..699d954 100644 --- a/src/jalview/schemes/FeatureSettingsAdapter.java +++ b/src/jalview/schemes/FeatureSettingsAdapter.java @@ -1,12 +1,12 @@ package jalview.schemes; import jalview.api.FeatureColourI; -import jalview.api.FeatureSettingsI; +import jalview.api.FeatureSettingsModelI; /** * An adapter class that may be extended to instantiate feature colour schemes */ -public class FeatureSettingsAdapter implements FeatureSettingsI +public class FeatureSettingsAdapter implements FeatureSettingsModelI { @Override diff --git a/src/jalview/ws/seqfetcher/DbSourceProxy.java b/src/jalview/ws/seqfetcher/DbSourceProxy.java index 2c6d582..a02ffc9 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxy.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxy.java @@ -20,7 +20,7 @@ */ package jalview.ws.seqfetcher; -import jalview.api.FeatureSettingsI; +import jalview.api.FeatureSettingsModelI; import jalview.datamodel.AlignmentI; import com.stevesoft.pat.Regex; @@ -177,5 +177,5 @@ public interface DbSourceProxy * * @return */ - FeatureSettingsI getFeatureColourScheme(); + FeatureSettingsModelI getFeatureColourScheme(); } \ No newline at end of file diff --git a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java index bdea000..20a1e33 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java @@ -20,7 +20,7 @@ */ package jalview.ws.seqfetcher; -import jalview.api.FeatureSettingsI; +import jalview.api.FeatureSettingsModelI; import jalview.datamodel.AlignmentI; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; @@ -151,7 +151,7 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy } @Override - public FeatureSettingsI getFeatureColourScheme() + public FeatureSettingsModelI getFeatureColourScheme() { return null; } -- 1.7.10.2