javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GSVGLocatableElement.java
changeset 80 d6dafc5d983f
parent 56 abc41079b313
child 87 1627c337e51e
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.microedition.m2g;
       
    19 
       
    20 import org.w3c.dom.svg.*;
       
    21 
       
    22 public class M2GSVGLocatableElement
       
    23         extends M2GSVGElement
       
    24         implements SVGLocatableElement
       
    25 {
       
    26     //------------------------------------------------------------------
       
    27     // METHODS
       
    28     //------------------------------------------------------------------
       
    29 
       
    30     /**
       
    31      * Constructor
       
    32      * @param aHandle -
       
    33      * @param aDocument -
       
    34      */
       
    35     public M2GSVGLocatableElement(int aHandle, M2GDocument aDocument)
       
    36     {
       
    37         super(aHandle, aDocument);
       
    38     }
       
    39 
       
    40     /**
       
    41      * @see org.w3c.dom.svg.SVGLocatableElement#getBBox()
       
    42      */
       
    43     public SVGRect getBBox()
       
    44     {
       
    45         M2GSVGRect bbox = new M2GSVGRect();
       
    46         M2GSVGElement._getBBox(getNativeSVGProxyHandle(), getHandle(),
       
    47             M2GSVGConstants.AT_BBOX, bbox.getComponents());
       
    48         // Checks element's type
       
    49         if ((iElementTypeId == M2GSVGConstants.EL_G) ||
       
    50                 (iElementTypeId == M2GSVGConstants.EL_PATH) ||
       
    51                 (iElementTypeId == M2GSVGConstants.EL_SVG))
       
    52         {
       
    53             if (bbox.isZero())
       
    54             {
       
    55                 bbox = null;
       
    56             }
       
    57         }
       
    58         else if (iElementTypeId == M2GSVGConstants.EL_TEXT)
       
    59         {
       
    60             if ((bbox.getHeight()) == 0 && (bbox.getWidth() == 0))
       
    61             {
       
    62                 bbox = null;
       
    63             }
       
    64         }
       
    65         return bbox;
       
    66     }
       
    67 
       
    68     /**
       
    69      * @see org.w3c.dom.svg.SVGLocatableElement#getScreenBBox()
       
    70      */
       
    71     public SVGRect getScreenBBox()
       
    72     {
       
    73         // Checks if this element is in DOM
       
    74         if (getDocument().isElementInDOM(getHandle()))
       
    75         {
       
    76             M2GSVGRect bbox = new M2GSVGRect();
       
    77             // Initializes M2GSVGRect components
       
    78             M2GSVGElement._getScreenBBox(
       
    79                 getNativeSVGProxyHandle(),
       
    80                 getHandle(),
       
    81                 bbox.getComponents());
       
    82             return bbox;
       
    83         }
       
    84         return null;
       
    85     }
       
    86 
       
    87     /**
       
    88      * @see org.w3c.dom.svg.SVGLocatableElement#getScreenCTM()
       
    89      */
       
    90     public SVGMatrix getScreenCTM()
       
    91     {
       
    92         if (getDocument().isElementInDOM(getHandle()))
       
    93         {
       
    94             M2GSVGMatrix matrix = new M2GSVGMatrix();
       
    95             _getMatrixTrait(getNativeSVGProxyHandle(),
       
    96                             getHandle(),
       
    97                             M2GSVGConstants.EL_SVG, matrix.getComponents());
       
    98             return matrix;
       
    99         }
       
   100         return null;
       
   101     }
       
   102 }