/** * create a fill of color * * @param fillColor the color of the fill * @return the fill created */ public Fill createFill(Color fillColor) { return createFill(colorExpression(fillColor)); }
/** * create a fill with color, background color and opacity supplied and uses the graphic supplied * for the fill * * @param color the foreground color * @param backgroundColor the background color * @param opacity the opacity of the fill * @param fill the graphic object to use to fill the fill * @return the fill created */ public Fill createFill(Color color, Color backgroundColor, double opacity, Graphic fill) { return sf.createFill( colorExpression(color), colorExpression(backgroundColor), literalExpression(opacity), fill); }
/** * create a fill with the supplied color and opacity * * @param fillColor the color to fill with * @param opacity the opacity of the fill 0 - transparent, 1 - completly filled * @return the fill created */ public Fill createFill(Color fillColor, double opacity) { return sf.createFill(colorExpression(fillColor), literalExpression(opacity)); }
/** * create a stroke with the supplied width and color * * @param color the color of the line * @param width the width of the line * @return the created stroke */ public Stroke createStroke(Color color, double width) { return sf.createStroke(colorExpression(color), literalExpression(width)); }
/** * create a stroke with color, width and opacity supplied * * @param color the color of the line * @param width the width of the line * @param opacity the opacity or <I>see throughness</I> of the line, 0 - is transparent, 1 is * completely drawn * @return the stroke created */ public Stroke createStroke(Color color, double width, double opacity) { return sf.createStroke( colorExpression(color), literalExpression(width), literalExpression(opacity)); }
/** * 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; }
@Test public void testConstantFunction() { Function cos = ff.function("cos", ff.literal(Math.toRadians(Math.PI))); Symbolizer ls = sb.createLineSymbolizer(sb.createStroke(sb.colorExpression(Color.BLACK), cos)); Rule r = sb.createRule(new Symbolizer[] {ls}); MetaBufferEstimator rbe = new MetaBufferEstimator(); // cos(pi) == 1 rbe.visit(r); assertEquals(1, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
/** * create a fill of color * * @param fillColor the color of the fill * * @return the fill created */ public Fill createFill(Color fillColor) { return createFill(colorExpression(fillColor)); }
/** * create a fill of color * * @param fillColor the color of the fill * * @return the fill created */ public Fill createFill(Color fillColor) { return createFill(colorExpression(fillColor)); }
@Test public void testNpePreventionStroke() { Style style = sb.createStyle( sb.createLineSymbolizer( sb.createStroke( sb.colorExpression(Color.BLACK), sb.literalExpression(null)))); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(1, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testLiteralParseStroke() { Style style = sb.createStyle( sb.createLineSymbolizer( sb.createStroke( sb.colorExpression(Color.BLACK), sb.literalExpression("10.0")))); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(10, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testMath() { Add add = ff.add(ff.literal("5"), ff.literal("-2")); Symbolizer ls = sb.createLineSymbolizer(sb.createStroke(sb.colorExpression(Color.BLACK), add)); Rule r = sb.createRule(new Symbolizer[] {ls}); MetaBufferEstimator rbe = new MetaBufferEstimator(); // 5-2 = 3 rbe.visit(r); assertEquals(3, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
/** * create a stroke with the supplied width and color * * @param color the color of the line * @param width the width of the line * * @return the created stroke */ public Stroke createStroke(Color color, double width) { return sf.createStroke(colorExpression(color), literalExpression(width)); }
/** * create a fill with the supplied color and opacity * * @param fillColor the color to fill with * @param opacity the opacity of the fill 0 - transparent, 1 - completly filled * * @return the fill created */ public Fill createFill(Color fillColor, double opacity) { return sf.createFill(colorExpression(fillColor), literalExpression(opacity)); }
@Test public void testPropertyWidth() { Symbolizer ls = sb.createLineSymbolizer( sb.createStroke( sb.colorExpression(Color.BLACK), sb.attributeExpression("gimbo"))); Symbolizer ps = sb.createPolygonSymbolizer(sb.createStroke(12), sb.createFill()); Rule r = sb.createRule(new Symbolizer[] {ls, ps}); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(r); assertEquals(12, rbe.getBuffer()); assertTrue(!rbe.isEstimateAccurate()); }
/** * create a stroke with the supplied width and color * * @param color the color of the line * @param width the width of the line * * @return the created stroke */ public Stroke createStroke(Color color, double width) { return sf.createStroke(colorExpression(color), literalExpression(width)); }
/** * create a fill with the supplied color and opacity * * @param fillColor the color to fill with * @param opacity the opacity of the fill 0 - transparent, 1 - completly filled * * @return the fill created */ public Fill createFill(Color fillColor, double opacity) { return sf.createFill(colorExpression(fillColor), literalExpression(opacity)); }
Expression color = styleBuilder.colorExpression(Color.RED); Expression width = styleBuilder.attributeExpression("width"); Stroke stroke = styleBuilder.createStroke(color, width);
@Test public void testEnvironmentWidth() { Symbolizer ls = sb.createLineSymbolizer( sb.createStroke( sb.colorExpression(Color.BLACK), ff.function("env", ff.literal("thickness"), ff.literal(10)))); Rule r = sb.createRule(new Symbolizer[] {ls}); MetaBufferEstimator rbe = new MetaBufferEstimator(); // no env variable, fall back on the default value rbe.visit(r); assertEquals(10, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); // set the env variable EnvFunction.setLocalValue("thickness", 15); try { rbe.visit(r); assertEquals(15, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); } finally { EnvFunction.clearLocalValues(); } }
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()); }