X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fcontroller%2FAlignViewController.java;h=cacde84dc4de4e61003941329f901ca10ac57873;hb=58d01bd17f04745e37f69f947a41432fb9e3ec15;hp=69e31cf1491974e07a333a4cb40fdf015afce91c;hpb=106a3890f956e2aa7780b2985f4326655912a558;p=jalview.git diff --git a/src/jalview/controller/AlignViewController.java b/src/jalview/controller/AlignViewController.java index 69e31cf..cacde84 100644 --- a/src/jalview/controller/AlignViewController.java +++ b/src/jalview/controller/AlignViewController.java @@ -52,29 +52,20 @@ public class AlignViewController implements AlignViewControllerI */ private AlignViewControllerGuiI avcg; - @Override - protected void finalize() throws Throwable - { - viewport = null; - alignPanel = null; - avcg = null; - }; - public AlignViewController(AlignViewControllerGuiI alignFrame, - AlignViewportI viewport, AlignmentViewPanel alignPanel) + AlignViewportI vp, AlignmentViewPanel ap) { this.avcg = alignFrame; - this.viewport = viewport; - this.alignPanel = alignPanel; + this.viewport = vp; + this.alignPanel = ap; } @Override - public void setViewportAndAlignmentPanel(AlignViewportI viewport, - AlignmentViewPanel alignPanel) + public void setViewportAndAlignmentPanel(AlignViewportI vp, + AlignmentViewPanel ap) { - this.alignPanel = alignPanel; - this.viewport = viewport; - + this.alignPanel = ap; + this.viewport = vp; } @Override @@ -166,7 +157,7 @@ public class AlignViewController implements AlignViewControllerI @Override public boolean markColumnsContainingFeatures(boolean invert, - boolean extendCurrent, boolean toggle, String featureType) + boolean extendCurrent, boolean toggle, String... featureType) { // JBPNote this routine could also mark rows, not just columns. // need a decent query structure to allow all types of feature searches @@ -175,7 +166,7 @@ public class AlignViewController implements AlignViewControllerI || extendCurrent) ? viewport.getAlignment() : viewport.getSelectionGroup(); - int nseq = findColumnsWithFeature(featureType, sqcol, bs); + int nseq = findColumnsWithFeature(sqcol, bs, featureType); ColumnSelection cs = viewport.getColumnSelection(); if (cs == null) @@ -183,6 +174,9 @@ public class AlignViewController implements AlignViewControllerI cs = new ColumnSelection(); } + String featureTypeString = featureType.length == 1 ? featureType[0] + : featureType.toString(); + if (bs.cardinality() > 0 || invert) { boolean changed = cs.markColumns(bs, sqcol.getStartRes(), @@ -203,7 +197,7 @@ public class AlignViewController implements AlignViewControllerI invert ? MessageManager .getString("label.not_containing") : MessageManager.getString("label.containing"), - featureType, Integer.valueOf(nseq).toString() })); + featureTypeString, Integer.valueOf(nseq).toString() })); return true; } } @@ -211,7 +205,7 @@ public class AlignViewController implements AlignViewControllerI { avcg.setStatus(MessageManager .formatMessage("label.no_feature_of_type_found", new String[] - { featureType })); + { featureTypeString })); if (!extendCurrent) { cs.clear(); @@ -223,17 +217,22 @@ public class AlignViewController implements AlignViewControllerI /** * Sets a bit in the BitSet for each column (base 0) in the sequence - * collection which includes the specified feature type. Returns the number of - * sequences which have the feature in the selected range. + * collection which includes a visible feature of the specified feature + * type(s). Returns the number of sequences which have the feature(s) visible + * in the selected range. * - * @param featureType * @param sqcol * @param bs + * @param featureType + * * @return */ - static int findColumnsWithFeature(String featureType, - SequenceCollectionI sqcol, BitSet bs) + int findColumnsWithFeature(SequenceCollectionI sqcol, + BitSet bs, String... featureType) { + FeatureRenderer fr = alignPanel == null ? null : alignPanel + .getFeatureRenderer(); + final int startColumn = sqcol.getStartRes() + 1; // converted to base 1 final int endColumn = sqcol.getEndRes() + 1; List seqs = sqcol.getSequences(); @@ -246,13 +245,19 @@ public class AlignViewController implements AlignViewControllerI List sfs = sq.findFeatures(startColumn, endColumn, featureType); - if (!sfs.isEmpty()) - { - nseq++; - } - + boolean found = false; for (SequenceFeature sf : sfs) { + if (fr.getColour(sf) == null) + { + continue; + } + if (!found) + { + nseq++; + } + found = true; + int sfStartCol = sq.findIndex(sf.getBegin()); int sfEndCol = sq.findIndex(sf.getEnd()); @@ -351,25 +356,25 @@ public class AlignViewController implements AlignViewControllerI public boolean parseFeaturesFile(String file, DataSourceType protocol, boolean relaxedIdMatching) { - boolean featuresFile = false; + boolean featuresAdded = false; + FeatureRenderer fr = alignPanel.getFeatureRenderer(); try { - featuresFile = new FeaturesFile(false, file, protocol).parse( - viewport.getAlignment().getDataset(), - alignPanel.getFeatureRenderer().getFeatureColours(), false, - relaxedIdMatching); + featuresAdded = new FeaturesFile(false, file, protocol).parse( + viewport.getAlignment().getDataset(), fr.getFeatureColours(), + fr.getFeatureFilters(), false, relaxedIdMatching); } catch (Exception ex) { ex.printStackTrace(); } - if (featuresFile) + if (featuresAdded) { avcg.refreshFeatureUI(true); - if (alignPanel.getFeatureRenderer() != null) + if (fr != null) { // update the min/max ranges where necessary - alignPanel.getFeatureRenderer().findAllFeatures(true); + fr.findAllFeatures(true); } if (avcg.getFeatureSettingsUI() != null) { @@ -378,7 +383,7 @@ public class AlignViewController implements AlignViewControllerI alignPanel.paintAlignment(true, true); } - return featuresFile; + return featuresAdded; }