use of com.sldeditor.colourramp.ramp.ColourRampData in project sldeditor by robward-scisys.
the class ColourRampTest method testColourRamp.
/**
* Test method for {@link com.sldeditor.colourramp.ColourRamp#ColourRamp()}.
*/
@Test
public void testColourRamp() {
ColourRamp ramp = new ColourRamp();
assertEquals(Color.BLACK, ramp.getStartColour());
assertEquals(Color.WHITE, ramp.getEndColour());
Color expectedStart = Color.red;
Color expectedEnd = Color.pink;
ramp.setColourRamp(expectedStart, expectedEnd);
assertEquals(expectedStart, ramp.getStartColour());
assertEquals(expectedEnd, ramp.getEndColour());
Color expectedEnd2 = Color.cyan;
ramp.addColour(expectedEnd2);
assertEquals(expectedStart, ramp.getStartColour());
assertEquals(expectedEnd2, ramp.getEndColour());
assertEquals(3, ramp.getColourList().size());
ImageIcon icon1 = ramp.getImageIcon(false);
assertNotNull(icon1);
ImageIcon icon2 = ramp.getImageIcon(true);
assertNotNull(icon2);
FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
ColourRampData data = new ColourRampData();
Expression expectedMinValue = ff.literal(1);
Expression expectedMaxValue = ff.literal(10);
data.setColourRamp(ramp);
data.setMinValue(1);
data.setMaxValue(10);
Expression actualStart = ramp.getColour(data, expectedMinValue, false);
@SuppressWarnings("unused") Expression actualEnd = ramp.getColour(data, expectedMaxValue, false);
assertEquals(ColourUtils.toColour(actualStart.toString()), expectedStart);
// Can't test end value
// assertEquals(ColourUtils.toColour(actualEnd.toString()), expectedEnd2);
// Reverse colours
actualStart = ramp.getColour(data, expectedMinValue, true);
actualEnd = ramp.getColour(data, expectedMaxValue, true);
assertEquals(ColourUtils.toColour(actualStart.toString()), expectedEnd2);
// Can't test end value
// assertEquals(ColourUtils.toColour(actualEnd.toString()), expectedStart);
}
use of com.sldeditor.colourramp.ramp.ColourRampData in project sldeditor by robward-scisys.
the class ColourRampDataTest method testColourRampData.
/**
* Test method for {@link com.sldeditor.colourramp.ramp.ColourRampData#ColourRampData()}.
*/
@Test
public void testColourRampData() {
ColourRampData obj = new ColourRampData();
assertNull(obj.getColourRamp());
assertEquals(0, obj.getMaxValue());
assertEquals(0, obj.getMinValue());
assertFalse(obj.reverseColours());
int expectedMinValue = 42;
obj.setMinValue(expectedMinValue);
assertEquals(expectedMinValue, obj.getMinValue());
int expectedMaxValue = 69;
obj.setMaxValue(expectedMaxValue);
assertEquals(expectedMaxValue, obj.getMaxValue());
ColourRamp colourRamp = new ColourRamp();
obj.setColourRamp(colourRamp);
assertEquals(colourRamp, obj.getColourRamp());
obj.setReverseColours(true);
assertTrue(obj.reverseColours());
}
Aggregations