Package org.geotools.styling

Examples of org.geotools.styling.ColorMap


                intervals = true;
            } else {
                intervals = false;
            }
        }
        ColorMap colorMap = new ColorMapImpl();

        // Adding transparent color entry before the min
        double start = min - (intervals ? 0 : 1E-2);
        ColorMapEntry entry = entries[0].getColorMapEntry(start);
        entry.setOpacity(filterFactory.literal(0));
        colorMap.addColorMapEntry(entry);

        if (intervals) {
            colorMap.setType(ColorMap.TYPE_INTERVALS);
            for (int i = 1; i < numEntries - 1; i += 2) {
                colorMap.addColorMapEntry(entries[i].getColorMapEntry(min, range));
            }
        } else {
            colorMap.setType(ColorMap.TYPE_RAMP);
            for (int i = 0; i < numEntries - 1; i ++) {
                colorMap.addColorMapEntry(entries[i].getColorMapEntry(min, range));
            }
        }
        colorMap.addColorMapEntry(entries[numEntries - 1].getColorMapEntry(max));

        // Adding transparent color entry after the max
        ColorMapEntry entryEnd = entries[numEntries - 1].getColorMapEntry(max + 1E-2);
        entryEnd.setOpacity(filterFactory.literal(0));
        colorMap.addColorMapEntry(entryEnd);

        return colorMap;
    }
View Full Code Here


    // /////////////////////////////////////////////////////////////////////
    //
    // COLOR MAP
    //
    // /////////////////////////////////////////////////////////////////////
    final ColorMap cm = rs.getColorMap();
    cmNode.addSource(csNode);
    csNode.addSink(cmNode);
    cmNode.visit(cm);

    // /////////////////////////////////////////////////////////////////////
View Full Code Here

        entry();

        if (unset) {
            return null;
        }
        ColorMap colorMap = sf.createColorMap();
        colorMap.setType(type);
        colorMap.setExtendedColors(extended);
        for (ColorMapEntry entry : entries) {
            colorMap.addColorMapEntry(entry);
        }
        if (parent == null) {
            reset();
        }
        return colorMap;
View Full Code Here

        ImageAssert.assertEquals(reference, image, 0);
    }

    private RasterSymbolizer buildRainColorMap() {
        StyleBuilder sb = new StyleBuilder();
        ColorMap colorMap = sb
                .createColorMap(new String[] { "1", "2", "3", "4" }, new double[] { 0, 100, 2000,
                        5000 }, new Color[] { Color.RED, Color.WHITE, Color.GREEN, Color.BLUE },
                        ColorMap.TYPE_RAMP);
        RasterSymbolizer rasterSymbolizer = sb.createRasterSymbolizer(colorMap, 1d);
        return rasterSymbolizer;
View Full Code Here

    return copy;
  }

   
    public void visit(ColorMap colorMap) {
        ColorMap copy = sf.createColorMap();
        copy.setType(colorMap.getType());
        copy.setExtendedColors(colorMap.getExtendedColors());
        ColorMapEntry[] entries = colorMap.getColorMapEntries();
        if (entries != null) {
            for (int i = 0; i < entries.length; i++) {
                ColorMapEntry entry = entries[i];
                copy.addColorMapEntry(copy(entry));
            }
        }
        if (STRICT && !copy.equals(colorMap)) {
            throw new IllegalStateException("Was unable to duplicate provided ColorMap:" + colorMap);
        }
        pages.push(copy);
    }
View Full Code Here

    }

    public void testNormal() throws Exception {
        SLDMockData.colorMap(document, document);

        ColorMap colorMap = (ColorMap) parse();
        assertNotNull(colorMap);

        ColorMapEntry[] entries = colorMap.getColorMapEntries();

        assertNotNull(entries);
        assertEquals(2, entries.length);
        assertEquals(org.geotools.styling.SLD.color(entries[0].getColor()), Color.BLACK);
        assertEquals(org.geotools.styling.SLD.color(entries[1].getColor()), Color.WHITE);
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {

        ColorMap map = (ColorMap) node.getChildValue("Categorize");
        if (map == null) {
            map = (ColorMap) node.getChildValue("Interpolate");
        }
       
        if (map == null) {
View Full Code Here

        </RasterSymbolizer>*/
        RasterSymbolizer sym = (RasterSymbolizer) parse("example-rastersymbolizer1.xml");
        assertEquals(1.0, sym.getOpacity().evaluate(null, Double.class));
        assertEquals(OverlapBehavior.AVERAGE, sym.getOverlapBehavior());
       
        ColorMap map = sym.getColorMap();
        assertNotNull(map);
        assertEquals(20, map.getColorMapEntries().length);
       
        //
        Color c = map.getColorMapEntry(0).getColor().evaluate(null, Color.class);
        assertEquals(0, c.getRed());
        assertEquals(255, c.getGreen());
        assertEquals(0, c.getBlue());
       
        c = map.getColorMapEntry(1).getColor().evaluate(null, Color.class);
        assertEquals(0, c.getRed());
        assertEquals(250, c.getGreen());
        assertEquals(0, c.getBlue());
        assertEquals(-417d, map.getColorMapEntry(1).getQuantity().evaluate(null, Double.class));
       
        c = map.getColorMapEntry(19).getColor().evaluate(null, Color.class);
        assertEquals(Color.WHITE, c);
        assertEquals(13000d, map.getColorMapEntry(19).getQuantity().evaluate(null, Double.class));
    }
View Full Code Here

        assertEquals("2", ch[1].getChannelName());
        assertEquals(2.5, ch[1].getContrastEnhancement().getGammaValue().evaluate(null, Double.class));
        assertEquals("3", ch[2].getChannelName());
        assertEquals(ContrastMethod.NORMALIZE, ch[2].getContrastEnhancement().getMethod());
       
        ColorMap map = sym.getColorMap();
        assertNotNull(map);
        assertEquals(2, map.getColorMapEntries().length);
       
        Color c = map.getColorMapEntry(0).getColor().evaluate(null, Color.class);
        assertEquals(Color.BLACK, c);
       
        c = map.getColorMapEntry(1).getColor().evaluate(null, Color.class);
        assertEquals(Color.WHITE, c);
       
        assertEquals(1.0, sym.getContrastEnhancement().getGammaValue().evaluate(null, Double.class));
    }
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {

        ColorMap map = styleFactory.createColorMap();
       
        for (ColorMapEntry e : (List<ColorMapEntry>) node.getChildValues(ColorMapEntry.class)) {
            map.addColorMapEntry(e);
        }
       
        return map;
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.ColorMap

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.