Here you can find the source of writePath(XMLStreamWriter w, Supplier
Parameter | Description |
---|---|
w | XMLStreamWriter |
cssClass | Supplier of css class or null if none |
fill | Supplier of fill or null if none |
stroke | Supplier of stroke or null if none |
path | Supplier of the path. Must not be null |
public static void writePath(XMLStreamWriter w, Supplier<String> cssClass, Supplier<String> fill, Supplier<String> stroke, Supplier<String> path)
//package com.java2s; //License from project: Apache License import java.util.function.Supplier; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; public class Main { /**/*from ww w . ja v a 2 s . com*/ * Write an SVG Path element * <p> * @param w XMLStreamWriter * @param cssClass Supplier of css class or null if none * @param fill Supplier of fill or null if none * @param stroke Supplier of stroke or null if none * @param path Supplier of the path. Must not be null */ public static void writePath(XMLStreamWriter w, Supplier<String> cssClass, Supplier<String> fill, Supplier<String> stroke, Supplier<String> path) { try { w.writeStartElement("path"); writeSvgAttributes(w, cssClass, fill, stroke); w.writeAttribute("d", path.get()); w.writeEndElement(); } catch (XMLStreamException ex) { throw new RuntimeException(ex); } } /** * Write common attributes to the {@link XMLStreamWriter} * <p> * @param w XMLStreamWriter * @param cssClass Supplier of css class or null if none * @param fill Supplier of fill or null if none * @param stroke Supplier of stroke or null if none * <p> * @throws XMLStreamException on failure */ public static void writeSvgAttributes(XMLStreamWriter w, Supplier<String> cssClass, Supplier<String> fill, Supplier<String> stroke) throws XMLStreamException { if (cssClass != null) { w.writeAttribute("class", cssClass.get()); } if (fill != null) { w.writeAttribute("fill", fill.get()); } if (stroke != null) { w.writeAttribute("stroke", stroke.get()); } } }