@Test public void testAsRasterData() throws Exception { System.out.println(" testRasterData"); setupParameters(data, colors); parameters.set(0, ff2.literal("RasterData")); parameters.add(ff2.literal(InterpolateFunction.METHOD_COLOR)); parameters.add(ff2.literal(InterpolateFunction.MODE_LINEAR)); Function fn = finder.findFunction("interpolate", parameters); Color result = null; for (int i = 1; i < data.length; i++) { double rasterValue = (data[i] + data[i-1]) / 2.0; result = fn.evaluate(rasterValue, Color.class); Color expected = new Color( (int) Math.round((colors[i].getRed() + colors[i-1].getRed()) / 2.0), (int) Math.round((colors[i].getGreen() + colors[i-1].getGreen()) / 2.0), (int) Math.round((colors[i].getBlue() + colors[i-1].getBlue()) / 2.0) ); assertEquals(expected, result); } for (int i = 0; i < data.length; i++) { result = fn.evaluate(data[i], Color.class); assertEquals(colors[i], result); } result = fn.evaluate(Double.valueOf(data[0] - 10), Color.class); assertEquals(colors[0], result); result = fn.evaluate(Double.valueOf(data[data.length - 1] + 10), Color.class); assertEquals(colors[colors.length - 1], result); }
public Object evaluate(Object object) { return evaluate(object, Object.class); }
InterpolateFunction implements Function { public Object evaluate(Object object) { return evaluate(object, Object.class); } }
InterpolateFunction implements Function { public Object evaluate(Object object) { return evaluate(object, Object.class); } InterpolateFunction();  InterpolateFunction(List<Expression> parameters, Literal fallback); }
InterpolateFunction implements Function { public Object evaluate(Object object) { return evaluate(object, Object.class); } InterpolateFunction();  InterpolateFunction(List<Expression> parameters, Literal fallback); String getName(); FunctionName getFunctionName(); List<Expression> getParameters(); Object accept(ExpressionVisitor visitor, Object extraData); Object evaluate(Object object); T evaluate(Object object, Class<T> context); Literal getFallbackValue(); }
InterpolateFunction implements Function { public Object evaluate(Object object) { return evaluate(object, Object.class); } InterpolateFunction();  InterpolateFunction(List<Expression> parameters, Literal fallback); String getName(); FunctionName getFunctionName(); List<Expression> getParameters(); Object accept(ExpressionVisitor visitor, Object extraData); Object evaluate(Object object); T evaluate(Object object, Class<T> context); Literal getFallbackValue(); static final String MODE_LINEAR; static final String MODE_COSINE; static final String MODE_CUBIC; static final String METHOD_NUMERIC; static final String METHOD_COLOR; static final String RASTER_DATA; static final FunctionName NAME; }