javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GSVGLocatableElement.java
author hgs
Fri, 29 Oct 2010 11:49:32 +0300
changeset 87 1627c337e51e
parent 56 abc41079b313
permissions -rw-r--r--
v2.2.21_1

/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/

package com.nokia.microedition.m2g;

import org.w3c.dom.svg.*;

public class M2GSVGLocatableElement
        extends M2GSVGElement
        implements SVGLocatableElement
{
    //------------------------------------------------------------------
    // METHODS
    //------------------------------------------------------------------

    /**
     * Constructor
     * @param aHandle -
     * @param aDocument -
     */
    public M2GSVGLocatableElement(int aHandle, M2GDocument aDocument)
    {
        super(aHandle, aDocument);
    }

    /**
     * @see org.w3c.dom.svg.SVGLocatableElement#getBBox()
     */
    public SVGRect getBBox()
    {
        M2GSVGRect bbox = new M2GSVGRect();
        M2GSVGElement._getBBox(getNativeSVGProxyHandle(), getHandle(),
                               M2GSVGConstants.AT_BBOX, bbox.getComponents());
        // Checks element's type
        if ((iElementTypeId == M2GSVGConstants.EL_G) ||
                (iElementTypeId == M2GSVGConstants.EL_PATH) ||
                (iElementTypeId == M2GSVGConstants.EL_SVG))
        {
            if (bbox.isZero())
            {
                bbox = null;
            }
        }
        else if (iElementTypeId == M2GSVGConstants.EL_TEXT)
        {
            if ((bbox.getHeight()) == 0 && (bbox.getWidth() == 0))
            {
                bbox = null;
            }
        }
        return bbox;
    }

    /**
     * @see org.w3c.dom.svg.SVGLocatableElement#getScreenBBox()
     */
    public SVGRect getScreenBBox()
    {
        // Checks if this element is in DOM
        if (getDocument().isElementInDOM(getHandle()))
        {
            M2GSVGRect bbox = new M2GSVGRect();
            // Initializes M2GSVGRect components
            M2GSVGElement._getScreenBBox(
                getNativeSVGProxyHandle(),
                getHandle(),
                bbox.getComponents());
            return bbox;
        }
        return null;
    }

    /**
     * @see org.w3c.dom.svg.SVGLocatableElement#getScreenCTM()
     */
    public SVGMatrix getScreenCTM()
    {
        if (getDocument().isElementInDOM(getHandle()))
        {
            M2GSVGMatrix matrix = new M2GSVGMatrix();
            _getMatrixTrait(getNativeSVGProxyHandle(),
                            getHandle(),
                            M2GSVGConstants.EL_SVG, matrix.getComponents());
            return matrix;
        }
        return null;
    }
}