当前位置: 首页>>代码示例>>Java>>正文


Java DOMUtilities类代码示例

本文整理汇总了Java中org.apache.batik.dom.util.DOMUtilities的典型用法代码示例。如果您正苦于以下问题:Java DOMUtilities类的具体用法?Java DOMUtilities怎么用?Java DOMUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DOMUtilities类属于org.apache.batik.dom.util包,在下文中一共展示了DOMUtilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: relativizeExternalReferences

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Rewrites external references contained in SVG files.
 *
 * @param path the path of the file to be processed
 */
public static byte[] relativizeExternalReferences(String path)
                                                         throws IOException {
  // use the GenericDOMImplementation here because
  // SVGDOMImplementation adds unwanted attributes to SVG elements
  final SAXDocumentFactory fac = new SAXDocumentFactory(
    new GenericDOMImplementation(),
    XMLResourceDescriptor.getXMLParserClassName());

  final URL here = new URL("file", null, new File(path).getCanonicalPath());
  final StringWriter sw = new StringWriter();

  try {
    final Document doc = fac.createDocument(here.toString());
    relativizeElement(doc.getDocumentElement());
    DOMUtilities.writeDocument(doc, sw);
  }
  catch (DOMException e) {
    throw (IOException) new IOException().initCause(e);
  }

  sw.flush();
  return sw.toString().getBytes();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:29,代码来源:SVGImageUtils.java

示例2: setPrefix

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Node#setPrefix(String)}.
 */
public void setPrefix(String prefix) throws DOMException {
    if (isReadonly()) {
        throw createDOMException
            (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node",
             new Object[] { new Integer(getNodeType()), getNodeName() });
    }

    if (prefix != null &&
        !prefix.equals("") &&
        !DOMUtilities.isValidName(prefix)) {
        throw createDOMException
            (DOMException.INVALID_CHARACTER_ERR, "prefix",
             new Object[] { new Integer(getNodeType()),
                            getNodeName(),
                            prefix });
    }

    this.prefix = prefix;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:23,代码来源:PrefixableStylableExtensionElement.java

示例3: transcode

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Transcodes the specified input in the specified output.
 * @param input the input to transcode
 * @param output the ouput where to transcode
 * @exception TranscoderException if an error occured while transcoding
 */
public void transcode(TranscoderInput input, TranscoderOutput output)
    throws TranscoderException {
    Reader r = input.getReader();
    Writer w = output.getWriter();

    if (r == null) {
        Document d = input.getDocument();
        if (d == null) {
            throw new Error("Reader or Document expected");
        }
        StringWriter sw = new StringWriter( 1024 );
        try {
            DOMUtilities.writeDocument(d, sw);
        } catch ( IOException ioEx ) {
            throw new Error("IO:" + ioEx.getMessage() );
        }
        r = new StringReader(sw.toString());
    }
    if (w == null) {
        throw new Error("Writer expected");
    }
    prettyPrint(r, w);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:30,代码来源:SVGTranscoder.java

示例4: checkChars

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Checks that the characters in the given string are all valid
 * content characters.
 */
protected boolean checkChars(String s) {
    int len = s.length();
    if (xmlVersion.equals(XMLConstants.XML_VERSION_11)) {
        for (int i = 0; i < len; i++) {
            if (!DOMUtilities.isXML11Character(s.charAt(i))) {
                return false;
            }
        }
    } else {
        // assume XML 1.0
        for (int i = 0; i < len; i++) {
            if (!DOMUtilities.isXMLCharacter(s.charAt(i))) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:23,代码来源:AbstractDocument.java

示例5: createElementNS

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Implements the behavior of Document.createElementNS() for this
 * DOM implementation.
 */
public Element createElementNS(AbstractDocument document,
                               String           namespaceURI,
                               String           qualifiedName) {
    if (namespaceURI != null && namespaceURI.length() == 0) {
        namespaceURI = null;
    }
    if (namespaceURI == null)
        return new GenericElement(qualifiedName.intern(), document);

    if (customFactories != null) {
        String name = DOMUtilities.getLocalName(qualifiedName);
        ElementFactory cef;
        cef = (ElementFactory)customFactories.get(namespaceURI, name);
        if (cef != null) {
            return cef.create(DOMUtilities.getPrefix(qualifiedName),
                              document);
        }
    }
    return new GenericElementNS(namespaceURI.intern(),
                                qualifiedName.intern(),
                                document);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:27,代码来源:ExtensibleDOMImplementation.java

示例6: AbstractElementNS

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Creates a new AbstractElementNS object.
 * @param nsURI The element namespace URI.
 * @param qname The element qualified name for validation purposes.
 * @param owner The owner document.
 * @exception DOMException
 *    INVALID_CHARACTER_ERR: Raised if the specified qualified name 
 *   contains an illegal character.
 *   <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is 
 *   malformed, if the <code>qualifiedName</code> has a prefix and the 
 *   <code>namespaceURI</code> is <code>null</code> or an empty string, 
 *   or if the <code>qualifiedName</code> has a prefix that is "xml" and 
 *   the <code>namespaceURI</code> is different from 
 *   "http://www.w3.org/XML/1998/namespace"  .
 */
protected AbstractElementNS(String nsURI, String qname,
                            AbstractDocument owner)
    throws DOMException {
    super(qname, owner);
    if (nsURI != null && nsURI.length() == 0) {
        nsURI = null;
    }
    namespaceURI = nsURI;
    String prefix = DOMUtilities.getPrefix(qname);
    if (prefix != null) {
        if (nsURI == null ||
            ("xml".equals(prefix) &&
             !XMLSupport.XML_NAMESPACE_URI.equals(nsURI))) {
            throw createDOMException
                (DOMException.NAMESPACE_ERR,
                 "namespace.uri",
                 new Object[] { new Integer(getNodeType()),
                                getNodeName(),
                                nsURI });
        }
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:38,代码来源:AbstractElementNS.java

示例7: actionPerformed

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
    addChangesToHistory();

    AbstractCompoundCommand cmd = historyBrowserInterface
            .createRemoveSelectedTreeNodesCommand(null);
    TreePath[] treePaths = tree.getSelectionPaths();
    for (int i = 0; treePaths != null && i < treePaths.length; i++) {
        TreePath treePath = treePaths[i];
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath
                .getLastPathComponent();
        NodeInfo nodeInfo = (NodeInfo) node.getUserObject();
        if (DOMUtilities.isParentOf(nodeInfo.getNode(),
                nodeInfo.getNode().getParentNode())) {
            cmd.addCommand(historyBrowserInterface
                    .createRemoveChildCommand(nodeInfo.getNode()
                            .getParentNode(), nodeInfo.getNode()));
        }
    }
    historyBrowserInterface.performCompoundUpdateCommand(cmd);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:21,代码来源:DOMViewer.java

示例8: updateElementAttributes

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Replaces all of the attributes of the given element with the referent
 * element's attributes.
 *
 * @param elem
 *            The element whose attributes should be replaced
 * @param referentElement
 *            The referentElement to copy the attributes from
 */
private void updateElementAttributes(Element elem, Element referentElement) {
    // Remove all element attributes
    removeAttributes(elem);

    // Copy all attributes from the referent element to the given element
    NamedNodeMap newNodeMap = referentElement.getAttributes();
    for (int i = newNodeMap.getLength() - 1; i >= 0; i--) {
        Node newAttr = newNodeMap.item(i);
        String qualifiedName = newAttr.getNodeName();
        String attributeValue = newAttr.getNodeValue();
        String prefix = DOMUtilities.getPrefix(qualifiedName);
        String namespaceURI = getNamespaceURI(prefix);
        elem.setAttributeNS(namespaceURI, qualifiedName, attributeValue);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:25,代码来源:NodePickerPanel.java

示例9: shouldUpdate

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * If the panel should update its components after dom mutation event.
 * Checks whether any node that is the child node of the node currently
 * being previewed has changed. If true, updates the xml text area of this
 * NodePicker. In case of DOMAttrModiefied mutation event, the additional
 * condition is added - to check whether the attributes of an element that
 * is being previewed are changed. If true, the xml text area is refreshed.
 *
 * @return True if should update
 */
private boolean shouldUpdate(String mutationEventType, Node affectedNode,
        Node currentNode) {
    if (mutationEventType.equals("DOMNodeInserted")) {
        if (DOMUtilities.isAncestorOf(currentNode, affectedNode)) {
            return true;
        }
    } else if (mutationEventType.equals("DOMNodeRemoved")) {
        if (DOMUtilities.isAncestorOf(currentNode, affectedNode)) {
            return true;
        }
    } else if (mutationEventType.equals("DOMAttrModified")) {
        if (DOMUtilities.isAncestorOf(currentNode, affectedNode)
                || currentNode == affectedNode) {
            return true;
        }
    } else if (mutationEventType.equals("DOMCharDataModified")) {
        if (DOMUtilities.isAncestorOf(currentNode, affectedNode)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:33,代码来源:NodePickerPanel.java

示例10: actionPerformed

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
    if (getMode() == VIEW_MODE) {
        enterEditMode();
    }
    // Find the contextElement
    Element contextElement = clonedElement;
    if (getMode() == ADD_NEW_ELEMENT) {
        contextElement = previewElement;
    }
    DefaultTableModel model =
        (DefaultTableModel) attributesTable.getModel();
    int[] selectedRows = attributesTable.getSelectedRows();
    for (int i = 0; i < selectedRows.length; i++) {
        String attrName = (String) model.getValueAt(selectedRows[i], 0);
        if (attrName != null) {
            String prefix = DOMUtilities.getPrefix(attrName);
            String localName = DOMUtilities.getLocalName(attrName);
            String namespaceURI = getNamespaceURI(prefix);
            contextElement.removeAttributeNS(namespaceURI, localName);
        }
    }
    shouldProcessUpdate = false;
    updateAttributesTable(contextElement);
    shouldProcessUpdate = true;
    updateNodeXmlArea(contextElement);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:27,代码来源:NodePickerPanel.java

示例11: setPrefix

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link Node#setPrefix(String)}.
 */
public void setPrefix(String prefix) throws DOMException {
    if (isReadonly()) {
        throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
                                 "readonly.node",
                                 new Object[] { new Integer(getNodeType()),
                                                getNodeName() });
    }
    if (prefix != null &&
        !prefix.equals("") &&
        !DOMUtilities.isValidName(prefix)) {
        throw createDOMException(DOMException.INVALID_CHARACTER_ERR,
                                 "prefix",
                                 new Object[] { new Integer(getNodeType()),
                                                getNodeName(),
                                                prefix });
    }
    this.prefix = prefix;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:XBLOMElement.java

示例12: createElementNS

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Implements the behavior of Document.createElementNS() for this
 * DOM implementation.
 */
public Element createElementNS(AbstractDocument document,
                               String           namespaceURI,
                               String           qualifiedName) {
    if (SVGConstants.SVG_NAMESPACE_URI.equals(namespaceURI)) {
        String name = DOMUtilities.getLocalName(qualifiedName);
        ElementFactory ef = (ElementFactory)factories.get(name);
        if (ef != null)
            return ef.create(DOMUtilities.getPrefix(qualifiedName),
                             document);
        throw document.createDOMException
            (DOMException.NOT_FOUND_ERR, "invalid.element",
             new Object[] { namespaceURI, qualifiedName });
    }

    return super.createElementNS(document, namespaceURI, qualifiedName);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:21,代码来源:SVGDOMImplementation.java

示例13: generateSVGString

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
public String generateSVGString() {
    try {
        //Define a String writer
        StringWriter writer = new StringWriter();
        //Get the SVG document from the root activity i.e. the Process Activity
        SVGDocument svgDoc = getRootActivity().getSVGDocument();
        if (svgDoc != null) {
            this.svgDoc = svgDoc;
        }
        //Method wrapper for SVGTranscoder.
        DOMUtilities.writeDocument(svgDoc, writer);
        writer.close();
        svgStr = writer.toString();
        return svgStr;
    } catch (IOException ioe) {
        log.error("Error Generating SVG String", ioe);
        return null;
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:20,代码来源:SVGImpl.java

示例14: getSvg

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
@ParameterList({ "obj" })
public static _Object getSvg(_Object obj) {

	SvgScene scene = new SvgScene();
	scene.setZoom(0.75f);

	_Object target = obj;
	String svg = null;
	if (target != null) {
		target.drawInternal(null, scene, new Point(0, 0),
				getVM().getObjectRepository());
		
		Writer sw = new StringWriter();
		try {
			DOMUtilities.writeDocument(scene.getDocument(), sw);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// System.out.println(sw.toString());
		svg = sw.toString();
	}

	StringValue sv = getObjectFactory().createString(svg);
	return sv;
}
 
开发者ID:jackhatedance,项目名称:visual-programming,代码行数:27,代码来源:Object.java

示例15: printNode

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Serializes the given node.
 */
public String printNode(Node n) {
    try {
        Writer writer = new StringWriter();
        DOMUtilities.writeNode(n, writer);
        writer.close();
        return writer.toString();
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:14,代码来源:ScriptingEnvironment.java


注:本文中的org.apache.batik.dom.util.DOMUtilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。