*/
private int changeCount;
- /*
- * cached rgb colours for each position of the aligned sequence (column)
- */
- private int[] argb;
-
/**
* Creates a new Sequence object.
*
@Override
public void sequenceChanged()
{
- argb = null;
changeCount++;
}
return 0;
}
- @Override
- public int getColor(int i)
- {
- return argb == null ? 0 : argb[i];
- }
-
- @Override
- public int setColor(int i, int rgb)
- {
- if (argb == null)
- {
- argb = new int[this.sequence.length];
- }
- return (argb[i] = rgb);
- }
-
- @Override
- public void resetColors()
- {
- argb = null;
- }
-
/**
* Answers a (possibly empty) list of features of the specified type that
* overlap the specified column position. If parameter {@code result} is not
public int firstResidueOutsideIterator(Iterator<int[]> it);
/**
- * @author Bob Hanson 2019.07.30
- *
- * get a 4-byte color, with caching
- *
- */
- public int getColor(int i);
-
- /**
- * @author Bob Hanson 2019.07.30
- *
- * set a 4-byte color, with caching
- *
- */
- public int setColor(int i, int argb);
-
- /**
- * @author Bob Hanson 2019.07.30
- *
- * allows resetting the color cache
- *
- */
- public void resetColors();
-
- /**
* Answers a (possibly empty) list of features of the specified type that
* overlap the specified column position. If parameter {@code result} is not
* null, features are appended to it and the (possibly extended) list is
SequenceGroup[] allGroups, final SequenceI seq, int i,
FeatureColourFinder finder)
{
-
- int c = seq.getColor(i);
- if (c != 0)
- {
- return c;
- }
-
int col = getResidueBoxColourInt(showBoxes, shader, allGroups, seq, i);
// if there's a FeatureColourFinder we might override the residue colour
// here with feature colouring
col = finder == null || finder.noFeaturesDisplayed() ? col
: finder.findFeatureColourInt(col, seq, i);
- return seq.setColor(i, col);
+ return col;
}
@Override
}
av.setGlobalColourScheme(new UserColourScheme(newColours));
- seq.resetColors();
// gap colour not specified so gaps are lightGray
assertEquals(Color.lightGray, rcf
newColours[23] = Color.pink;
av.setGlobalColourScheme(new UserColourScheme(newColours));
- seq.resetColors();
// gap colour specified as pink
assertEquals(Color.pink, rcf.getResidueColour(true,
// unaffected by showBoxes setting
// gap colour not specified so gaps are lightGray
newColours[23] = null;
- seq.resetColors();
assertEquals(Color.lightGray, rcf.getResidueColour(false,
av.getResidueShading(), null, seq, 3, null));
newColours[23] = Color.pink;
av.setGlobalColourScheme(new UserColourScheme(newColours));
- seq.resetColors();
// gap colour specified as pink
assertEquals(Color.pink, rcf.getResidueColour(false,
// use legacy colouring
rcf = new OverviewResColourFinder(true, Color.blue, Color.red);
-
- seq.resetColors();
// G in group specified as magenta in Zappo
assertEquals(Color.magenta, rcf.getResidueColour(false,
// use new colouring
rcf = new OverviewResColourFinder(false, Color.blue, Color.red);
- seq.resetColors();
-
// G in group specified as magenta in Zappo
assertEquals(Color.magenta, rcf.getResidueColour(false,
av.getResidueShading(), groups, seq, 7, null));
ResidueColourFinder rcf = new OverviewResColourFinder();
ResidueShaderI shader = new ResidueShader();
- seq.resetColors();
-
// residues white
Color c = rcf.getBoxColour(shader, seq, 0);
assertEquals(Color.white, c);
rcf = new OverviewResColourFinder(true, Color.blue, Color.red);
shader = new ResidueShader();
- seq.resetColors();
-
// residues light gray
c = rcf.getBoxColour(shader, seq, 0);
assertEquals(Color.lightGray, c);
rcf = new OverviewResColourFinder();
shader = new ResidueShader();
- seq.resetColors();
-
// residues white
c = rcf.getBoxColour(shader, seq, 0);
assertEquals(Color.white, c);
rcf = new OverviewResColourFinder(false, Color.blue, Color.red);
shader = new ResidueShader(new ZappoColourScheme());
- seq.resetColors();
-
// M residue pink
c = rcf.getBoxColour(shader, seq, 0);
assertEquals(Color.pink, c);
// legacy colouring with colour scheme
rcf = new OverviewResColourFinder(true, Color.blue, Color.red);
- seq.resetColors();
-
// M residue pink
c = rcf.getBoxColour(shader, seq, 0);
assertEquals(Color.pink, c);