From: Jim Procter Date: Wed, 18 Feb 2015 11:14:26 +0000 (+0000) Subject: JAL-1482 JAL-653 refactor feature file import code to alignview controller X-Git-Tag: Release_2_10_0~296^2~173 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7ba92fd0e87b8155e656cfb9562d024a2524086d;p=jalview.git JAL-1482 JAL-653 refactor feature file import code to alignview controller --- diff --git a/src/jalview/api/AlignViewControllerGuiI.java b/src/jalview/api/AlignViewControllerGuiI.java index f768451..4896b35 100644 --- a/src/jalview/api/AlignViewControllerGuiI.java +++ b/src/jalview/api/AlignViewControllerGuiI.java @@ -47,4 +47,19 @@ public interface AlignViewControllerGuiI void setMenusForViewport(); void changeColour(ColourSchemeI cs); + + /** + * trigger an update of the UI in response to a model data change, and if + * necessary enable the display of sequence feature annotation on the view. + * + * @param enableIfNecessary + */ + void refreshFeatureUI(boolean enableIfNecessary); + + /** + * get the Feature Settings control panel for the alignment view if one exists + * + * @return + */ + FeatureSettingsControllerI getFeatureSettingsUI(); } diff --git a/src/jalview/api/AlignViewControllerI.java b/src/jalview/api/AlignViewControllerI.java index 235a656..fef9f14 100644 --- a/src/jalview/api/AlignViewControllerI.java +++ b/src/jalview/api/AlignViewControllerI.java @@ -76,4 +76,17 @@ public interface AlignViewControllerI */ void sortAlignmentByFeatureDensity(String[] typ); + /** + * add a features file of some kind to the current view + * + * @param file + * @param protocol + * @param relaxedIdMatching + * if true, try harder to match up IDs with local sequence data + * @return true if parsing resulted in something being imported to the view or + * dataset + */ + public boolean parseFeaturesFile(String file, String protocol, + boolean relaxedIdMatching); + } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 478aa09..77747d1 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -26,6 +26,7 @@ import jalview.api.AlignViewControllerGuiI; import jalview.api.AlignViewControllerI; import jalview.api.AlignViewportI; import jalview.api.FeatureRenderer; +import jalview.api.FeatureSettingsControllerI; import jalview.api.SequenceStructureBinding; import jalview.bin.JalviewLite; import jalview.commands.CommandI; @@ -4178,7 +4179,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { this.splitFrame = sf; } - + // may not need this @Override public void setShowSeqFeatures(boolean b) { @@ -4193,4 +4194,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // setMenusFromViewport(viewport); } + @Override + public void refreshFeatureUI(boolean enableIfNecessary) + { + if (enableIfNecessary) + { + sequenceFeatures.setState(true); + alignPanel.av.setShowSequenceFeatures(true); + } + } + + @Override + public FeatureSettingsControllerI getFeatureSettingsUI() + { + return alignPanel.av.featureSettings; + } + } diff --git a/src/jalview/controller/AlignViewController.java b/src/jalview/controller/AlignViewController.java index 972b6ab..3be32bb 100644 --- a/src/jalview/controller/AlignViewController.java +++ b/src/jalview/controller/AlignViewController.java @@ -33,6 +33,7 @@ import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.io.FeaturesFile; import jalview.util.MessageManager; import java.awt.Color; @@ -379,4 +380,38 @@ public class AlignViewController implements AlignViewControllerI { sortBy(typ, "Sort by Feature Score", AlignmentSorter.FEATURE_SCORE); } + + @Override + public boolean parseFeaturesFile(String file, String protocol, + boolean relaxedIdMatching) + { + boolean featuresFile = false; + try + { + featuresFile = new FeaturesFile(file, protocol).parse(viewport + .getAlignment().getDataset(), alignPanel.getFeatureRenderer() + .getFeatureColours(), false, relaxedIdMatching); + } catch (Exception ex) + { + ex.printStackTrace(); + } + + if (featuresFile) + { + avcg.refreshFeatureUI(true); + if (alignPanel.getFeatureRenderer() != null) + { + // update the min/max ranges where necessary + alignPanel.getFeatureRenderer().findAllFeatures(true); + } + if (avcg.getFeatureSettingsUI() != null) + { + avcg.getFeatureSettingsUI().discoverAllFeatureData(); + } + alignPanel.paintAlignment(true); + } + + return featuresFile; + + } } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 553ddd2..90b9f6a 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -32,7 +32,6 @@ import jalview.api.AlignViewControllerGuiI; import jalview.api.AlignViewControllerI; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; -import jalview.api.SplitContainerI; import jalview.api.ViewStyleI; import jalview.api.analysis.ScoreModelI; import jalview.bin.Cache; @@ -60,7 +59,6 @@ import jalview.gui.ViewSelectionMenu.ViewSetProvider; import jalview.io.AlignmentProperties; import jalview.io.AnnotationFile; import jalview.io.BioJsHTMLOutput; -import jalview.io.FeaturesFile; import jalview.io.FileLoader; import jalview.io.FormatAdapter; import jalview.io.HtmlSvgOutput; @@ -3067,6 +3065,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public FeatureSettings featureSettings; @Override + public FeatureSettingsControllerI getFeatureSettingsUI() + { + return featureSettings; + } + + @Override public void featureSettings_actionPerformed(ActionEvent e) { if (featureSettings != null) @@ -4916,41 +4920,29 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * contents or path to retrieve file * @param type * access mode of file (see jalview.io.AlignFile) - * @return true if features file was parsed corectly. + * @return true if features file was parsed correctly. */ public boolean parseFeaturesFile(String file, String type) { - boolean featuresFile = false; - try - { - featuresFile = new FeaturesFile(file, type).parse(viewport - .getAlignment().getDataset(), alignPanel.getSeqPanel().seqCanvas - .getFeatureRenderer().getFeatureColours(), false, - jalview.bin.Cache.getDefault("RELAXEDSEQIDMATCHING", false)); - } catch (Exception ex) - { - ex.printStackTrace(); - } + return avc.parseFeaturesFile(file, type, + jalview.bin.Cache.getDefault("RELAXEDSEQIDMATCHING", false)); + + } - if (featuresFile) + @Override + public void refreshFeatureUI(boolean enableIfNecessary) + { + // note - currently this is only still here rather than in the controller + // because of the featureSettings hard reference that is yet to be + // abstracted + if (enableIfNecessary) { viewport.setShowSequenceFeatures(true); showSeqFeatures.setSelected(true); - if (alignPanel.getSeqPanel().seqCanvas.fr != null) - { - // update the min/max ranges where necessary - alignPanel.getSeqPanel().seqCanvas.fr.findAllFeatures(true); - } - if (featureSettings != null) - { - featureSettings.setTableData(); - } - alignPanel.paintAlignment(true); } - return featuresFile; - } + } @Override public void dragEnter(DropTargetDragEvent evt) { diff --git a/src/jalview/viewmodel/seqfeatures/FeatureSettingsModel.java b/src/jalview/viewmodel/seqfeatures/FeatureSettingsModel.java index 57d57da..15d1da7 100644 --- a/src/jalview/viewmodel/seqfeatures/FeatureSettingsModel.java +++ b/src/jalview/viewmodel/seqfeatures/FeatureSettingsModel.java @@ -2,7 +2,7 @@ package jalview.viewmodel.seqfeatures; import jalview.api.FeatureSettingsModelI; -public class FeatureSettingsModel implements FeatureSettingsModelI +public abstract class FeatureSettingsModel implements FeatureSettingsModelI { }