if (oldcs.isGraduatedColour())
{
threshline.value = oldcs.getThreshold();
- cs = new FeatureColour((FeatureColour) oldcs, min, max);
+ cs = new FeatureColour(oldcs.getColour(), oldcs.getMinColour(),
+ oldcs.getMaxColour(), oldcs.getNoColour(), min, max);
}
else
{
bl = oldcs.getColour();
}
// original colour becomes the maximum colour
- cs = new FeatureColour(Color.white, bl, mm[0], mm[1]);
+ cs = new FeatureColour(bl, Color.white, bl, Color.white, mm[0],
+ mm[1]);
}
minColour.setBackground(cs.getMinColour());
maxColour.setBackground(cs.getMaxColour());
slider.setEnabled(true);
thresholdValue.setEnabled(true);
- FeatureColour acg = new FeatureColour(minColour.getBackground(),
- maxColour.getBackground(), min, max);
+ Color minc = minColour.getBackground();
+ Color maxc = maxColour.getBackground();
+ FeatureColour acg = new FeatureColour(maxc, minc, maxc, minc, min, max);
acg.setColourByLabel(colourFromLabel.getState());
maxColour.setEnabled(!colourFromLabel.getState());
{
if (thresholdOption == AnnotationColourGradient.ABOVE_THRESHOLD)
{
- acg = new FeatureColour(acg, threshline.value, max);
+ acg = new FeatureColour(acg.getColour(), acg.getMinColour(),
+ acg.getMaxColour(), acg.getNoColour(), threshline.value,
+ max);
}
else
{
- acg = new FeatureColour(acg, min, threshline.value);
+ acg = new FeatureColour(acg.getColour(), acg.getMinColour(),
+ acg.getMaxColour(), acg.getNoColour(), min,
+ threshline.value);
}
}
maxColour.setBorder(new LineBorder(Color.black));
/*
- * default max colour to last plain colour;
- * make min colour a pale version of max colour
+ * if not set, default max colour to last plain colour,
+ * and make min colour a pale version of max colour
*/
- FeatureColourI fc = fr.getFeatureColours().get(featureType);
- Color bg = fc.getColour() == null ? Color.BLACK : fc.getColour();
- maxColour.setBackground(bg);
- minColour.setBackground(ColorUtils.bleachColour(bg, 0.9f));
+ Color max = originalColour.getMaxColour();
+ if (max == null)
+ {
+ max = originalColour.getColour();
+ minColour.setBackground(ColorUtils.bleachColour(max, 0.9f));
+ }
+ else
+ {
+ maxColour.setBackground(max);
+ minColour.setBackground(originalColour.getMinColour());
+ }
noValueCombo = new JComboBox<>();
noValueCombo.addItem(MessageManager.getString("label.no_colour"));
singleColour.setFont(JvSwingUtils.getLabelFont());
singleColour.setBorder(BorderFactory.createLineBorder(Color.black));
singleColour.setPreferredSize(new Dimension(40, 20));
- if (originalColour.isGraduatedColour())
- {
- singleColour.setBackground(originalColour.getMaxColour());
- singleColour.setForeground(originalColour.getMaxColour());
- }
- else
- {
+ // if (originalColour.isGraduatedColour())
+ // {
+ // singleColour.setBackground(originalColour.getMaxColour());
+ // singleColour.setForeground(originalColour.getMaxColour());
+ // }
+ // else
+ // {
singleColour.setBackground(originalColour.getColour());
singleColour.setForeground(originalColour.getColour());
- }
+ // }
singleColour.addMouseListener(new MouseAdapter()
{
@Override
private FeatureColourI makeColourFromInputs()
{
/*
- * easiest case - a single colour
+ * min-max range is to (or from) threshold value if
+ * 'threshold is min/max' is selected
*/
- if (simpleColour.isSelected())
- {
- return new FeatureColour(singleColour.getBackground());
- }
-
- /*
- * next easiest case - colour by Label, or attribute text
- */
- if (byCategory.isSelected())
- {
- Color c = singleColour.getBackground();
- FeatureColourI fc = new FeatureColour(c);
- fc.setColourByLabel(true);
- String byWhat = (String) colourByTextCombo.getSelectedItem();
- if (!LABEL_18N.equals(byWhat))
- {
- fc.setAttributeName(
- FeatureMatcher.fromAttributeDisplayName(byWhat));
- }
- return fc;
- }
-
- /*
- * remaining case - graduated colour by score, or attribute value
- */
- Color noColour = null;
- if (noValueCombo.getSelectedIndex() == MIN_COLOUR_OPTION)
- {
- noColour = minColour.getBackground();
- }
- else if (noValueCombo.getSelectedIndex() == MAX_COLOUR_OPTION)
- {
- noColour = maxColour.getBackground();
- }
float thresh = 0f;
try
{
// invalid inputs are already handled on entry
}
-
- /*
- * min-max range is to (or from) threshold value if
- * 'threshold is min/max' is selected
- */
float minValue = min;
float maxValue = max;
final int thresholdOption = threshold.getSelectedIndex();
{
maxValue = thresh;
}
+ Color noColour = null;
+ if (noValueCombo.getSelectedIndex() == MIN_COLOUR_OPTION)
+ {
+ noColour = minColour.getBackground();
+ }
+ else if (noValueCombo.getSelectedIndex() == MAX_COLOUR_OPTION)
+ {
+ noColour = maxColour.getBackground();
+ }
+
+ /*
+ * construct a colour that 'remembers' all the options, including
+ * those not currently selected
+ */
+ FeatureColourI fc = new FeatureColour(singleColour.getBackground(),
+ minColour.getBackground(), maxColour.getBackground(), noColour,
+ minValue, maxValue);
+
+ /*
+ * easiest case - a single colour
+ */
+ if (simpleColour.isSelected())
+ {
+ ((FeatureColour) fc).setGraduatedColour(false);
+ return fc;
+ }
/*
- * make the graduated colour
+ * next easiest case - colour by Label, or attribute text
*/
- FeatureColourI fc = new FeatureColour(minColour.getBackground(),
- maxColour.getBackground(), noColour, minValue, maxValue);
+ if (byCategory.isSelected())
+ {
+ fc.setColourByLabel(true);
+ String byWhat = (String) colourByTextCombo.getSelectedItem();
+ if (!LABEL_18N.equals(byWhat))
+ {
+ fc.setAttributeName(
+ FeatureMatcher.fromAttributeDisplayName(byWhat));
+ }
+ return fc;
+ }
/*
+ * remaining case - graduated colour by score, or attribute value;
* set attribute to colour by if selected
*/
String byWhat = (String) colourByRangeCombo.getSelectedItem();
import jalview.schemabinding.version2.AnnotationColours;
import jalview.schemabinding.version2.AnnotationElement;
import jalview.schemabinding.version2.CalcIdParam;
-import jalview.schemabinding.version2.Colour;
import jalview.schemabinding.version2.CompoundMatcher;
import jalview.schemabinding.version2.DBRef;
import jalview.schemabinding.version2.Features;
}
float min = setting.hasMin() ? setting.getMin() : 0f;
float max = setting.hasMin() ? setting.getMax() : 1f;
- FeatureColourI gc = new FeatureColour(minColour, maxColour,
- noValueColour, min, max);
+ FeatureColourI gc = new FeatureColour(maxColour, minColour,
+ maxColour, noValueColour, min, max);
if (setting.getAttributeNameCount() > 0)
{
gc.setAttributeName(setting.getAttributeName());
noValueColour = maxcol;
}
- colour = new FeatureColour(mincol, maxcol, noValueColour,
- colourModel.getMin(),
- colourModel.getMax());
+ colour = new FeatureColour(maxcol, mincol, maxcol, noValueColour,
+ colourModel.getMin(), colourModel.getMax());
String[] attributes = colourModel.getAttributeName();
if (attributes != null && attributes.length > 0)
{
Color maxColour = ColorUtils.parseColourString(maxcol);
Color noColour = noValueColour.equals(NO_VALUE_MAX) ? maxColour
: (noValueColour.equals(NO_VALUE_NONE) ? null : minColour);
- featureColour = new FeatureColour(minColour, maxColour, noColour, min,
- max);
+ featureColour = new FeatureColour(maxColour, minColour, maxColour,
+ noColour, min, max);
featureColour.setColourByLabel(minColour == null);
featureColour.setAutoScaled(autoScaled);
if (byAttribute)
}
/**
- * Constructor given a simple colour
+ * Constructor given a simple colour. This also 'primes' a graduated colour
+ * range, where the maximum colour is the given simple colour, and the minimum
+ * colour a paler shade of it. This is for convenience when switching from a
+ * simple colour to a graduated colour scheme.
*
* @param c
*/
public FeatureColour(Color c)
{
- minColour = Color.WHITE;
- maxColour = Color.BLACK;
- noColour = DEFAULT_NO_COLOUR;
- minRed = 0f;
- minGreen = 0f;
- minBlue = 0f;
- deltaRed = 0f;
- deltaGreen = 0f;
- deltaBlue = 0f;
- colour = c;
- }
+ /*
+ * set max colour to the simple colour, min colour to a paler shade of it
+ */
+ this(c, c == null ? Color.white : ColorUtils.bleachColour(c, 0.9f),
+ c == null ? Color.black : c, DEFAULT_NO_COLOUR, 0, 0);
- /**
- * Constructor given a colour range and a score range, defaulting 'no value
- * colour' to be the same as minimum colour
- *
- * @param low
- * @param high
- * @param min
- * @param max
- */
- public FeatureColour(Color low, Color high, float min, float max)
- {
- this(low, high, low, min, max);
+ /*
+ * but enforce simple colour for now!
+ */
+ setGraduatedColour(false);
}
/**
}
/**
- * Copy constructor with new min/max ranges
- *
- * @param fc
- * @param min
- * @param max
- */
- public FeatureColour(FeatureColour fc, float min, float max)
- {
- this(fc);
- updateBounds(min, max);
- }
-
- /**
- * Constructor for a graduated colour
+ * Constructor that sets both simple and graduated colour values. This allows
+ * alternative colour schemes to be 'preserved' while switching between them
+ * to explore their effects on the visualisation.
+ * <p>
+ * This sets the colour scheme to 'graduated' by default. Override this if
+ * wanted by calling <code>setGraduatedColour(false)</code> for a simple
+ * colour, or <code>setColourByLabel(true)</code> for colour by label.
*
+ * @param myColour
* @param low
* @param high
* @param noValueColour
* @param min
* @param max
*/
- public FeatureColour(Color low, Color high, Color noValueColour,
- float min, float max)
+ public FeatureColour(Color myColour, Color low, Color high,
+ Color noValueColour, float min, float max)
{
if (low == null)
{
{
high = Color.black;
}
- graduatedColour = true;
- colour = null;
+ colour = myColour;
minColour = low;
maxColour = high;
+ setGraduatedColour(true);
noColour = noValueColour;
threshold = Float.NaN;
isHighToLow = min >= max;
* Sets the 'graduated colour' flag. If true, also sets 'colour by label' to
* false.
*/
- void setGraduatedColour(boolean b)
+ public void setGraduatedColour(boolean b)
{
graduatedColour = b;
if (b)
sb.append(BAR).append(Format.getHexString(getMinColour()))
.append(BAR);
sb.append(Format.getHexString(getMaxColour())).append(BAR);
- String noValue = minColour.equals(noColour) ? NO_VALUE_MIN
- : (maxColour.equals(noColour) ? NO_VALUE_MAX
- : NO_VALUE_NONE);
+
+ /*
+ * 'no value' colour should be null, min or max colour;
+ * if none of these, coerce to minColour
+ */
+ String noValue = NO_VALUE_MIN;
+ if (maxColour.equals(noColour))
+ {
+ noValue = NO_VALUE_MAX;
+ }
+ if (noColour == null)
+ {
+ noValue = NO_VALUE_NONE;
+ }
sb.append(noValue).append(BAR);
if (!isAutoScaled())
{
{
// set graduated color as fading to white for minimum, and
// autoscaling to values on alignment
- FeatureColourI ggc = new FeatureColour(Color.white,
- gc.getColour(), Float.MIN_VALUE, Float.MAX_VALUE);
+ FeatureColourI ggc = new FeatureColour(gc.getColour(),
+ Color.white, gc.getColour(), Color.white,
+ Float.MIN_VALUE, Float.MAX_VALUE);
ggc.setAutoScaled(true);
fr.setColour(ft, ggc);
}
* seq1 feature in columns 4-6 is hidden
* seq2 feature in columns 6-7 is shown
*/
- FeatureColourI fc = new FeatureColour(Color.red, Color.blue, 0f, 10f);
+ FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null,
+ 0f, 10f);
fc.setAboveThreshold(true);
fc.setThreshold(5f);
af.getFeatureRenderer().setColour("Metal", fc);
* seq1 feature in columns 1-5 is hidden
* seq2 feature in columns 6-10 is shown
*/
- FeatureColourI fc = new FeatureColour(Color.red, Color.blue, 0f, 10f);
+ FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null,
+ 0f, 10f);
fc.setAboveThreshold(true);
fc.setThreshold(5f);
alignFrame.getFeatureRenderer().setColour("Metal", fc);
fr.setColour("type2", byLabel);
// type3: by score above threshold
- FeatureColourI byScore = new FeatureColour(Color.BLACK, Color.BLUE, 1,
- 10);
+ FeatureColourI byScore = new FeatureColour(null, Color.BLACK,
+ Color.BLUE, null, 1, 10);
byScore.setAboveThreshold(true);
byScore.setThreshold(2f);
fr.setColour("type3", byScore);
fr.setColour("type4", byAF);
// type5: by attribute CSQ:PolyPhen below threshold
- FeatureColourI byPolyPhen = new FeatureColour(Color.BLACK, Color.BLUE,
- 1, 10);
+ FeatureColourI byPolyPhen = new FeatureColour(null, Color.BLACK,
+ Color.BLUE, null, 1, 10);
byPolyPhen.setBelowThreshold(true);
byPolyPhen.setThreshold(3f);
byPolyPhen.setAttributeName("CSQ", "PolyPhen");
fr.setColour("type2", byLabel);
// type3: by score above threshold
- FeatureColourI byScore = new FeatureColour(Color.BLACK, Color.BLUE, 1,
- 10);
+ FeatureColourI byScore = new FeatureColour(null, Color.BLACK,
+ Color.BLUE, null, 1, 10);
byScore.setAboveThreshold(true);
byScore.setThreshold(2f);
fr.setColour("type3", byScore);
fr.setColour("type4", byAF);
// type5: by attribute CSQ:PolyPhen below threshold
- FeatureColourI byPolyPhen = new FeatureColour(Color.BLACK, Color.BLUE,
- 1, 10);
+ FeatureColourI byPolyPhen = new FeatureColour(null, Color.BLACK,
+ Color.BLUE, null, 1, 10);
byPolyPhen.setBelowThreshold(true);
byPolyPhen.setThreshold(3f);
byPolyPhen.setAttributeName("CSQ", "PolyPhen");
import java.awt.Color;
import java.util.Map;
-import junit.extensions.PA;
-
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import junit.extensions.PA;
+
public class SequenceAnnotationReportTest
{
/*
* then with colour by an attribute the feature lacks
*/
- FeatureColourI fc = new FeatureColour(Color.white, Color.black, 5, 10);
+ FeatureColourI fc = new FeatureColour(null, Color.white, Color.black,
+ null, 5, 10);
fc.setAttributeName("Pfam");
fr.setColour("METAL", fc);
sb.setLength(0);
FeatureRendererModel fr = new FeatureRenderer(null);
Map<String, float[][]> minmax = fr.getMinMax();
- FeatureColourI fc = new FeatureColour(Color.white, Color.blue, 12, 22);
+ FeatureColourI fc = new FeatureColour(null, Color.white, Color.blue,
+ null, 12, 22);
fc.setAttributeName("clinical_significance");
fr.setColour("METAL", fc);
minmax.put("METAL", new float[][] { { 0f, 1f }, null });
// with showDbRefs = true, colour Variant features by clinical_significance
sb.setLength(0);
- FeatureColourI fc = new FeatureColour(Color.green, Color.pink, 2, 3);
+ FeatureColourI fc = new FeatureColour(null, Color.green, Color.pink,
+ null, 2, 3);
fc.setAttributeName("clinical_significance");
fr.setColour("Variant", fc);
sar.createSequenceAnnotationReport(sb, seq, true, true, fr);
*/
Color min = new Color(100, 50, 150);
Color max = new Color(200, 0, 100);
- FeatureColourI fc = new FeatureColour(min, max, 0, 10);
+ FeatureColourI fc = new FeatureColour(null, min, max, null, 0, 10);
fr.setColour("kd", fc);
fr.featuresAdded();
av.setShowSequenceFeatures(true);
*/
Color min = new Color(100, 50, 150);
Color max = new Color(200, 0, 100);
- FeatureColourI fc = new FeatureColour(min, max, 0, 10);
+ FeatureColourI fc = new FeatureColour(null, min, max, null, 0, 10);
fc.setAboveThreshold(true);
fc.setThreshold(5f);
fr.setColour(kdFeature, fc);
* give "Type3" features a graduated colour scheme
* - first with no threshold
*/
- FeatureColourI gc = new FeatureColour(Color.yellow, Color.red, null, 0f,
- 10f);
+ FeatureColourI gc = new FeatureColour(Color.green, Color.yellow,
+ Color.red, null, 0f, 10f);
fr.getFeatureColours().put("Type3", gc);
features = fr.findFeaturesAtColumn(seq, 8);
assertTrue(features.contains(sf4));
* graduated colour by score, no threshold, no score
*
*/
- FeatureColourI gc = new FeatureColour(Color.yellow, Color.red,
- Color.green, 1f, 11f);
+ FeatureColourI gc = new FeatureColour(Color.red, Color.yellow,
+ Color.red, Color.green, 1f, 11f);
fr.getFeatureColours().put("Cath", gc);
assertEquals(fr.getColour(sf1), Color.green);
* threshold is min-max; now score 6 is 1/6 of the way from 5 to 11
* or from yellow(255, 255, 0) to red(255, 0, 0)
*/
- gc = new FeatureColour(Color.yellow, Color.red, Color.green, 5f, 11f);
+ gc = new FeatureColour(Color.red, Color.yellow, Color.red, Color.green,
+ 5f, 11f);
fr.getFeatureColours().put("Cath", gc);
gc.setAutoScaled(false); // this does little other than save a checkbox setting!
assertEquals(fr.getColour(sf2), new Color(255, 213, 0));
* colour by feature attribute value
* first with no value held
*/
- gc = new FeatureColour(Color.yellow, Color.red, Color.green, 1f, 11f);
+ gc = new FeatureColour(Color.red, Color.yellow, Color.red, Color.green,
+ 1f, 11f);
fr.getFeatureColours().put("Cath", gc);
gc.setAttributeName("AF");
assertEquals(fr.getColour(sf2), Color.green);
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import junit.extensions.PA;
-
public class FeatureColourTest
{
}
@Test(groups = { "Functional" })
+ public void testConstructors()
+ {
+ FeatureColourI fc = new FeatureColour();
+ assertNull(fc.getColour());
+ assertTrue(fc.isSimpleColour());
+ assertFalse(fc.isColourByLabel());
+ assertFalse(fc.isGraduatedColour());
+ assertFalse(fc.isColourByAttribute());
+ assertEquals(Color.white, fc.getMinColour());
+ assertEquals(Color.black, fc.getMaxColour());
+
+ fc = new FeatureColour(Color.RED);
+ assertEquals(Color.red, fc.getColour());
+ assertTrue(fc.isSimpleColour());
+ assertFalse(fc.isColourByLabel());
+ assertFalse(fc.isGraduatedColour());
+ assertFalse(fc.isColourByAttribute());
+ assertEquals(ColorUtils.bleachColour(Color.RED, 0.9f),
+ fc.getMinColour());
+ assertEquals(Color.RED, fc.getMaxColour());
+
+ }
+
+ @Test(groups = { "Functional" })
public void testCopyConstructor()
{
/*
/*
* min-max colour
*/
- fc = new FeatureColour(Color.gray, Color.black, 10f, 20f);
+ fc = new FeatureColour(null, Color.gray, Color.black, Color.gray, 10f,
+ 20f);
fc.setAboveThreshold(true);
fc.setThreshold(12f);
fc1 = new FeatureColour(fc);
/*
* min-max-noValue colour
*/
- fc = new FeatureColour(Color.gray, Color.black, Color.green, 10f, 20f);
+ fc = new FeatureColour(Color.red, Color.gray, Color.black, Color.green,
+ 10f, 20f);
fc.setAboveThreshold(true);
fc.setThreshold(12f);
fc1 = new FeatureColour(fc);
assertTrue(fc1.isGraduatedColour());
assertFalse(fc1.isColourByLabel());
+ assertFalse(fc1.isSimpleColour());
assertFalse(fc1.isColourByAttribute());
assertNull(fc1.getAttributeName());
assertTrue(fc1.isAboveThreshold());
assertEquals(Color.gray, fc1.getMinColour());
assertEquals(Color.black, fc1.getMaxColour());
assertEquals(Color.green, fc1.getNoColour());
+ assertEquals(Color.red, fc1.getColour());
assertEquals(10f, fc1.getMin());
assertEquals(20f, fc1.getMax());
/*
* colour by attribute (value)
*/
- fc = new FeatureColour(Color.gray, Color.black, Color.green, 10f, 20f);
+ fc = new FeatureColour(Color.yellow, Color.gray, Color.black,
+ Color.green, 10f, 20f);
fc.setAboveThreshold(true);
fc.setThreshold(12f);
fc.setAttributeName("AF");
assertTrue(fc1.isGraduatedColour());
assertFalse(fc1.isColourByLabel());
assertTrue(fc1.isColourByAttribute());
+ assertFalse(fc1.isSimpleColour());
assertArrayEquals(new String[] { "AF" }, fc1.getAttributeName());
assertTrue(fc1.isAboveThreshold());
assertEquals(12f, fc1.getThreshold());
assertEquals(Color.gray, fc1.getMinColour());
assertEquals(Color.black, fc1.getMaxColour());
assertEquals(Color.green, fc1.getNoColour());
+ assertEquals(Color.yellow, fc1.getColour());
assertEquals(10f, fc1.getMin());
assertEquals(20f, fc1.getMax());
}
@Test(groups = { "Functional" })
- public void testCopyConstructor_minMax()
- {
- /*
- * graduated colour
- */
- FeatureColour fc = new FeatureColour(Color.BLUE, Color.RED, 1f, 5f);
- assertTrue(fc.isGraduatedColour());
- assertFalse(fc.isColourByLabel());
- assertFalse(fc.isColourByAttribute());
- assertNull(fc.getAttributeName());
- assertEquals(1f, fc.getMin());
- assertEquals(5f, fc.getMax());
-
- /*
- * update min-max bounds
- */
- FeatureColour fc1 = new FeatureColour(fc, 2f, 6f);
- assertTrue(fc1.isGraduatedColour());
- assertFalse(fc1.isColourByLabel());
- assertFalse(fc1.isColourByAttribute());
- assertNull(fc1.getAttributeName());
- assertEquals(2f, fc1.getMin());
- assertEquals(6f, fc1.getMax());
- assertFalse((boolean) PA.getValue(fc1, "isHighToLow"));
-
- /*
- * update min-max bounds - high to low
- */
- fc1 = new FeatureColour(fc, 23f, 16f);
- assertTrue(fc1.isGraduatedColour());
- assertFalse(fc1.isColourByLabel());
- assertFalse(fc1.isColourByAttribute());
- assertNull(fc1.getAttributeName());
- assertEquals(23f, fc1.getMin());
- assertEquals(16f, fc1.getMax());
- assertTrue((boolean) PA.getValue(fc1, "isHighToLow"));
-
- /*
- * graduated colour by attribute
- */
- fc1.setAttributeName("AF");
- fc1 = new FeatureColour(fc1, 13f, 36f);
- assertTrue(fc1.isGraduatedColour());
- assertFalse(fc1.isColourByLabel());
- assertTrue(fc1.isColourByAttribute());
- assertArrayEquals(new String[] { "AF" }, fc1.getAttributeName());
- assertEquals(13f, fc1.getMin());
- assertEquals(36f, fc1.getMax());
- assertFalse((boolean) PA.getValue(fc1, "isHighToLow"));
-
- /*
- * colour by label
- */
- fc = new FeatureColour(Color.BLUE, Color.RED, 1f, 5f);
- fc.setColourByLabel(true);
- assertFalse(fc.isGraduatedColour());
- assertTrue(fc.isColourByLabel());
- assertFalse(fc.isColourByAttribute());
- assertNull(fc.getAttributeName());
- assertEquals(1f, fc.getMin());
- assertEquals(5f, fc.getMax());
-
- /*
- * update min-max bounds
- */
- fc1 = new FeatureColour(fc, 2f, 6f);
- assertFalse(fc1.isGraduatedColour());
- assertTrue(fc1.isColourByLabel());
- assertFalse(fc1.isColourByAttribute());
- assertNull(fc1.getAttributeName());
- assertEquals(2f, fc1.getMin());
- assertEquals(6f, fc1.getMax());
-
- /*
- * colour by attribute text
- */
- fc1.setAttributeName("AC");
- fc1 = new FeatureColour(fc1, 13f, 36f);
- assertFalse(fc1.isGraduatedColour());
- assertTrue(fc1.isColourByLabel());
- assertTrue(fc1.isColourByAttribute());
- assertArrayEquals(new String[] { "AC" }, fc1.getAttributeName());
- assertEquals(13f, fc1.getMin());
- assertEquals(36f, fc1.getMax());
- }
-
- @Test(groups = { "Functional" })
public void testGetColor_simpleColour()
{
FeatureColour fc = new FeatureColour(Color.RED);
* score 0 to 100
* gray(128, 128, 128) to red(255, 0, 0)
*/
- FeatureColour fc = new FeatureColour(Color.GRAY, Color.RED, 0f, 100f);
+ FeatureColour fc = new FeatureColour(null, Color.GRAY, Color.RED, null,
+ 0f, 100f);
// feature score is 75 which is 3/4 of the way from GRAY to RED
SequenceFeature sf = new SequenceFeature("type", "desc", 0, 20, 75f,
null);
public void testGetColor_aboveBelowThreshold()
{
// gradient from [50, 150] from WHITE(255, 255, 255) to BLACK(0, 0, 0)
- FeatureColour fc = new FeatureColour(Color.WHITE, Color.BLACK, 50f,
- 150f);
+ FeatureColour fc = new FeatureColour(null, Color.WHITE, Color.BLACK,
+ Color.white, 50f, 150f);
SequenceFeature sf = new SequenceFeature("type", "desc", 0, 20, 70f,
null);
* graduated colour by score, no threshold
* - default constructor sets noValueColor = minColor
*/
- fc = new FeatureColour(Color.GREEN, Color.RED, 12f, 25f);
+ fc = new FeatureColour(null, Color.GREEN, Color.RED, Color.GREEN, 12f,
+ 25f);
String greenHex = Format.getHexString(Color.GREEN);
String expected = String.format(
"domain\tscore|%s|%s|noValueMin|abso|12.0|25.0|none", greenHex,
/*
* graduated colour by score, no threshold, no value gets min colour
*/
- fc = new FeatureColour(Color.GREEN, Color.RED, Color.GREEN, 12f, 25f);
+ fc = new FeatureColour(Color.RED, Color.GREEN, Color.RED, Color.GREEN,
+ 12f, 25f);
expected = String.format(
"domain\tscore|%s|%s|noValueMin|abso|12.0|25.0|none", greenHex,
redHex);
/*
* graduated colour by score, no threshold, no value gets max colour
*/
- fc = new FeatureColour(Color.GREEN, Color.RED, Color.RED, 12f, 25f);
+ fc = new FeatureColour(Color.RED, Color.GREEN, Color.RED, Color.RED,
+ 12f, 25f);
expected = String.format(
"domain\tscore|%s|%s|noValueMax|abso|12.0|25.0|none", greenHex,
redHex);
* graduated colour based on attribute value for AF
* given a min-max range of 0-100
*/
- FeatureColour fc = new FeatureColour(new Color(50, 100, 150),
- new Color(150, 200, 250), Color.yellow, 0f, 100f);
+ FeatureColour fc = new FeatureColour(Color.white,
+ new Color(50, 100, 150), new Color(150, 200, 250), Color.yellow,
+ 0f, 100f);
String attName = "AF";
fc.setAttributeName(attName);