use of org.opengis.filter.FilterFactory in project sldeditor by robward-scisys.
the class DetailsUtilitiesTest method testIsSameDisplacementDisplacement.
/**
* Test method for {@link com.sldeditor.ui.detail.DetailsUtilities#isSame(org.geotools.styling.Displacement, org.geotools.styling.Displacement)}.
*/
@Test
public void testIsSameDisplacementDisplacement() {
assertFalse(DetailsUtilities.isSame((Displacement) null, (Displacement) null));
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
// Try values that are the same
Displacement displacement1 = new DisplacementImpl();
displacement1.setDisplacementX(ff.literal(42));
displacement1.setDisplacementY(ff.literal(-2));
Displacement displacement2 = new DisplacementImpl();
displacement2.setDisplacementX(ff.literal("42"));
displacement2.setDisplacementY(ff.literal(-2));
assertTrue(DetailsUtilities.isSame(displacement1, displacement2));
// Try values that are not the same
Displacement displacement3 = new DisplacementImpl();
displacement3.setDisplacementX(ff.literal(1));
displacement3.setDisplacementY(ff.literal(-2));
assertFalse(DetailsUtilities.isSame(displacement1, displacement3));
assertFalse(DetailsUtilities.isSame(displacement2, displacement3));
Displacement displacement4 = new DisplacementImpl();
displacement4.setDisplacementX(ff.literal((Long) 1L));
displacement4.setDisplacementY(ff.literal(-2));
assertFalse(DetailsUtilities.isSame(displacement1, displacement4));
assertFalse(DetailsUtilities.isSame(displacement2, displacement4));
}
use of org.opengis.filter.FilterFactory in project sldeditor by robward-scisys.
the class DetailsUtilitiesTest method testIsSameAnchorPointAnchorPoint.
/**
* Test method for {@link com.sldeditor.ui.detail.DetailsUtilities#isSame(org.geotools.styling.AnchorPoint, org.geotools.styling.AnchorPoint)}.
*/
@Test
public void testIsSameAnchorPointAnchorPoint() {
assertFalse(DetailsUtilities.isSame((AnchorPoint) null, (AnchorPoint) null));
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
// Try values that are the same
AnchorPoint anchorPoint1 = new AnchorPointImpl();
anchorPoint1.setAnchorPointX(ff.literal(0.58));
anchorPoint1.setAnchorPointY(ff.literal(0.1));
AnchorPoint anchorPoint2 = new AnchorPointImpl();
anchorPoint2.setAnchorPointX(ff.literal(0.58));
anchorPoint2.setAnchorPointY(ff.literal("0.1"));
assertTrue(DetailsUtilities.isSame(anchorPoint1, anchorPoint2));
// Try values that are not the same
AnchorPoint anchorPoint3 = new AnchorPointImpl();
anchorPoint3.setAnchorPointX(ff.literal(1.0));
anchorPoint3.setAnchorPointY(ff.literal(0.1));
assertFalse(DetailsUtilities.isSame(anchorPoint1, anchorPoint3));
assertFalse(DetailsUtilities.isSame(anchorPoint2, anchorPoint3));
}
use of org.opengis.filter.FilterFactory in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testExpressionUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#expressionUpdated(org.opengis.filter.expression.Expression)}.
*/
@Test
public void testExpressionUpdated() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
String expressionName = "test expression";
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Expression testExpression = ff.literal(expressionName);
field.expressionUpdated(testExpression);
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expressionName.compareTo(expression.toString()) == 0);
}
use of org.opengis.filter.FilterFactory in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testFunctionUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#functionUpdated(org.opengis.filter.expression.Expression)}.
*/
@Test
public void testFunctionUpdated() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
FunctionName functionName = null;
for (FunctionName func : functionFactory.getFunctionNames()) {
if (func.getName() == "greaterThan") {
functionName = func;
break;
}
}
assertNotNull(functionName);
Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
field.functionUpdated(testExpression);
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_FUNCTION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expression.toString().startsWith(functionName.getName()));
}
use of org.opengis.filter.FilterFactory in project sldeditor by robward-scisys.
the class ColourMapDataTest method testColourMapData.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.colourmap.ColourMapData#ColourMapData()}.
*/
@Test
public void testColourMapData() {
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
ColourMapData actual = new ColourMapData();
String expectedLabel = "abc";
String expectedColour = "#123456";
double expectedOpacity = 0.5;
int expectedQuantity = 42;
actual.setLabel(expectedLabel);
actual.setColour(ff.literal(expectedColour));
actual.setOpacity(ff.literal(expectedOpacity));
actual.setQuantity(ff.literal(expectedQuantity));
assertEquals(actual.getLabel(), expectedLabel);
assertEquals(ColourUtils.fromColour(actual.getColour()), expectedColour);
assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
// Test getNextQuantity with a value
Expression nextQuantity = actual.getNextQuantity();
int iValue = Double.valueOf(nextQuantity.toString()).intValue();
assertTrue(iValue == (expectedQuantity + 1));
// Test getNextQuantity with a function expression set
Divide divide = ff.divide(ff.literal(10.0), ff.literal(2.0));
actual.setQuantity(divide);
nextQuantity = actual.getNextQuantity();
assertEquals(nextQuantity.toString(), actual.getQuantity().toString());
actual.update(null);
// Label
ColourMapData update = new ColourMapData();
String updatedLabel = "new label";
update.setLabel(updatedLabel);
actual.update(update);
assertEquals(actual.getLabel(), updatedLabel);
// Colour
ColourMapData updateColour = new ColourMapData();
String updatedColour = "#234567";
updateColour.setColour(ff.literal(updatedColour));
actual.update(updateColour);
assertEquals(actual.getColourString(), updatedColour);
// Opacity
ColourMapData updateOpacity = new ColourMapData();
double updatedOpacity = 0.25;
updateOpacity.setOpacity(ff.literal(updatedOpacity));
actual.update(updateOpacity);
assertEquals(actual.getOpacity().toString(), String.valueOf(updatedOpacity));
// Quantity
ColourMapData updateQuantity = new ColourMapData();
int updatedQuantity = 78;
updateQuantity.setQuantity(ff.literal(updatedQuantity));
actual.update(updateQuantity);
assertEquals(actual.getQuantity().toString(), String.valueOf(updatedQuantity));
}
Aggregations