2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Nokia. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.util.drawing;
26 import org.apache.batik.svggen.SVGGraphics2D;
27 import org.w3c.dom.Document;
28 import org.w3c.dom.Element;
29 import org.w3c.dom.Node;
31 public class DocumentBuilder {
32 private final Document groupingDocument;
33 private final Document documentFactory;
35 static final String DATA_ELEMENT_ID_ATTRIBUTE = "data-element-id";
37 DocumentBuilder(Document groupingDocument, Document documentFactory) {
38 this.groupingDocument = groupingDocument;
39 this.documentFactory = documentFactory;
42 void pushChangestoDocument(SVGGraphics2D g2d, String dataElementId) {
44 this.documentFactory.createElementNS(SVGGraphics2D.SVG_NAMESPACE_URI,
45 SVGGraphics2D.SVG_G_TAG);
46 element.setAttribute(DATA_ELEMENT_ID_ATTRIBUTE, dataElementId);
48 Node node = this.groupingDocument.importNode(element, true);
49 this.groupingDocument.getDocumentElement().appendChild(node);
52 Document getGroupingDocument() {
53 return groupingDocument;