org.jboss.elemento.svg.SVG Maven / Gradle / Ivy
/*
* Copyright 2023 Red Hat
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.elemento.svg;
import static elemental2.dom.DomGlobal.document;
import static jsinterop.base.Js.cast;
public final class SVG {
// ------------------------------------------------------ elements
public static SVGContainerBuilder svg() {
return svgContainer("svg", SVGElement.class);
}
public static SVGContainerBuilder circle() {
return svgContainer("circle", SVGCircleElement.class);
}
public static SVGContainerBuilder ellipse() {
return svgContainer("ellipse", SVGEllipseElement.class);
}
public static SVGContainerBuilder g() {
return svgContainer("g", SVGGElement.class);
}
public static SVGContainerBuilder line() {
return svgContainer("line", SVGLineElement.class);
}
public static SVGContainerBuilder path() {
return svgContainer("path", SVGPathElement.class);
}
public static SVGContainerBuilder polygon() {
return svgContainer("polygon", SVGPolygonElement.class);
}
public static SVGContainerBuilder rect() {
return svgContainer("rect", SVGRectElement.class);
}
public static SVGContainerBuilder text() {
return svgContainer("text", SVGTextElement.class);
}
// ------------------------------------------------------ factories & wrappers
/** Returns a builder for the specified SVG element. */
public static SVGElementBuilder svgElement(String element, Class type) {
return new SVGElementBuilder<>(createSvgElement(element, type));
}
/** Returns a builder for the existing SVG element. */
public static SVGElementBuilder wrapSvgElement(E element) {
return new SVGElementBuilder<>(element);
}
/** Returns a builder for the specified SVG container. */
public static SVGContainerBuilder svgContainer(String element, Class type) {
return new SVGContainerBuilder<>(createSvgElement(element, type));
}
/** Returns a builder for the existing SVG container. */
public static SVGContainerBuilder wrapSvgContainer(E element) {
return new SVGContainerBuilder<>(element);
}
/** Creates the specified SVG element. */
public static E createSvgElement(String element, Class type) {
return cast(document.createElementNS(SVGElement.NAMESPACE, element));
}
// ------------------------------------------------------ instance
// this is a static helper class, which must never be instantiated!
private SVG() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy