/** * create font of supplied family and size * * @param fontFamily - the font family * @param fontSize - the size of the font in points * @return the font object created */ public Font createFont(String fontFamily, double fontSize) { Expression family = literalExpression(fontFamily); Expression style = literalExpression(FONT_STYLE_NORMAL); Expression weight = literalExpression(FONT_WEIGHT_NORMAL); return sf.createFont(family, style, weight, literalExpression(fontSize)); }
/** * wrapper round Stylefactory Method * * @param x - the x displacement * @param y - the y displacement * @return the Displacement created */ public Displacement createDisplacement(double x, double y) { return sf.createDisplacement(literalExpression(x), literalExpression(y)); }
/** * wrapper round Stylefactory Method * * @param x - the x coordinate of the anchor * @param y - the y coordinate of the anchor * @return the AnchorPoint created */ public AnchorPoint createAnchorPoint(double x, double y) { return sf.createAnchorPoint(literalExpression(x), literalExpression(y)); }
/** * wrapper round StyleFactory method to create halo * * @param fill - the fill of the halo * @param radius - the width of the halo * @return the new halo */ public Halo createHalo(Fill fill, double radius) { return sf.createHalo(fill, literalExpression(radius)); }
/** * wrapper round Stylefactory Method * * @param offset - the distance between the line and the label * @return the LinePlacement created */ public LinePlacement createLinePlacement(double offset) { return sf.createLinePlacement(literalExpression(offset)); }
/** * 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)); }
/** * create a default fill 50% gray * * @return the fill created */ public Fill createFill() { Fill f = sf.getDefaultFill(); f.setColor(literalExpression("#808080")); f.setBackgroundColor(literalExpression("#808080")); f.setOpacity(literalExpression(1.0)); return f; }
/** * 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 the named mark * * @param wellKnownName the wellknown name of the mark * @return the mark created */ public Mark createMark(String wellKnownName) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); return mark; }
/** * wrapper round Stylefactory Method * * @param anchorX - the X coordinate * @param anchorY - the Y coordinate * @param rotation - the rotaion of the label * @return the pointplacement created */ public PointPlacement createPointPlacement(double anchorX, double anchorY, double rotation) { AnchorPoint anchorPoint = createAnchorPoint(anchorX, anchorY); return sf.createPointPlacement(anchorPoint, null, literalExpression(rotation)); }
/** * 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 textsymbolizer which doesn't change * * @param color the color of the text * @param font the font to use * @param label the label to use * @return the new textsymbolizer */ public TextSymbolizer createStaticTextSymbolizer(Color color, Font font, String label) { return createTextSymbolizer( createFill(color), new Font[] {font}, null, literalExpression(label), null, null); }
/** * wrapper round StyleFactory method to create halo * * @param color - the color of the halo * @param radius - the width of the halo * @return the new halo */ public Halo createHalo(Color color, double radius) { return sf.createHalo(createFill(color), literalExpression(radius)); }
/** * wrapper round StyleFactory method to create halo * * @param color - the color of the halo * @param opacity - the opacity of the halo fill 0 - transparent 1 - solid * @param radius - the width of the halo * @return the new halo */ public Halo createHalo(Color color, double opacity, double radius) { return sf.createHalo(createFill(color, opacity), literalExpression(radius)); }
/** * wrapper round StyleFactory method to create default halo * * @return the new halo */ public Halo createHalo() { return sf.createHalo(createFill(Color.WHITE), literalExpression(1)); }
/** * create a textsymbolizer which doesn't change * * @param color the color of the text * @param fonts an array of fonts to use from the first to last * @param label the label to use * @return the new textsymbolizer */ public TextSymbolizer createStaticTextSymbolizer(Color color, Font[] fonts, String label) { return createTextSymbolizer( createFill(color), fonts, null, literalExpression(label), null, null); }
/** * Creates a raster symbolizer * * @param colorMap The symbolizer color map * @param opacity The whole layer opacity */ public RasterSymbolizer createRasterSymbolizer(ColorMap colorMap, double opacity) { RasterSymbolizer rs = sf.getDefaultRasterSymbolizer(); rs.setColorMap(colorMap); rs.setOpacity(literalExpression(opacity)); return rs; }
@Test public void testLiteralParseGraphics() { Graphic g = sb.createGraphic(); g.setSize(sb.literalExpression("10.0")); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(g); assertEquals(11, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); } }
@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 testSimpleGraphic() { PointSymbolizer ps = sb.createPointSymbolizer( sb.createGraphic(null, sb.createMark(sb.MARK_CIRCLE), null)); ps.getGraphic().setSize(sb.literalExpression(15)); Style style = sb.createStyle(ps); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(16, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }