X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2Fseqfeatures%2FFeatureRendererModel.java;h=40f38b6eccbf6e56d063886d9f4203511b5d3826;hb=9ba5a485b66e9c5a86b12dedc7b32616f3ef6db8;hp=c1ad4659b5602ab2fb767edcdf586972ebc782e7;hpb=eb5043c4c5932b46aa018e37ae42bd011405cd87;p=jalview.git diff --git a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java index c1ad465..40f38b6 100644 --- a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java +++ b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java @@ -28,7 +28,7 @@ import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.renderer.seqfeatures.FeatureRenderer; import jalview.schemes.FeatureColour; -import jalview.schemes.UserColourScheme; +import jalview.util.ColorUtils; import java.awt.Color; import java.beans.PropertyChangeListener; @@ -36,6 +36,7 @@ import java.beans.PropertyChangeSupport; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -344,6 +345,8 @@ public abstract class FeatureRendererModel implements { minmax = new Hashtable(); } + + Set oldGroups = new HashSet(featureGroups.keySet()); AlignmentI alignment = av.getAlignment(); for (int i = 0; i < alignment.getHeight(); i++) { @@ -358,9 +361,10 @@ public abstract class FeatureRendererModel implements int index = 0; while (index < features.length) { + String fgrp = features[index].getFeatureGroup(); + oldGroups.remove(fgrp); if (!featuresDisplayed.isRegistered(features[index].getType())) { - String fgrp = features[index].getFeatureGroup(); if (fgrp != null) { Boolean groupDisplayed = featureGroups.get(fgrp); @@ -424,6 +428,16 @@ public abstract class FeatureRendererModel implements index++; } } + + /* + * oldGroups now consists of groups that no longer + * have any feature in them - remove these + */ + for (String grp : oldGroups) + { + featureGroups.remove(grp); + } + updateRenderOrder(allfeatures); findingFeatures = false; } @@ -542,7 +556,7 @@ public abstract class FeatureRendererModel implements FeatureColourI fc = featureColours.get(featureType); if (fc == null) { - Color col = UserColourScheme.createColourFromName(featureType); + Color col = ColorUtils.createColourFromName(featureType); fc = new FeatureColour(col); featureColours.put(featureType, fc); } @@ -550,18 +564,28 @@ public abstract class FeatureRendererModel implements } /** - * calculate the render colour for a specific feature using current feature - * settings. + * Returns the configured colour for a particular feature instance. This + * includes calculation of 'colour by label', or of a graduated score colour, + * if applicable. It does not take into account feature visibility or colour + * transparency. * * @param feature - * @return render colour for the given feature + * @return */ public Color getColour(SequenceFeature feature) { FeatureColourI fc = getFeatureStyle(feature.getType()); - return fc.getColor(feature); + return fc.isColored(feature) ? fc.getColor(feature) : null; } + /** + * Answers true unless the feature has a score value which lies outside a + * minimum or maximum threshold configured for colouring. This method does not + * check feature type or group visibility. + * + * @param sequenceFeature + * @return + */ protected boolean showFeature(SequenceFeature sequenceFeature) { FeatureColourI fc = getFeatureStyle(sequenceFeature.type); @@ -586,11 +610,13 @@ public abstract class FeatureRendererModel implements featureColours.put(featureType, col); } + @Override public void setTransparency(float value) { transparency = value; } + @Override public float getTransparency() { return transparency; @@ -822,7 +848,7 @@ public abstract class FeatureRendererModel implements * @return list of groups */ @Override - public List getGroups(boolean visible) + public List getGroups(boolean visible) { if (featureGroups != null) {