public void visit(ColorMapEntry cme) { if (cme.getOpacity() != null) { checkOpacity(cme.getOpacity()); } }
public void visit(ColorMapEntry colorEntry) { if (colorEntry != null) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute( "", "color", "color", "", colorEntry.getColor().evaluate(null, String.class)); if (colorEntry.getOpacity() != null) { atts.addAttribute( "", "opacity", "opacity", "", colorEntry.getOpacity().toString()); } if (colorEntry.getQuantity() != null) { atts.addAttribute( "", "quantity", "quantity", "", colorEntry.getQuantity().toString()); } if (colorEntry.getLabel() != null) { atts.addAttribute("", "label", "label", "", colorEntry.getLabel()); } element("ColorMapEntry", (String) null, atts); } }
@Override public ColorMapEntryBuilder reset(ColorMapEntry original) { if (original == null) { return unset(); } label = original.getLabel(); color = original.getColor(); opacity = original.getOpacity(); quantity = original.getQuantity(); unset = false; return this; }
Expression opacity = entry.getOpacity(); Double opacityValue = null; if (opacity != null) opacityValue = (Double) opacity.evaluate(null, Double.class);
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(copy(colorMapEntry.getQuantity())); if (STRICT && !copy.equals(colorMapEntry)) { throw new IllegalStateException( "Was unable to duplicate provided ColorMapEntry:" + colorMapEntry); } pages.push(copy); }
@Override public Tuple next() { ColorMapEntry entry = entries.next(); return Tuple.of( toColorOrNull(entry.getColor()), toObjOrNull(entry.getOpacity()), toObjOrNull(entry.getQuantity()), entry.getLabel()); }
public void visit(ColorMapEntry colorMapEntry) { ColorMapEntry copy = sf.createColorMapEntry(); copy.setColor(copyCqlExpression(colorMapEntry.getColor())); copy.setLabel(colorMapEntry.getLabel()); copy.setOpacity(copyCqlExpression(colorMapEntry.getOpacity())); copy.setQuantity(copyCqlExpression(colorMapEntry.getQuantity())); if (STRICT && !copy.equals(colorMapEntry)) { throw new IllegalStateException( "Was unable to duplicate provided ColorMapEntry:" + colorMapEntry); } pages.push(copy); } }
private void testBlueAcquaYellowRed(GradientColorMapGenerator colorMapGenerator) { ColorMap colorMap = colorMapGenerator.generateColorMap(10, 100); assertNotNull(colorMap); ColorMapEntry[] colorEntries = colorMap.getColorMapEntries(); assertNotNull(colorEntries); assertEquals(6, colorEntries.length); // First and last color entry are transparent assertEquals(0, colorEntries[0].getOpacity().evaluate(null, Double.class), 0d); assertEquals(0, colorEntries[5].getOpacity().evaluate(null, Double.class), 0d); assertEquals("#0000FF", colorEntries[1].getColor().toString()); assertEquals("#00FFFF", colorEntries[2].getColor().toString()); assertEquals("#FFFF00", colorEntries[3].getColor().toString()); assertEquals("#FF0000", colorEntries[4].getColor().toString()); assertEquals("10.0", colorEntries[1].getQuantity().toString()); assertEquals("40.0", colorEntries[2].getQuantity().toString()); assertEquals("70.0", colorEntries[3].getQuantity().toString()); assertEquals("100.0", colorEntries[4].getQuantity().toString()); }
public void visit(ColorMapEntry cme) { if(cme.getOpacity() != null) { checkOpacity(cme.getOpacity()); } }
@Test public void testSVG() throws FileNotFoundException, IOException, SAXException, ParserConfigurationException { final File svgFile = TestData.file(this, "sample.svg"); GradientColorMapGenerator colorMapGenerator = GradientColorMapGenerator.getColorMapGenerator(svgFile); ColorMap colorMap = colorMapGenerator.generateColorMap(10, 80); assertNotNull(colorMap); ColorMapEntry[] colorEntries = colorMap.getColorMapEntries(); assertNotNull(colorEntries); assertEquals(6, colorEntries.length); // First and last color entry are transparent assertEquals(0, colorEntries[0].getOpacity().evaluate(null, Double.class), 0d); assertEquals(0, colorEntries[5].getOpacity().evaluate(null, Double.class), 0d); assertEquals("#0000FF", colorEntries[1].getColor().toString()); assertEquals("#00FFFF", colorEntries[2].getColor().toString()); assertEquals("#FFFF00", colorEntries[3].getColor().toString()); assertEquals("#FF0000", colorEntries[4].getColor().toString()); assertEquals("17.0", colorEntries[1].getQuantity().toString()); assertEquals("38.0", colorEntries[2].getQuantity().toString()); assertEquals("66.0", colorEntries[3].getQuantity().toString()); assertEquals("80.0", colorEntries[4].getQuantity().toString()); }
private void assertEntry(ColorMapEntry entry, double quantity, Color color, float opacity) { assertEquals(quantity, entry.getQuantity().evaluate(null, Double.class), 0d); assertEquals(color, entry.getColor().evaluate(null, Color.class)); assertEquals(opacity, entry.getOpacity().evaluate(null, Double.class), 0.01f); } }
@Test public void testRGBAcolors() throws FileNotFoundException, IOException, SAXException, ParserConfigurationException { GradientColorMapGenerator colorMapGenerator = GradientColorMapGenerator.getColorMapGenerator( "rgba(0,0,0,1);rgba(255,0,0,0.1);rgba(0,0,255,0)"); ColorMap colorMap = colorMapGenerator.generateColorMap(10, 100); assertNotNull(colorMap); ColorMapEntry[] colorEntries = colorMap.getColorMapEntries(); assertNotNull(colorEntries); assertEquals(5, colorEntries.length); // first and last fully transparent assertEquals(0, colorEntries[0].getOpacity().evaluate(null, Double.class), 0d); assertEquals(0, colorEntries[4].getOpacity().evaluate(null, Double.class), 0d); // checking colors and ranges assertEntry(colorEntries[1], 10, Color.BLACK, 1f); assertEntry(colorEntries[2], 55, Color.RED, 0.1f); assertEntry(colorEntries[3], 100, Color.BLUE, 0f); }
@Test public void testColourMapExpression() throws Exception { String yaml = "raster: \n" + " color-map:\n" + " type: values\n" + " entries:\n" + " - " + tuple("#ff0000", "1.0", "0", "start") + "\n" + " - " + tuple("#00ff00", "1.0", "500", "middle") + "\n" + " - " + tuple("#0000ff", "'${pow(0.75, 1.2)}'", "1000", "end") + "\n" + // Expression containing comma needs to be quoted ""; StyledLayerDescriptor sld = Ysld.parse(yaml); FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0); RasterSymbolizer symb = (RasterSymbolizer) fs.rules().get(0).symbolizers().get(0); // need to use the geotools.styling interface as it provides the accessors for the entries. ColorMap map = (ColorMap) symb.getColorMap(); assertThat( map.getColorMapEntry(2).getOpacity(), function("pow", literal(0.75), literal(1.2))); }
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()); }
@Override public void visit(ColorMapEntry colorMapEntry) { if (colorMapEntry.getColor() != null) { //colorMapEntry.getColor().accept(visitor, extraData) } if (colorMapEntry.getOpacity() != null) { //colorMapEntry.getOpacity().accept(visitor, extraData) } if (colorMapEntry.getQuantity() != null) { //colorMapEntry.getQuantity().accept(visitor, extraData) } }
public void visit(ColorMapEntry colorEntry) { if (colorEntry != null) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "color", "color", "",colorEntry.getColor().evaluate(null, String.class)); if (colorEntry.getOpacity() != null) { atts.addAttribute("", "opacity", "opacity", "", colorEntry.getOpacity().toString()); } if (colorEntry.getQuantity() != null) { atts.addAttribute("", "quantity", "quantity", "", colorEntry.getQuantity().toString()); } if (colorEntry.getLabel() != null) { atts.addAttribute("", "label", "label", "", colorEntry.getLabel()); } element("ColorMapEntry", (String) null, atts); } }
public void setEdited(ColorMapEntry entry) { this.entry = entry; if (entry != null) { guiColor.setExpression(entry.getColor()); guiLabel.setText(entry.getLabel()); guiOpacity.setExpression(entry.getOpacity()); guiQuantity.setExpression(entry.getQuantity()); } }
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); }
@Test public void testRasterWithAlphaChannel() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Alpha channel</Title> // <FeatureTypeStyle> // <Rule> // <RasterSymbolizer> // <ColorMap> // <ColorMapEntry color="#008000" quantity="70" /> // <ColorMapEntry color="#008000" quantity="256" opacity="0"/> // </ColorMap> // </RasterSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("raster", "alpha-channel.sld"); RasterSymbolizer raster = SLD.rasterSymbolizer(style); ColorMapEntry e = raster.getColorMap().getColorMapEntry(0); assertEquals("#008000", Filters.asString(e.getColor())); assertEquals(70, Filters.asInt(e.getQuantity())); e = raster.getColorMap().getColorMapEntry(1); assertEquals("#008000", Filters.asString(e.getColor())); assertEquals(256, Filters.asInt(e.getQuantity())); assertEquals(0, Filters.asInt(e.getOpacity())); }
@Override public Tuple next() { ColorMapEntry entry = entries.next(); return Tuple.of( toColorOrNull(entry.getColor()), toObjOrNull(entry.getOpacity()), toObjOrNull(entry.getQuantity()), entry.getLabel()); }