private boolean predefinedColours = false;
private boolean seqAssociated = false;
+
/**
* false if the scheme was constructed without a minColour and maxColour used
* to decide if existing colours should be taken from annotation elements when
* they exist
*/
private boolean noGradient = false;
+
IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
@Override
- public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+ public ColourSchemeI getInstance(AnnotatedCollectionI sg,
Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
{
AnnotationColourGradient acg = new AnnotationColourGradient(annotation,
- colourScheme, aboveAnnotationThreshold);
+ getColourScheme(), aboveAnnotationThreshold);
acg.thresholdIsMinMax = thresholdIsMinMax;
acg.annotationThreshold = (annotationThreshold == null) ? null
: new GraphLine(annotationThreshold);
{
if (originalColour instanceof AnnotationColourGradient)
{
- colourScheme = ((AnnotationColourGradient) originalColour).colourScheme;
+ setColourScheme(((AnnotationColourGradient) originalColour)
+ .getColourScheme());
}
else
{
- colourScheme = originalColour;
+ setColourScheme(originalColour);
}
this.annotation = annotation;
bb = 0;
noGradient = true;
+ checkLimits();
}
/**
bb = maxColour.getBlue() - b1;
noGradient = false;
+ checkLimits();
+ }
+
+ private void checkLimits()
+ {
aamax = annotation.graphMax;
aamin = annotation.graphMin;
if (annotation.isRNA())
{
+ // reset colour palette
+ ColourSchemeProperty.resetRnaHelicesShading();
ColourSchemeProperty.initRnaHelicesShading(1 + (int) aamax);
}
}
// resolve the context containing all the annotation for the sequence
AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment
: alignment.getContext();
- boolean f = true,rna=false;
+ boolean f = true, rna = false;
for (AlignmentAnnotation alan : alcontext.findAnnotation(annotation
.getCalcId()))
{
}
float aamin = 0f, aamax = 0f;
+
public String getAnnotation()
{
return annotation.label;
*
* @return DOCUMENT ME!
*/
+ @Override
public Color findColour(char c)
{
return Color.red;
public Color findColour(char c, int j, SequenceI seq)
{
Color currentColour = Color.white;
- AlignmentAnnotation annotation = (seqAssociated && seqannot!=null ? seqannot.get(seq)
- : this.annotation);
+ AlignmentAnnotation annotation = (seqAssociated && seqannot != null ? seqannot
+ .get(seq) : this.annotation);
if (annotation == null)
{
return currentColour;
}
- if ((threshold == 0) || aboveThreshold(c, j))
+ // if ((threshold == 0) || aboveThreshold(c, j))
+ // {
+ if (annotation.annotations != null && j < annotation.annotations.length
+ && annotation.annotations[j] != null
+ && !jalview.util.Comparison.isGap(c))
{
- if (annotation.annotations != null
- && j < annotation.annotations.length
- && annotation.annotations[j] != null
- && !jalview.util.Comparison.isGap(c))
+ Annotation aj = annotation.annotations[j];
+ // 'use original colours' => colourScheme != null
+ // -> look up colour to be used
+ // predefined colours => preconfigured shading
+ // -> only use original colours reference if thresholding enabled &
+ // minmax exists
+ // annotation.hasIcons => null or black colours replaced with glyph
+ // colours
+ // -> reuse original colours if present
+ // -> if thresholding enabled then return colour on non-whitespace glyph
+
+ if (aboveAnnotationThreshold == NO_THRESHOLD
+ || (annotationThreshold != null && (aboveAnnotationThreshold == ABOVE_THRESHOLD ? aj.value >= annotationThreshold.value
+ : aj.value <= annotationThreshold.value)))
{
- Annotation aj = annotation.annotations[j];
- // 'use original colours' => colourScheme != null
- // -> look up colour to be used
- // predefined colours => preconfigured shading
- // -> only use original colours reference if thresholding enabled &
- // minmax exists
- // annotation.hasIcons => null or black colours replaced with glyph
- // colours
- // -> reuse original colours if present
- // -> if thresholding enabled then return colour on non-whitespace glyph
-
- if (aboveAnnotationThreshold == NO_THRESHOLD
- || (annotationThreshold != null && (aboveAnnotationThreshold == ABOVE_THRESHOLD ? aj.value >= annotationThreshold.value
- : aj.value <= annotationThreshold.value)))
+ if (predefinedColours && aj.colour != null
+ && !aj.colour.equals(Color.black))
{
- if (predefinedColours && aj.colour != null
- && !aj.colour.equals(Color.black))
- {
- currentColour = aj.colour;
- }
- else if (annotation.hasIcons
- && annotation.graph == AlignmentAnnotation.NO_GRAPH)
+ currentColour = aj.colour;
+ }
+ else if (annotation.hasIcons
+ && annotation.graph == AlignmentAnnotation.NO_GRAPH)
+ {
+ if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.'
+ && aj.secondaryStructure != '-')
{
- if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.'
- && aj.secondaryStructure != '-')
+ if (getColourScheme() != null)
{
- if (colourScheme != null)
+ currentColour = getColourScheme().findColour(c, j, seq, null,
+ 0f);
+ }
+ else
+ {
+ if (annotation.isRNA())
{
- currentColour = colourScheme.findColour(c, j, seq);
+ currentColour = ColourSchemeProperty.rnaHelices[(int) aj.value];
}
else
{
- if (annotation.isRNA())
- {
- currentColour = ColourSchemeProperty.rnaHelices[(int) aj.value];
- }
- else
- {
- currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR
- : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR
- : jalview.renderer.AnnotationRenderer.STEM_COLOUR;
- }
+ currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR
+ : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR
+ : jalview.renderer.AnnotationRenderer.STEM_COLOUR;
}
}
- else
- {
- //
- return Color.white;
- }
}
- else if (noGradient)
+ else
{
- if (colourScheme != null)
- {
- currentColour = colourScheme.findColour(c, j, seq);
- }
- else
- {
- if (aj.colour != null)
- {
- currentColour = aj.colour;
- }
- }
+ //
+ return Color.white;
+ }
+ }
+ else if (noGradient)
+ {
+ if (getColourScheme() != null)
+ {
+ currentColour = getColourScheme().findColour(c, j, seq, null,
+ 0f);
}
else
{
- currentColour = shadeCalculation(annotation, j);
+ if (aj.colour != null)
+ {
+ currentColour = aj.colour;
+ }
}
}
- if (conservationColouring)
+ else
{
- currentColour = applyConservation(currentColour, j);
+ currentColour = shadeCalculation(annotation, j);
}
}
+ // if (conservationColouring)
+ // {
+ // currentColour = applyConservation(currentColour, j);
+ // }
}
+ // }
return currentColour;
}
return new Color(dr, dg, db);
}
+
public boolean isPredefinedColours()
{
return predefinedColours;
{
seqAssociated = sassoc;
}
+
+ @Override
+ public String getSchemeName()
+ {
+ return "Annotation";
+ }
+
+ @Override
+ public boolean isSimple()
+ {
+ return false;
+ }
}