X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FFeatureRenderer.java;h=86d8b3004d79a3ed19a6e28dfdc625ed94f43f56;hb=b57a02c25e335d033c97f8a6bacd6b54f62bd2b6;hp=7cdc0e8419e24b7d2b72cf90942410616347dba0;hpb=1e1f9a1e1983144126974c77005dcab524051ae7;p=jalview.git diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 7cdc0e8..86d8b30 100755 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * * This file is part of Jalview. * @@ -84,6 +84,25 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer featureGroups = fr.featureGroups; featureColours = fr.featureColours; transparency = fr.transparency; + if (av != null && fr.av != null && fr.av != av) + { + if (fr.av.featuresDisplayed != null) + { + if (av.featuresDisplayed == null) + { + av.featuresDisplayed = new Hashtable(); + } + else + { + av.featuresDisplayed.clear(); + } + Enumeration en = fr.av.featuresDisplayed.keys(); + while (en.hasMoreElements()) + { + av.featuresDisplayed.put(en.nextElement(), Boolean.TRUE); + } + } + } } static String lastFeatureAdded; @@ -661,16 +680,16 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer else if (sequenceFeatures[sfindex].type.equals("disulfide bond")) { - renderFeature(g, seq, seq - .findIndex(sequenceFeatures[sfindex].begin) - 1, seq - .findIndex(sequenceFeatures[sfindex].begin) - 1, + renderFeature(g, seq, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, getColour(sequenceFeatures[sfindex]) // new Color(((Integer) av.featuresDisplayed // .get(sequenceFeatures[sfindex].type)).intValue()) , start, end, y1); - renderFeature(g, seq, seq - .findIndex(sequenceFeatures[sfindex].end) - 1, seq - .findIndex(sequenceFeatures[sfindex].end) - 1, + renderFeature(g, seq, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, getColour(sequenceFeatures[sfindex]) // new Color(((Integer) av.featuresDisplayed // .get(sequenceFeatures[sfindex].type)).intValue()) @@ -681,9 +700,9 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer { if (showFeature(sequenceFeatures[sfindex])) { - renderFeature(g, seq, seq - .findIndex(sequenceFeatures[sfindex].begin) - 1, seq - .findIndex(sequenceFeatures[sfindex].end) - 1, + renderFeature(g, seq, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, getColour(sequenceFeatures[sfindex]), start, end, y1); } } @@ -747,6 +766,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer } Hashtable minmax = null; + /** * Called when alignment in associated view has new/modified features to * discover and display. @@ -757,6 +777,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer lastSeq = null; findAllFeatures(); } + /** * find all features on the alignment */ @@ -767,10 +788,10 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer av.featuresDisplayed = new Hashtable(); Vector allfeatures = new Vector(); minmax = new Hashtable(); - - for (int i = 0; i < av.alignment.getHeight(); i++) + AlignmentI alignment = av.getAlignment(); + for (int i = 0; i < alignment.getHeight(); i++) { - SequenceFeature[] features = av.alignment.getSequenceAt(i) + SequenceFeature[] features = alignment.getSequenceAt(i) .getSequenceFeatures(); if (features == null) @@ -790,8 +811,8 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer { if (getColour(features[index].getType()) == null) { - featureColours.put(features[index].getType(), ucs - .createColourFromName(features[index].getType())); + featureColours.put(features[index].getType(), + ucs.createColourFromName(features[index].getType())); } av.featuresDisplayed.put(features[index].getType(), new Integer( @@ -1045,9 +1066,9 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer for (int i = 0; i < toset.length; i++) { Object st = featureGroups.get(toset[i]); + featureGroups.put(toset[i], new Boolean(visible)); if (st != null) { - featureGroups.put(toset[i], new Boolean(visible)); rdrw = rdrw || (visible != ((Boolean) st).booleanValue()); } } @@ -1071,6 +1092,8 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer } } + ArrayList hiddenGroups = new ArrayList(); + /** * analyse alignment for groups and hash tables (used to be embedded in * FeatureSettings.setTableData) @@ -1084,29 +1107,34 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer { featureGroups = new Hashtable(); } - Vector allFeatures = new Vector(); - Vector allGroups = new Vector(); + hiddenGroups = new ArrayList(); + hiddenGroups.addAll(featureGroups.keySet()); + ArrayList allFeatures = new ArrayList(); + ArrayList allGroups = new ArrayList(); SequenceFeature[] tmpfeatures; String group; - for (int i = 0; i < av.alignment.getHeight(); i++) + AlignmentI alignment = av.getAlignment(); + for (int i = 0; i < alignment.getHeight(); i++) { - if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null) + if (alignment.getSequenceAt(i).getSequenceFeatures() == null) { continue; } alignmentHasFeatures = true; - tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures(); + tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures(); int index = 0; while (index < tmpfeatures.length) { if (tmpfeatures[index].getFeatureGroup() != null) { group = tmpfeatures[index].featureGroup; + // Remove group from the hiddenGroup list + hiddenGroups.remove(group); if (!allGroups.contains(group)) { - allGroups.addElement(group); + allGroups.add(group); boolean visible = true; if (featureGroups.containsKey(group)) @@ -1122,7 +1150,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer if (!allFeatures.contains(tmpfeatures[index].getType())) { - allFeatures.addElement(tmpfeatures[index].getType()); + allFeatures.add(tmpfeatures[index].getType()); } index++; } @@ -1151,16 +1179,17 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer Vector allFeatures = new Vector(); SequenceFeature[] tmpfeatures; String group; - for (int i = 0; i < av.alignment.getHeight(); i++) + AlignmentI alignment = av.getAlignment(); + for (int i = 0; i < alignment.getHeight(); i++) { - if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null) + if (alignment.getSequenceAt(i).getSequenceFeatures() == null) { continue; } alignmentHasFeatures = true; - tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures(); + tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures(); int index = 0; while (index < tmpfeatures.length) {