import jalview.appletgui.FeatureSettings.MyCheckbox;
import jalview.datamodel.*;
+import jalview.schemes.GraduatedColor;
/**
* DOCUMENT ME!
if (sequenceFeatures[sfindex].begin <= start
&& sequenceFeatures[sfindex].end >= start)
{
- currentColour = av.featuresDisplayed
- .get(sequenceFeatures[sfindex].type);
+ currentColour = new Integer(getColour(sequenceFeatures[sfindex]).getRGB());//av.featuresDisplayed
+ //.get(sequenceFeatures[sfindex].type);
}
}
renderFeature(g, seq, seq
.findIndex(sequenceFeatures[sfindex].begin) - 1, seq
.findIndex(sequenceFeatures[sfindex].end) - 1,
- getColour(sequenceFeatures[sfindex].type), start, end, y1);
+ getColour(sequenceFeatures[sfindex]), start, end, y1);
}
}
}
}
}
-
+ Hashtable minmax=null;
void findAllFeatures()
{
jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();
av.featuresDisplayed = new Hashtable();
Vector allfeatures = new Vector();
+ minmax = new Hashtable();
+
for (int i = 0; i < av.alignment.getHeight(); i++)
{
SequenceFeature[] features = av.alignment.getSequenceAt(i)
int index = 0;
while (index < features.length)
{
+ if (features[index].begin==0 && features[index].end==0) {
+ index++;
+ continue;
+ }
if (!av.featuresDisplayed.containsKey(features[index].getType()))
{
if (getColour(features[index].getType()) == null)
getColour(features[index].getType()).getRGB()));
allfeatures.addElement(features[index].getType());
}
+ if (features[index].score != Float.NaN)
+ {
+ int nonpos= features[index].getBegin()>=1 ? 0 : 1;
+ float[][] mm = (float[][]) minmax.get(features[index].getType());
+ if (mm == null)
+ {
+ mm = new float[][] {null, null };
+ minmax.put(features[index].getType(), mm);
+ }
+ if (mm[nonpos]==null)
+ {
+ mm[nonpos] = new float[] { features[index].score, features[index].score };
+
+ }
+ else
+ {
+ if (mm[nonpos][0] > features[index].score)
+ {
+ mm[nonpos][0] = features[index].score;
+ }
+ if (mm[nonpos][1] < features[index].score)
+ {
+ mm[nonpos][1] = features[index].score;
+ }
+ }
+ }
+
index++;
}
}
public Color getColour(String featureType)
{
- if (!featureColours.containsKey(featureType))
+ Object fc = featureColours.get(featureType);
+ if (fc == null)
{
jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();
Color col = ucs.createColourFromName(featureType);
featureColours.put(featureType, col);
return col;
}
+ else if (fc instanceof Color)
+ {
+ return (Color) fc;
+ }
else
- return (Color) featureColours.get(featureType);
+ {
+ if (fc instanceof GraduatedColor)
+ {
+ return ((GraduatedColor) fc).getMinColor();
+ }
+ // TODO: raise an implementation error here.
+ return null; // Color.white;
+ }
+ }
+ /**
+ * implement graduated colouring for features with scores
+ *
+ * @param feature
+ * @return render colour for the given feature
+ */
+ public Color getColour(SequenceFeature feature)
+ {
+ Object fc = featureColours.get(feature.type);
+ if (fc == null)
+ {
+ jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();
+ Color col = ucs.createColourFromName(feature.type);
+ featureColours.put(feature.type, col);
+ return col;
+ }
+ else if (fc instanceof Color)
+ {
+ return (Color) fc;
+ }
+ else
+ {
+ if (fc instanceof GraduatedColor)
+ {
+ return ((GraduatedColor) fc).findColor(feature);
+ }
+ // TODO: raise an implementation error here.
+ return null; // Color.white;
+ }
}
public void setColour(String featureType, Color col)
return alignmentHasFeatures;
}
+ /**
+ *
+ * @return the displayed feature type as an array of strings
+ */
+ protected String[] getDisplayedFeatureTypes()
+ {
+ String[] typ = null;
+ synchronized (renderOrder)
+ {
+ typ = new String[renderOrder.length];
+ System.arraycopy(renderOrder, 0, typ, 0, typ.length);
+ for (int i = 0; i < typ.length; i++)
+ {
+ if (av.featuresDisplayed.get(typ[i]) == null)
+ {
+ typ[i] = null;
+ }
+ }
+ }
+ return typ;
+ }
}
class TransparencySetter