Search in sources :

Example 91 with Element

use of org.w3c.dom.Element in project atlas by alibaba.

the class Configuration method readDexPatternsFromXml.

private void readDexPatternsFromXml(Node node) throws IOException {
    NodeList childNodes = node.getChildNodes();
    if (childNodes.getLength() > 0) {
        for (int j = 0, n = childNodes.getLength(); j < n; j++) {
            Node child = childNodes.item(j);
            if (child.getNodeType() == Node.ELEMENT_NODE) {
                Element check = (Element) child;
                String tagName = check.getTagName();
                String value = check.getAttribute(ATTR_VALUE);
                if (tagName.equals(ATTR_DEX_MODE)) {
                    if (value.equals("raw")) {
                        mDexRaw = true;
                    }
                } else if (tagName.equals(ATTR_PATTERN)) {
                    addToPatterns(value, mDexFilePattern);
                } else if (tagName.equals(ATTR_LOADER)) {
                    mDexLoaderPattern.add(value);
                } else {
                    System.err.println("unknown dex tag " + tagName);
                }
            }
        }
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Example 92 with Element

use of org.w3c.dom.Element in project android_frameworks_base by ParanoidAndroid.

the class ColladaParser method getRenderable.

private void getRenderable(Element shape, Transform t) {
    String geoURL = shape.getAttribute("url").substring(1);
    String geoName = mMeshIdNameMap.get(geoURL);
    if (geoName != null) {
        geoURL = geoName;
    }
    //RenderableGroup group = new RenderableGroup();
    //group.setName(geoURL.substring(1));
    //mScene.appendRenderable(group);
    NodeList nl = shape.getElementsByTagName("instance_material");
    if (nl != null) {
        for (int i = 0; i < nl.getLength(); i++) {
            Element materialRef = (Element) nl.item(i);
            String meshIndexName = materialRef.getAttribute("symbol");
            String materialName = materialRef.getAttribute("target");
            Renderable d = new Renderable();
            d.setMesh(geoURL, meshIndexName);
            d.setMaterialName(materialName.substring(1));
            d.setName(geoURL);
            //Log.v(TAG, "Created drawable geo " + geoURL + " index " + meshIndexName + " material " + materialName);
            d.setTransform(t);
            //Log.v(TAG, "Set source param " + t.getName());
            // Now find all the parameters that exist on the material
            ArrayList<ShaderParam> materialParams;
            materialParams = mEffectsParams.get(materialName.substring(1));
            for (int pI = 0; pI < materialParams.size(); pI++) {
                d.appendSourceParams(materialParams.get(pI));
            //Log.v(TAG, "Set source param i: " + pI + " name " + materialParams.get(pI).getParamName());
            }
            mScene.appendRenderable(d);
        //group.appendChildren(d);
        }
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 93 with Element

use of org.w3c.dom.Element in project android_frameworks_base by ParanoidAndroid.

the class ColladaParser method getNode.

private void getNode(Element node, Transform parent, String indent) {
    String name = node.getAttribute("name");
    String id = node.getAttribute("id");
    CompoundTransform current = new CompoundTransform();
    current.setName(name);
    if (parent != null) {
        parent.appendChild(current);
    } else {
        mScene.appendTransform(current);
    }
    mScene.addToTransformMap(current);
    //Log.v(TAG, indent + "|");
    //Log.v(TAG, indent + "[" + name + "]");
    Node childNode = node.getFirstChild();
    while (childNode != null) {
        if (childNode.getNodeType() == Node.ELEMENT_NODE) {
            Element field = (Element) childNode;
            String fieldName = field.getTagName();
            String description = field.getAttribute("sid");
            if (fieldName.equals("translate")) {
                Float3 value = getFloat3(field);
                current.addTranslate(description, value);
            //Log.v(TAG, indent + " translate " + description + toString(value));
            } else if (fieldName.equals("rotate")) {
                Float4 value = getFloat4(field);
                //Log.v(TAG, indent + " rotate " + description + toString(value));
                Float3 axis = new Float3(value.x, value.y, value.z);
                current.addRotate(description, axis, value.w);
            } else if (fieldName.equals("scale")) {
                Float3 value = getFloat3(field);
                //Log.v(TAG, indent + " scale " + description + toString(value));
                current.addScale(description, value);
            } else if (fieldName.equals("instance_geometry")) {
                getRenderable(field, current);
            } else if (fieldName.equals("instance_light")) {
                updateLight(field, current);
            } else if (fieldName.equals("instance_camera")) {
                updateCamera(field, current);
            } else if (fieldName.equals("node")) {
                getNode(field, current, indent + "   ");
            }
        }
        childNode = childNode.getNextSibling();
    }
}
Also used : Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Example 94 with Element

use of org.w3c.dom.Element in project android_frameworks_base by ParanoidAndroid.

the class ColladaParser method convertMaterials.

private void convertMaterials(Element mat) {
    String id = mat.getAttribute("id");
    NodeList nl = mat.getElementsByTagName("instance_effect");
    if (nl != null && nl.getLength() == 1) {
        Element ref = (Element) nl.item(0);
        String url = ref.getAttribute("url");
        ArrayList<ShaderParam> params = mEffectsParams.get(url.substring(1));
        mEffectsParams.put(id, params);
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 95 with Element

use of org.w3c.dom.Element in project android_frameworks_base by ParanoidAndroid.

the class ColladaParser method convertEffects.

private void convertEffects(Element fx) {
    String id = fx.getAttribute("id");
    ArrayList<ShaderParam> params = new ArrayList<ShaderParam>();
    NodeList nl = fx.getElementsByTagName("newparam");
    if (nl != null) {
        for (int i = 0; i < nl.getLength(); i++) {
            Element field = (Element) nl.item(i);
            field.setIdAttribute("sid", true);
        }
    }
    nl = fx.getElementsByTagName("blinn");
    if (nl != null) {
        for (int i = 0; i < nl.getLength(); i++) {
            Element field = (Element) nl.item(i);
            //Log.v(TAG, "blinn");
            extractParams(field, params);
        }
    }
    nl = fx.getElementsByTagName("lambert");
    if (nl != null) {
        for (int i = 0; i < nl.getLength(); i++) {
            Element field = (Element) nl.item(i);
            //Log.v(TAG, "lambert");
            extractParams(field, params);
        }
    }
    nl = fx.getElementsByTagName("phong");
    if (nl != null) {
        for (int i = 0; i < nl.getLength(); i++) {
            Element field = (Element) nl.item(i);
            //Log.v(TAG, "phong");
            extractParams(field, params);
        }
    }
    mEffectsParams.put(id, params);
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Aggregations

Element (org.w3c.dom.Element)9072 Document (org.w3c.dom.Document)2651 NodeList (org.w3c.dom.NodeList)2103 Node (org.w3c.dom.Node)1855 ArrayList (java.util.ArrayList)957 DocumentBuilder (javax.xml.parsers.DocumentBuilder)793 IOException (java.io.IOException)732 Test (org.junit.Test)693 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)591 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)489 HashMap (java.util.HashMap)434 SAXException (org.xml.sax.SAXException)406 File (java.io.File)358 Attr (org.w3c.dom.Attr)333 InputStream (java.io.InputStream)309 QName (javax.xml.namespace.QName)292 Map (java.util.Map)285 JAXBElement (javax.xml.bind.JAXBElement)285 NamedNodeMap (org.w3c.dom.NamedNodeMap)266 List (java.util.List)264