Search in sources :

Example 1 with InterpolationBicubic2

use of javax.media.jai.InterpolationBicubic2 in project sldeditor by robward-scisys.

the class InterpolationValues method setValue.

/*
     * (non-Javadoc)
     *
     * @see
     * com.sldeditor.rendertransformation.types.RenderTransformValueInterface#setValue(java.lang.
     * Object)
     */
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;
    if (aValue instanceof LiteralExpressionImpl) {
        String displayName = ((Expression) aValue).toString();
        if (InterpolationNearest.class.getSimpleName().compareTo(displayName) == 0) {
            value = new InterpolationNearest();
        } else if (InterpolationBilinear.class.getSimpleName().compareTo(displayName) == 0) {
            value = new InterpolationBilinear();
        } else if (displayName.startsWith(InterpolationBicubic2.class.getSimpleName())) {
            sampleBits = extractSampleBits(INTERPOLATION_BICUBIC2_PATTERN_MATCH, displayName);
            value = new InterpolationBicubic2(sampleBits);
        } else if (displayName.startsWith(InterpolationBicubic.class.getSimpleName())) {
            sampleBits = extractSampleBits(INTERPOLATION_BICUBIC_PATTERN_MATCH, displayName);
            value = new InterpolationBicubic(sampleBits);
        }
    } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
Also used : InterpolationBicubic(javax.media.jai.InterpolationBicubic) InterpolationNearest(javax.media.jai.InterpolationNearest) InterpolationBicubic2(javax.media.jai.InterpolationBicubic2) MathExpressionImpl(org.geotools.filter.MathExpressionImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) InterpolationBilinear(javax.media.jai.InterpolationBilinear) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 2 with InterpolationBicubic2

use of javax.media.jai.InterpolationBicubic2 in project sldeditor by robward-scisys.

the class InterpolationValuesTest method testInterpolationValues.

/**
 * Test method for {@link
 * com.sldeditor.rendertransformation.types.InterpolationValues#InterpolationValues()}.
 */
@Test
void testInterpolationValues() {
    InterpolationValues testObj = new InterpolationValues();
    testObj.createInstance();
    assertEquals(Arrays.asList(Interpolation.class), testObj.getType());
    Interpolation interpolation = new InterpolationBicubic2(3);
    testObj.setDefaultValue(interpolation);
    assertEquals(String.format("%s(%d)", interpolation.getClass().getSimpleName(), 8), testObj.getExpression().toString());
    // Interpolation value
    testObj.setValue(ff.literal(interpolation.getClass().getSimpleName()));
    assertEquals(String.format("%s(%d)", InterpolationBicubic2.class.getSimpleName(), 8), testObj.getExpression().toString());
    interpolation = new InterpolationBilinear(8, null, false, 1.0, 1);
    testObj.setValue(ff.literal(interpolation.getClass().getSimpleName()));
    assertEquals(InterpolationBilinear.class.getSimpleName(), testObj.getExpression().toString());
    testObj.setValue(ff.literal(String.format("%s(%d)", InterpolationBicubic.class.getSimpleName(), 16)));
    assertEquals(String.format("%s(%d)", InterpolationBicubic.class.getSimpleName(), 16), testObj.getExpression().toString());
    // Literal expression
    interpolation = new InterpolationNearest(null, false, 1.0, 1);
    Expression expectedExpression = ff.literal(interpolation.getClass().getSimpleName());
    testObj.setValue(expectedExpression);
    assertEquals(testObj.getExpression().toString(), InterpolationNearest.class.getSimpleName());
    // Attribute expression
    expectedExpression = ff.property("test");
    testObj.setValue(expectedExpression);
    assertNull(testObj.getExpression());
    // Not set
    testObj.setValue("");
    assertNull(testObj.getExpression());
    FieldConfigBase field = testObj.getField(new FieldConfigCommonData(InterpolationValues.class, FieldIdEnum.INITIAL_GAP, "label", true, false, false));
    assertEquals(FieldConfigEnum.class, field.getClass());
    // Increase code coverage
    TestInterpolationValues testObj2 = new TestInterpolationValues();
    testObj2.populateSymbolType(null);
    SymbolTypeConfig config = new SymbolTypeConfig(String.class);
    testObj2.populateSymbolType(config);
    assertTrue(config.getKeyOrderList().size() > 0);
}
Also used : Interpolation(javax.media.jai.Interpolation) InterpolationBicubic(javax.media.jai.InterpolationBicubic) InterpolationValues(com.sldeditor.rendertransformation.types.InterpolationValues) InterpolationNearest(it.geosolutions.jaiext.interpolators.InterpolationNearest) InterpolationBicubic2(javax.media.jai.InterpolationBicubic2) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) InterpolationBilinear(it.geosolutions.jaiext.interpolators.InterpolationBilinear) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) Test(org.junit.jupiter.api.Test)

Aggregations

InterpolationBicubic (javax.media.jai.InterpolationBicubic)2 InterpolationBicubic2 (javax.media.jai.InterpolationBicubic2)2 Expression (org.opengis.filter.expression.Expression)2 InterpolationValues (com.sldeditor.rendertransformation.types.InterpolationValues)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)1 SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)1 InterpolationBilinear (it.geosolutions.jaiext.interpolators.InterpolationBilinear)1 InterpolationNearest (it.geosolutions.jaiext.interpolators.InterpolationNearest)1 Interpolation (javax.media.jai.Interpolation)1 InterpolationBilinear (javax.media.jai.InterpolationBilinear)1 InterpolationNearest (javax.media.jai.InterpolationNearest)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)1 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)1 MathExpressionImpl (org.geotools.filter.MathExpressionImpl)1 Test (org.junit.jupiter.api.Test)1