/** * Creates a graphic with the specified external graphic and size. * * @param graphic the graphic * @param size the size * @return the graphic */ public static GraphicInfo createGraphic(ExternalGraphicInfo graphic, int size) { GraphicInfo graphicInfo = new GraphicInfo(); ChoiceInfo choice = new ChoiceInfo(); choice.setExternalGraphic(graphic); graphicInfo.getChoiceList().add(choice); SizeInfo sizeInfo = new SizeInfo(); sizeInfo.setValue(Integer.toString(size)); graphicInfo.setSize(sizeInfo); return graphicInfo; }
private static RuleInfo createPointRule(Map<String, Object> properties) { RuleInfo rule = new RuleInfo(); rule.setName(getPropValue(STYLENAME, properties, "default")); SymbolizerTypeInfo symbolizer = new PointSymbolizerInfo(); GraphicInfo gi = new GraphicInfo(); ((PointSymbolizerInfo) symbolizer).setGraphic(gi); gi.setSize(createSize(properties)); List<ChoiceInfo> list = new ArrayList<ChoiceInfo>(); ChoiceInfo choiceInfoGraphic = new ChoiceInfo(); list.add(choiceInfoGraphic); ((PointSymbolizerInfo) symbolizer).getGraphic().setChoiceList(list); choiceInfoGraphic.setMark(createMark(properties)); rule.getSymbolizerList().add(symbolizer); return rule; }
private static void extractProperties(PointSymbolizerInfo psi, Map<String, Object> properties) { if (psi.getGraphic() != null && psi.getGraphic() != null) { if (psi.getGraphic().getSize() != null && psi.getGraphic().getSize().getValue() != null) { properties.put(SIZE, Float.valueOf(psi.getGraphic().getSize().getValue())); } if (psi.getGraphic().getChoiceList() != null && psi.getGraphic().getChoiceList().size() > 0) { ChoiceInfo ci = psi.getGraphic().getChoiceList().get(0); if (ci.getMark() != null) { if (ci.getMark().getStroke() != null && ci.getMark().getStroke().getCssParameterList() != null) { List<CssParameterInfo> plist = ci.getMark().getStroke().getCssParameterList(); properties.put(STROKECOLOR, extractCssPropertyValue(STROKECOLOR, plist, DEFAULT_STROKECOLOR)); properties.put(STROKEOPACITY, extractCssPropertyValue(STROKEOPACITY, plist, DEFAULT_STROKEOPACITY)); properties.put(STROKEWIDTH, extractCssPropertyValue(STROKEWIDTH, plist, DEFAULT_STROKEWIDTH)); } if (ci.getMark().getFill() != null && ci.getMark().getFill().getCssParameterList() != null) { List<CssParameterInfo> plist = ci.getMark().getFill().getCssParameterList(); properties.put(FILLCOLOR, extractCssPropertyValue(FILLCOLOR, plist, DEFAULT_FILLCOLOR)); properties.put(FILLOPACITY, extractCssPropertyValue(FILLOPACITY, plist, DEFAULT_FILLOPACITY)); } if (ci.getMark().getWellKnownName() != null && ci.getMark().getWellKnownName().getWellKnownName() != null) { properties.put(WELLKNOWNNAME, ci.getMark().getWellKnownName().getWellKnownName()); } } } } }
/** * Creates a graphic with the specified mark and size. * * @param mark the mark * @param size the size * @return the graphic */ public static GraphicInfo createGraphic(MarkInfo mark, int size) { GraphicInfo graphicInfo = new GraphicInfo(); ChoiceInfo choice = new ChoiceInfo(); choice.setMark(mark); graphicInfo.getChoiceList().add(choice); SizeInfo sizeInfo = new SizeInfo(); sizeInfo.setValue(Integer.toString(size)); graphicInfo.setSize(sizeInfo); return graphicInfo; }