oldcs = fr.featureColours.get(type);
if (oldcs instanceof GraduatedColor)
{
- cs = new GraduatedColor((GraduatedColor) oldcs, min, max);
+ if (((GraduatedColor)oldcs).isAutoScale())
+ {
+ // update the scale
+ cs = new GraduatedColor((GraduatedColor) oldcs, min, max);
+ } else {
+ cs = new GraduatedColor((GraduatedColor) oldcs);
+ }
} else {
// promote original color to a graduated color
Color bl = Color.black;
} catch (Exception ex)
{
}
+ // update the gui from threshold state
+ thresholdIsMin.setSelected(!cs.isAutoScale());
+ if (cs.getThreshType()!=AnnotationColourGradient.NO_THRESHOLD)
+ {
+ // initialise threshold slider and selector
+ threshold.setSelectedIndex(cs.getThreshType()==AnnotationColourGradient.ABOVE_THRESHOLD ? 1 : 2);
+ slider.setEnabled(true);
+ thresholdValue.setEnabled(true);
+ threshline = new jalview.datamodel.GraphLine(
+ (max - min) / 2f,
+ "Threshold", Color.black);
+
+ }
adjusting = false;
threshold_actionPerformed(e);
}
});
- threshold.addItem("No Threshold");
- threshold.addItem("Above Threshold");
- threshold.addItem("Below Threshold");
+ threshold.addItem("No Threshold"); // index 0
+ threshold.addItem("Above Threshold"); // index 1
+ threshold.addItem("Below Threshold"); // index 2
jPanel3.setLayout(flowLayout2);
thresholdValue.addActionListener(new ActionListener()
{
acg.setThreshType(aboveThreshold);
if (thresholdIsMin.isSelected() && aboveThreshold != AnnotationColourGradient.NO_THRESHOLD)
{
+ acg.setAutoScaled(false);
if (aboveThreshold==AnnotationColourGradient.ABOVE_THRESHOLD)
{
acg = new GraduatedColor(acg, threshline.value, max);
} else {
acg = new GraduatedColor(acg, min,threshline.value);
}
+ } else {
+ acg.setAutoScaled(true);
}
fr.featureColours.put(type,acg);
if (sequenceFeatures[sfindex].begin <= start
&& sequenceFeatures[sfindex].end >= start)
{
- currentColour = av.featuresDisplayed
- .get(sequenceFeatures[sfindex].type);
+ // this is passed out to the overview and other sequence renderers (e.g. molecule viewer) to get displayed colour for rendered sequence
+ currentColour = new Integer(getColour(sequenceFeatures[sfindex]).getRGB());
+ // used to be retreived from av.featuresDisplayed
+ // currentColour = av.featuresDisplayed
+ // .get(sequenceFeatures[sfindex].type);
+
+
}
}
else if (sequenceFeatures[sfindex].type.equals("disulfide bond"))
seq,
seq.findIndex(sequenceFeatures[sfindex].begin) - 1,
seq.findIndex(sequenceFeatures[sfindex].begin) - 1,
- new Color(((Integer) av.featuresDisplayed
- .get(sequenceFeatures[sfindex].type)).intValue()),
+ 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,
- new Color(((Integer) av.featuresDisplayed
- .get(sequenceFeatures[sfindex].type)).intValue()),
+ getColour(sequenceFeatures[sfindex])
+ //new Color(((Integer) av.featuresDisplayed
+ // .get(sequenceFeatures[sfindex].type)).intValue())
+ ,
start, end, y1);
}
* types, in the order given by getOrder or the order given in allFeatures.
* Note. this operates directly on the featureOrder hash for efficiency. TODO:
* eliminate the float storage for computing/recalling the persistent ordering
- *
+ * New Cability: updates min/max for colourscheme range if its dynamic
* @param allFeatures
*/
private void updateRenderOrder(Vector allFeatures)
Vector allfeatures = new Vector(allFeatures);
String[] oldRender = renderOrder;
renderOrder = new String[allfeatures.size()];
+ Object mmrange,fc=null;
boolean initOrders = (featureOrder == null);
int opos = 0;
if (oldRender != null && oldRender.length > 0)
renderOrder[opos++] = oldRender[j]; // existing features always
// appear below new features
allfeatures.removeElement(oldRender[j]);
+ if (minmax!=null)
+ {
+ mmrange = minmax.get(oldRender[j]);
+ if (mmrange!=null)
+ {
+ fc = featureColours.get(oldRender[j]);
+ if (fc!=null && fc instanceof GraduatedColor && ((GraduatedColor)fc).isAutoScale())
+ {
+ ((GraduatedColor) fc).updateBounds(((float[][])mmrange)[0][0],((float[][])mmrange)[0][1]);
+ }
+ }
}
}
}
+ }
}
if (allfeatures.size() == 0)
{
while (en.hasMoreElements())
{
newf[i] = en.nextElement().toString();
+ if (minmax!=null)
+ {
+ // update from new features minmax if necessary
+ mmrange = minmax.get(newf[i]);
+ if (mmrange!=null)
+ {
+ fc = featureColours.get(newf[i]);
+ if (fc!=null && fc instanceof GraduatedColor && ((GraduatedColor)fc).isAutoScale())
+ {
+ ((GraduatedColor) fc).updateBounds(((float[][])mmrange)[0][0],((float[][])mmrange)[0][1]);
+ }
+ }
+ }
if (initOrders || !featureOrder.containsKey(newf[i]))
{
int denom = initOrders ? allfeatures.size() : featureOrder.size();
i--;
}
if (iSize > 1 && sort)
+ {
jalview.util.QuickSort.sort(sortOrder, newf);
+ }
sortOrder = null;
System.arraycopy(newf, 0, renderOrder, opos, newf.length);
}
{
if (fc instanceof GraduatedColor)
{
- return ((GraduatedColor) fc).getMinColor();
+ return ((GraduatedColor) fc).getMaxColor();
}
// TODO: raise an implementation error here.
return null; // Color.white;