• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DOMUtilities类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: dispatchKeyboardEvent

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Dispatch a DOM 3 Keyboard event.
 */
protected void dispatchKeyboardEvent(String eventType,
                                     GraphicsNodeKeyEvent evt) {
    FocusManager fmgr = context.getFocusManager();
    if (fmgr == null) {
        return;
    }

    Element targetElement = (Element) fmgr.getCurrentEventTarget();
    if (targetElement == null) {
        targetElement = context.getDocument().getDocumentElement();
    }
    DocumentEvent d = (DocumentEvent) targetElement.getOwnerDocument();
    DOMKeyboardEvent keyEvt
        = (DOMKeyboardEvent) d.createEvent("KeyboardEvent");
    String modifiers
        = DOMUtilities.getModifiersList(evt.getLockState(),
                                        evt.getModifiers());
    keyEvt.initKeyboardEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
                               eventType, 
                               true,
                               true,
                               null,
                               mapKeyCodeToIdentifier(evt.getKeyCode()),
                               mapKeyLocation(evt.getKeyLocation()),
                               modifiers);

    try {
        ((EventTarget)targetElement).dispatchEvent(keyEvt);
    } catch (RuntimeException e) {
        ua.displayError(e);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:36,代码来源:SVG12BridgeEventSupport.java


示例17: addScriptingListenersOn

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Adds the scripting listeners to the given element.
 */
protected void addScriptingListenersOn(Element elt) {
    String eltNS = elt.getNamespaceURI();
    String eltLN = elt.getLocalName();
    if (SVGConstants.SVG_NAMESPACE_URI.equals(eltNS)
            && SVG12Constants.SVG_HANDLER_TAG.equals(eltLN)) {
        // For this 'handler' element, add a handler for the given
        // event type.
        AbstractElement tgt = (AbstractElement) elt.getParentNode();
        String eventType = elt.getAttributeNS
            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
             XMLConstants.XML_EVENTS_EVENT_ATTRIBUTE);
        String eventNamespaceURI = XMLConstants.XML_EVENTS_NAMESPACE_URI;
        if (eventType.indexOf(':') != -1) {
            String prefix = DOMUtilities.getPrefix(eventType);
            eventType = DOMUtilities.getLocalName(eventType);
            eventNamespaceURI
                = ((AbstractElement) elt).lookupNamespaceURI(prefix);
        }

        EventListener listener = new HandlerScriptingEventListener
            (eventNamespaceURI, eventType, (AbstractElement) elt);
        tgt.addEventListenerNS
            (eventNamespaceURI, eventType, listener, false, null);
        if (handlerScriptingListeners == null) {
            handlerScriptingListeners = new TriplyIndexedTable();
        }
        handlerScriptingListeners.put
            (eventNamespaceURI, eventType, elt, listener);
    }

    super.addScriptingListenersOn(elt);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:36,代码来源:SVG12ScriptingEnvironment.java


示例18: removeScriptingListenersOn

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Removes the scripting listeners from the given element.
 */
protected void removeScriptingListenersOn(Element elt) {
    String eltNS = elt.getNamespaceURI();
    String eltLN = elt.getLocalName();
    if (SVGConstants.SVG_NAMESPACE_URI.equals(eltNS)
            && SVG12Constants.SVG_HANDLER_TAG.equals(eltLN)) {
        // For this 'handler' element, remove the handler for the given
        // event type.
        AbstractElement tgt = (AbstractElement) elt.getParentNode();
        String eventType = elt.getAttributeNS
            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
             XMLConstants.XML_EVENTS_EVENT_ATTRIBUTE);
        String eventNamespaceURI = XMLConstants.XML_EVENTS_NAMESPACE_URI;
        if (eventType.indexOf(':') != -1) {
            String prefix = DOMUtilities.getPrefix(eventType);
            eventType = DOMUtilities.getLocalName(eventType);
            eventNamespaceURI
                = ((AbstractElement) elt).lookupNamespaceURI(prefix);
        }

        EventListener listener =
            (EventListener) handlerScriptingListeners.put
                (eventNamespaceURI, eventType, elt, null);
        tgt.removeEventListenerNS
            (eventNamespaceURI, eventType, listener, false);
    }

    super.removeScriptingListenersOn(elt);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:32,代码来源:SVG12ScriptingEnvironment.java


示例19: AbstractElement

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Creates a new AbstractElement object.
 * @param name  The element name for validation purposes.
 * @param owner The owner document.
 * @exception DOMException
 *   INVALID_CHARACTER_ERR: if name contains invalid characters,
 */
protected AbstractElement(String name, AbstractDocument owner) {
    ownerDocument = owner;
    if (owner.getStrictErrorChecking() && !DOMUtilities.isValidName(name)) {
        throw createDOMException(DOMException.INVALID_CHARACTER_ERR,
               "xml.name",
               new Object[] { name });
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:16,代码来源:AbstractElement.java


示例20: checkName

import org.apache.batik.dom.util.DOMUtilities; //导入依赖的package包/类
/**
 * Checks that the given string is a valid XML name.
 */
protected boolean checkName(String s) {
    if (xmlVersion.equals(XMLConstants.XML_VERSION_11)) {
        return DOMUtilities.isValidName11(s);
    }
    // assume XML 1.0
    return DOMUtilities.isValidName(s);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:11,代码来源:AbstractDocument.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HibernateTemplate类代码示例发布时间:2022-05-23
下一篇:
Java JsonUtils类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap