*/
package jalview.workers;
+import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import jalview.api.AlignViewportI;
+import jalview.api.FeatureColourI;
import jalview.api.FeaturesDisplayedI;
import jalview.datamodel.SequenceFeature;
import jalview.gui.FeatureRenderer;
@Override
public void propertyChange(PropertyChangeEvent evt)
{
- if (ourViewport != null) // could check source is
+ if (ourViewport != null) // could
+ // check
+ // source
+ // is
// ourFr.getChangeSupport...
{
updateFeatureAnnotationTracks();
.isShowSequenceFeatureCounts()
? ourViewport.getFeaturesDisplayed()
: null;
+ // get latest FeatureRenderer, just in case it's different.
+ ourFr = ourFr.getAlignPanel().getFeatureRenderer();
+
Set<String> visibleFeatures = new HashSet();
if (featuresDisp != null)
{
}
// otherwise set up tracks accordingly
+ int[][] minC = new int[visibleFeatures.size()][3],
+ maxC = new int[visibleFeatures.size()][3];
+ Map<String, FeatureColourI> fcs = ourFr.getDisplayedFeatureCols();
+ int p = 0;
+ for (String s : visibleFeatures)
+ {
+ FeatureColourI color = fcs.get(s);
+ if (color.isSimpleColour())
+ {
+ minC[p] = new int[] { 133, 133, 133 };
+ maxC[p] = new int[] { color.getColour().getRed(),
+ color.getColour().getGreen(), color.getColour().getBlue() };
+ }
+ else
+ {
+ Color min = color.getMinColour(), max = color.getMaxColour();
+ minC[p] = new int[] { min.getRed(), min.getGreen(), min.getBlue() };
+ maxC[p] = new int[] { max.getRed(), max.getGreen(), max.getBlue() };
+ }
+ p++;
+ }
+ minColours = minC;
+ maxColours = maxC;
/*
* and register the counter
*/
if (ourWorker != null)
{
- Set<String> toRemove = new HashSet<String>(),
- toAdd = new HashSet<String>();
+ Set<String> toRemove = new HashSet<String>();
toRemove.addAll(dispFeatures);
toRemove.removeAll(visibleFeatures);
dispFeatures = visibleFeatures;
return dispFeatures.toArray(new String[0]);
}
+ int[][] minColours = null, maxColours = null;
+
@Override
- public int[] getMaxColour()
+ public int[] getMaxColour(int row)
{
+ if (maxColours != null && row >= 0 && row < maxColours.length)
+ {
+ return maxColours[row];
+ }
return new int[] { 0, 0, 255 };
}
@Override
- public int[] getMinColour()
+ public int[] getMinColour(int row)
{
- return new int[] { 0, 255, 255 };
+ if (minColours != null && row >= 0 && row < minColours.length)
+ {
+ return minColours[row];
+ }
+ return new int[] { 133, 133, 133 };
}
}
\ No newline at end of file