Package org.geotools.styling

Examples of org.geotools.styling.ColorMapEntry


    final List<ColorMapEntry> mapEntries, final HAlign hAlign, final VAlign vAling,
            final Color bkgColor, final double bkgOpacity, final String text,
            final Dimension requestedDimension, final Font labelFont, final Color labelFontColor,
            final boolean fontAntiAliasing, final Color borderColor) {

        final ColorMapEntry previousCME = mapEntries.get(0);
        final ColorMapEntry currentCME = mapEntries.get(1);
        boolean leftEdge;
        if (previousCME == null)
            leftEdge = true;
        else
            leftEdge = false;

        Color color = LegendUtils.color(currentCME);
        final double opacity = LegendUtils.getOpacity(currentCME);
        color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (255 * opacity));
        super.add(new SimpleColorManager(color, opacity, requestedDimension, borderColor));

        String label = currentCME.getLabel();
        double quantity1 = leftEdge ? LegendUtils.getQuantity(currentCME) : LegendUtils
                .getQuantity(previousCME);
        double quantity2 = LegendUtils.getQuantity(currentCME);
        String symbol1 = null, symbol2 = null;
        if (leftEdge)
View Full Code Here


        }
        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

        private ColorMapEntry getColorMapEntry(double value) {
            return getColorMapEntry(value, Double.NaN);
        }

        private ColorMapEntry getColorMapEntry(double min, double range) {
            ColorMapEntry entry = new ColorMapEntryImpl();
            entry.setOpacity(filterFactory.literal(opacity));
            entry.setColor(filterFactory.literal(toHexColor(color)));
            entry.setQuantity(filterFactory.literal(min + (Double.isNaN(range) ? 0 : (percentage*range))));
            return entry;
        }
View Full Code Here

    public ColorMapEntry build() {
        if (unset) {
            return null;
        }

        ColorMapEntry entry = sf.createColorMapEntry();
        entry.setLabel(label);
        entry.setColor(color);
        entry.setOpacity(opacity);
        entry.setQuantity(quantity);

        if (parent == null) {
            reset();
        }
View Full Code Here

        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);
View Full Code Here

        }
        pages.push(copy);
    }

    public void visit(ColorMapEntry colorMapEntry) {
        ColorMapEntry copy = sf.createColorMapEntry();
        copy.setColor(copy(colorMapEntry.getColor()));
        copy.setLabel(colorMapEntry.getLabel());
        copy.setOpacity(copy(colorMapEntry.getOpacity()));
        copy.setQuantity(colorMapEntry.getQuantity());

        if (STRICT && !copy.equals(colorMapEntry)) {
            throw new IllegalStateException("Was unable to duplicate provided ColorMapEntry:" + colorMapEntry);
        }
        pages.push(copy);
    }
View Full Code Here

    }
   
   
    public void testColorMapEntryDuplication() throws Exception {

        ColorMapEntry cme = sf.createColorMapEntry();
        cme.setColor(sb.colorExpression(Color.YELLOW));
        cme.setLabel("thelabel");
        cme.setQuantity(sb.literalExpression(66.66));
        cme.setOpacity(sb.literalExpression(0.77));

        cme.accept(visitor);

        ColorMapEntry cme2 = (ColorMapEntry) visitor.getCopy();

        assertEquals("Colormaps LABEL must be equal after duplication ", cme.getLabel(), cme2
                .getLabel());
        assertEquals("Colormaps QUANTITY must be equal after duplication ", cme.getQuantity(), cme2
                .getQuantity());
        assertEquals("Colormaps COLOR must be equal after duplication ", cme.getColor(), cme2
                .getColor());
        assertEquals("Colormaps OPACITY must be equal after duplication ", cme.getOpacity(), cme2
                .getOpacity());
    }
View Full Code Here

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

        ColorMapEntry entry = styleFactory.createColorMapEntry();

        //&lt;xsd:element ref="se:Data"/&gt;
        entry.setQuantity(filterFactory.literal(node.getChildValue("Data")));
       
        //&lt;xsd:element ref="se:Value"/&gt;
        entry.setColor((Expression) node.getChildValue("Value"));
       
        return entry;
    }
View Full Code Here

        document.getDocumentElement().setAttributeNS(SLD.NAMESPACE, "color", "#000000");
        document.getDocumentElement().setAttributeNS(SLD.NAMESPACE, "opacity", "1.2");
        document.getDocumentElement().setAttributeNS(SLD.NAMESPACE, "quantity", "3.4");
        document.getDocumentElement().setAttributeNS(SLD.NAMESPACE, "label", "someLabel");

        ColorMapEntry entry = (ColorMapEntry) parse();
        assertNotNull(entry);
        assertEquals(org.geotools.styling.SLD.color(entry.getColor()), Color.BLACK);
        assertEquals(Filters.asDouble(entry.getOpacity()), 1.2d, 0d);
        assertEquals(Filters.asDouble(entry.getQuantity()), 3.4d, 0d);
        assertEquals(entry.getLabel(), "someLabel");
    }
View Full Code Here

       
        List<Node> children = node.getChildren();
        int i = 0;
        while(!"Value".equals(children.get(i).getComponent().getName())) i++;
       
        ColorMapEntry entry = styleFactory.createColorMapEntry();
        entry.setColor((Expression)children.get(i++).getValue());
        map.addColorMapEntry(entry);
       
        while(i < children.size()) {
            entry = styleFactory.createColorMapEntry();
            entry.setQuantity((Expression)children.get(i).getValue());
            if (i+1 >= children.size()) {
                throw new IllegalArgumentException("Incorrectly specified color map Threshold/Value pair");
            }
           
            entry.setColor((Expression)children.get(i+1).getValue());
            map.addColorMapEntry(entry);

            i+=2;
        }
       
View Full Code Here

TOP

Related Classes of org.geotools.styling.ColorMapEntry

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.