Package org.geotools.styling

Examples of org.geotools.styling.ContrastEnhancement


    // /////////////////////////////////////////////////////////////////////
    //
    // CONTRAST ENHANCEMENT
    //
    // /////////////////////////////////////////////////////////////////////
    final ContrastEnhancement ce = rs.getContrastEnhancement();
    ceNode.addSource(cmNode);
    cmNode.addSink(ceNode);
    ceNode.visit(ce);

   
View Full Code Here


     * @param band the image band to use for the greyscale display
     *
     * @return a new Style instance to render the image in greyscale
     */
    private Style createGreyscaleStyle(int band) {
        ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE);
        SelectedChannelType sct = sf.createSelectedChannelType(String.valueOf(band), ce);

        RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
        ChannelSelection sel = sf.channelSelection(sct);
        sym.setChannelSelection(sel);
View Full Code Here

            channelNum[GREEN] = 2;
            channelNum[BLUE] = 3;
        }
        // Now we create a RasterSymbolizer using the selected channels
        SelectedChannelType[] sct = new SelectedChannelType[cov.getNumSampleDimensions()];
        ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE);
        for (int i = 0; i < 3; i++) {
            sct[i] = sf.createSelectedChannelType(String.valueOf(channelNum[i]), ce);
        }
        RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
        ChannelSelection sel = sf.channelSelection(sct[RED], sct[GREEN], sct[BLUE]);
View Full Code Here

    public ContrastEnhancement build() {
        if (unset) {
            return null;
        }
        ContrastEnhancement contrastEnhancement = sf.contrastEnhancement(gamma, method);
        return contrastEnhancement;
    }
View Full Code Here

    }
   
    protected ContrastEnhancement copy(ContrastEnhancement contrast) {
        if( contrast == null ) return null;
       
        ContrastEnhancement copy = sf.createContrastEnhancement();
        copy.setGammaValue( copy( contrast.getGammaValue()));
        copy.setMethod(contrast.getMethod());
        if(contrast.getType() != null) {
            copy.setType(contrast.getType());
        }
        return copy;
    }
View Full Code Here

    }
   
    protected SelectedChannelType copy(SelectedChannelType selectedChannelType) {
        if( selectedChannelType == null ) return null;
       
        ContrastEnhancement enhancement = copy( selectedChannelType.getContrastEnhancement() );
        String name = selectedChannelType.getChannelName();
        SelectedChannelType copy = sf.createSelectedChannelType( name, enhancement);
       
        return copy;
    }
View Full Code Here

        }
        pages.push(copy);
    }
   
    public void visit(ContrastEnhancement contrastEnhancement) {
        final ContrastEnhancement copy = sf.createContrastEnhancement();
        copy.setType(contrastEnhancement.getType());
        copy.setGammaValue(contrastEnhancement.getGammaValue());
        if (STRICT && !copy.equals(contrastEnhancement)) {
            throw new IllegalStateException("Was unable to duplicate provided contrastEnhancement:" + contrastEnhancement);
        }
        pages.push(copy);

    }
View Full Code Here

        assertTrue("Equal objects should return equal hashcodes",controlEqHash == testHash);
    }
   
    public void testContrastEnhancementDuplication() throws Exception {

        ContrastEnhancement ce = sf.createContrastEnhancement();
        ce.setGammaValue(sb.literalExpression(0.5));
        ce.setMethod(ContrastMethod.HISTOGRAM);
        ce.setHistogram();
        ce.accept(visitor);
        ContrastEnhancement ce2 = (ContrastEnhancement) visitor.getCopy();

        assertEquals("Gamma value incorrest after duplication", ((Literal)ce.getGammaValue()).getValue(), ((Literal)ce2.getGammaValue()).getValue());
        assertEquals("ContrastMethod must be equal after duplication ", ce.getMethod(), ce2.getMethod());
        assertEquals("Contrast Type must be equal after duplication ", ((Literal)ce.getType()).getValue()((Literal)ce2.getType()).getValue());

    }
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        ContrastEnhancement ce = styleFactory.createContrastEnhancement();

        if (node.getChildValue("GammaValue") != null) {
            Double gamma = (Double) node.getChildValue("GammaValue");
            ce.setGammaValue(filterFactory.literal(gamma.doubleValue()));
        }

        if (node.getChild("Normalize") != null) {
            ce.setNormalize();
        } else {
            if (node.getChild("Histogram") != null) {
                ce.setHistogram();
            }
        }

        return ce;
    }
View Full Code Here

    }

    public void testHistogram() throws Exception {
        SLDMockData.contrastEnhancement(document, document);

        ContrastEnhancement ce = (ContrastEnhancement) parse();
        assertNotNull(ce);

        assertNotNull(ce.getGammaValue());
        assertEquals(1.23, Filters.asDouble(ce.getGammaValue()), 0d);

        assertNotNull(ce.getType());
        assertEquals("Histogram", Filters.asString(ce.getType()));
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.ContrastEnhancement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.