/** Internal parse method - made protected for unit testing */ protected ColorMapEntry parseColorMapEntry(Node root) { ColorMapEntry symbol = factory.createColorMapEntry(); NamedNodeMap atts = root.getAttributes(); if (atts.getNamedItem(colorMapLabelString) != null) { symbol.setLabel(atts.getNamedItem(colorMapLabelString).getNodeValue()); } if (atts.getNamedItem(colorMapColorString) != null) { symbol.setColor(ff.literal(atts.getNamedItem(colorMapColorString).getNodeValue())); } if (atts.getNamedItem(colorMapOpacityString) != null) { symbol.setOpacity(ff.literal(atts.getNamedItem(colorMapOpacityString).getNodeValue())); } if (atts.getNamedItem(colorMapQuantityString) != null) { symbol.setQuantity( ff.literal(atts.getNamedItem(colorMapQuantityString).getNodeValue())); } return symbol; }
private void fillColorInEntry(ColorMapEntry startEntry, Color color) { if (color == null) { color = TRANSPARENT; } startEntry.setColor(filterFactory.literal(toHexColor(color))); startEntry.setOpacity(filterFactory.literal(color.getAlpha() / 255.)); }
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; } }
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); }
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); } }
/** * Creates a simple color entity based on a fixed value and a color.<br> * The color alpha will be used as the entry's opacity * * @param quantity The entry's quantity * @param color The entry's color. */ private ColorMapEntry createColorMapEntry(String label, double quantity, Color color) { ColorMapEntry entry = sf.createColorMapEntry(); entry.setQuantity(literalExpression(quantity)); entry.setColor(colorExpression(color)); entry.setOpacity(literalExpression(color.getAlpha() / 255.0)); entry.setLabel(label); return entry; }
@Override 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(); } return entry; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { ColorMapEntry entry = styleFactory.createColorMapEntry(); // <xsd:element ref="se:Data"/> entry.setQuantity(filterFactory.literal(node.getChildValue("Data"))); // <xsd:element ref="se:Value"/> entry.setColor((Expression) node.getChildValue("Value")); return entry; } }
entry.setColor(color);
@Test public void testDynamicColor() { entry.setColor(ff.literal("${strConcat('#FF','0000')}")); builder.addColorMapEntry(entry); LinearColorMap colorMap = builder.buildLinearColorMap(); LinearColorMapElement[] domainElements = colorMap.getDomainElements(); assertEquals(1, domainElements.length); assertEquals(1, domainElements[0].getColors().length); assertEquals(255, domainElements[0].getColors()[0].getRed()); assertEquals(0, domainElements[0].getColors()[0].getGreen()); assertEquals(0, domainElements[0].getColors()[0].getBlue()); }
e.setColor(Util.color(Util.stripQuotes(q.strAt(0)), factory));
@Before public void setUp() { builder = new SLDColorMapBuilder(); builder.setNumberColorMapEntries(1); builder.setLinearColorMapType(LinearColorMapType.TYPE_VALUES); entry = new ColorMapEntryImpl(); entry.setColor(ff.literal("#000000")); entry.setQuantity(ff.literal(1.0)); entry.setOpacity(ff.literal(1.0)); entry.setLabel("label"); envValues = new HashMap<String, Object>(); }
@Test public void testDynamicColorEnv() { EnvFunction.setLocalValue("color", "#FF0000"); try { entry.setColor(ff.literal("${env('color')}")); builder.addColorMapEntry(entry); LinearColorMap colorMap = builder.buildLinearColorMap(); LinearColorMapElement[] domainElements = colorMap.getDomainElements(); assertEquals(1, domainElements.length); assertEquals(1, domainElements[0].getColors().length); assertEquals(255, domainElements[0].getColors()[0].getRed()); assertEquals(0, domainElements[0].getColors()[0].getGreen()); assertEquals(0, domainElements[0].getColors()[0].getBlue()); } finally { EnvFunction.clearLocalValues(); } }
private ColorMapEntry getEntry(Color color, int value) { ColorMapEntry entry = new ColorMapEntryImpl(); entry.setColor(new ColorExp(color)); entry.setQuantity(new ValueExp(value)); return entry; }
private ColorMapEntry getEntry(Color color, int value) { ColorMapEntry entry = new ColorMapEntryImpl(); entry.setColor(new ColorExp(color)); entry.setQuantity(new ValueExp(value)); return entry; }
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); }
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()); }