Code example for Element

Methods: getAttributegetElementsByTagName

0
 
        //Log.v(TAG, "Light " + name + " color " + toString(color)); 
    } 
 
    private void convertCamera(Element camera) {
        String name = camera.getAttribute("name");
        String id = camera.getAttribute("id");
        float fov = 30.0f;
        if (getString(camera, "yfov") != null) {
            fov = getFloat(camera, "yfov");
        } else if(getString(camera, "xfov") != null) {
            float aspect = getFloat(camera, "aspect_ratio");
            fov = getFloat(camera, "xfov") / aspect;
        } 
 
        float near = getFloat(camera, "znear");
        float far = getFloat(camera, "zfar");
 
        Camera sceneCamera = new Camera(); 
        sceneCamera.setFOV(fov);
        sceneCamera.setNear(near);
        sceneCamera.setFar(far);
        sceneCamera.setName(name);
        mScene.appendCamera(sceneCamera);
        mCameras.put(id, sceneCamera);
    } 
 
    private void convertImage(Element img) {
        String name = img.getAttribute("name");
        String id = img.getAttribute("id");
        String file = getString(img, "init_from");
 
        Texture2D tex = new Texture2D();
        tex.setFileName(file);
        tex.setFileDir(mRootDir);
        mScene.appendTextures(tex);
        mImages.put(id, tex);
    } 
 
    private void getScene(Element scene) {
        String name = scene.getAttribute("name");
        String id = scene.getAttribute("id");
 
        Node childNode = scene.getFirstChild();
        while (childNode != null) {
            if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                String indent = "";
                getNode((Element)childNode, null, indent);
            } 
            childNode = childNode.getNextSibling();
        } 
    } 
 
    private String getString(Element elem, String name) {
        String text = null;
        NodeList nl = elem.getElementsByTagName(name);
        if (nl != null && nl.getLength() != 0) {
            text = ((Element)nl.item(0)).getFirstChild().getNodeValue();
        } 
        return text;
    } 
Experience pair programming with AI  Get Codota for Java