/** 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 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); }
entry.setQuantity((Expression) children.get(i).getValue()); if (i + 1 >= children.size()) { throw new IllegalArgumentException(
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.setQuantity(filterFactory.literal(quantity.doubleValue()));
e.setQuantity(Util.expression(q.strAt(2), 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 testDynamicQuantity() { entry.setQuantity(ff.literal("${6.0+4.0}")); builder.addColorMapEntry(entry); LinearColorMap colorMap = builder.buildLinearColorMap(); LinearColorMapElement[] domainElements = colorMap.getDomainElements(); assertEquals(1, domainElements.length); assertEquals(10.0, domainElements[0].getInputMinimum(), 0.0); assertEquals(10.0, domainElements[0].getInputMaximum(), 0.0); }
@Test public void testDynamicQuantityEnv() { EnvFunction.setLocalValue("quantity", 10.0); try { entry.setQuantity(ff.literal("${env('quantity')}")); builder.addColorMapEntry(entry); LinearColorMap colorMap = builder.buildLinearColorMap(); LinearColorMapElement[] domainElements = colorMap.getDomainElements(); assertEquals(1, domainElements.length); assertEquals(10.0, domainElements[0].getInputMinimum(), 0.0); assertEquals(10.0, domainElements[0].getInputMaximum(), 0.0); } finally { EnvFunction.clearLocalValues(); } }
ColorMapEntry e1 = styleFactory.createColorMapEntry(); e1.setColor(filterFactory.literal("#000011")); e1.setQuantity(filterFactory.literal(0.0d)); ColorMapEntry e2 = styleFactory.createColorMapEntry(); e2.setColor(filterFactory.literal("#0000EE")); e2.setQuantity( filterFactory.function( "pow", filterFactory.literal(1.2d), filterFactory.literal(2.0d)));
ColorMapEntry e1 = styleFactory.createColorMapEntry(); e1.setColor(filterFactory.literal("#000011")); e1.setQuantity(filterFactory.literal(0.0d)); ColorMapEntry e2 = styleFactory.createColorMapEntry(); e2.setColor(filterFactory.literal("#0000EE")); e2.setQuantity(filterFactory.literal(1.0d)); symb.getColorMap().addColorMapEntry(e1); symb.getColorMap().addColorMapEntry(e2);
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 apply() { if (entry != null) { entry.setColor(guiColor.getExpression()); entry.setLabel(guiLabel.getText()); entry.setOpacity(guiOpacity.getExpression()); entry.setQuantity(guiQuantity.getExpression()); } }
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()); }