use of org.opengis.filter.expression.Divide 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));
}
use of org.opengis.filter.expression.Divide in project polymap4-core by Polymap4.
the class LuceneQueryDialect method supports.
public static boolean supports(Filter _filter) {
final List notSupported = new ArrayList();
_filter.accept(new DefaultFilterVisitor() {
public Object visit(Beyond filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Contains filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Crosses filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Disjoint filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Divide expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(DWithin filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(org.opengis.filter.expression.Function expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(Intersects filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Multiply expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(Overlaps filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Subtract expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(Touches filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Within filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
}, notSupported);
return notSupported.isEmpty();
}
Aggregations