javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GDocument.java
changeset 87 1627c337e51e
parent 80 d6dafc5d983f
equal deleted inserted replaced
80:d6dafc5d983f 87:1627c337e51e
     1 /*
     1 /*
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    35 {
    35 {
    36     //--------------------------------------------------
    36     //--------------------------------------------------
    37     // STATIC CONSTANTS
    37     // STATIC CONSTANTS
    38     //--------------------------------------------------
    38     //--------------------------------------------------
    39     // Error constants
    39     // Error constants
    40     /* Optimization: static finals changed to local variables
    40 
    41     public static final String UNSUPORTED_ELEMENT_TYPE_ESTR =
       
    42       "The type of element is not supported by the implementation.";
       
    43     public static final String UNSUPORTED_NAMESPACE_ESTR =
       
    44       "The URI is not the SVG namespace URI.";
       
    45     public static final String ID_IS_NULL_ESTR =
       
    46       "The ID is null.";
       
    47     public static final String NAMESPACE_URI_IS_NULL_ESTR =
       
    48       "The namespace URI is null.";
       
    49     public static final String QUALIFIED_NAME_IS_NULL_ESTR =
       
    50       "The qualifiedName is null.";
       
    51     public static final String CANNOT_APPEND_CHILD_ESTR =
       
    52       "Cannot appendChild to a Document node.";
       
    53     public static final String CANNOT_INSERT_BEFORE_ESTR =
       
    54       "Cannot insertBefore a Document node.";
       
    55     public static final String CANNOT_REMOVE_CHILD_ESTR =
       
    56       "Cannot removeChild from a Document node.";
       
    57     public static final String DOCUMENT_IS_ILLEGAL_ESTR =
       
    58       "The SVG document does not conform to the XML 1.0 specification.";
       
    59     public static final String HEIGHT_IS_ILLEGAL_ESTR =
       
    60       "The height is negative.";
       
    61     public static final String WIDTH_IS_ILLEGAL_ESTR =
       
    62       "The width is negative.";
       
    63     */
       
    64 
    41 
    65     //--------------------------------------------------
    42     //--------------------------------------------------
    66     // VARIABLES
    43     // VARIABLES
    67     //--------------------------------------------------
    44     //--------------------------------------------------
    68     private M2GEventDispatcher iEventDispatcher = null;
    45     private M2GEventDispatcher iEventDispatcher = null;
    92     //--------------------------------------------------
    69     //--------------------------------------------------
    93     /**
    70     /**
    94      * Creates new document object. If aData is null or empty then
    71      * Creates new document object. If aData is null or empty then
    95      * an empty document is create.
    72      * an empty document is create.
    96      * @param aImage Svg image
    73      * @param aImage Svg image
    97     * @param aBaseUrl A base url from where a document is downloaded.
    74      * @param aBaseUrl A base url from where a document is downloaded.
    98      * @param aSuffixUrl A suffix url from where a document is downloaded
    75      * @param aSuffixUrl A suffix url from where a document is downloaded
    99      * @param aData Plain text svg data
    76      * @param aData Plain text svg data
   100      */
    77      */
   101     public M2GDocument(M2GSVGImage aImage, String aBaseUrl, String aSuffixUrl,
    78     public M2GDocument(M2GSVGImage aImage, String aBaseUrl, String aSuffixUrl,
   102                        String aData)
    79                        String aData)
   103     {
    80     {
   104         super();
    81         super();
   105         
    82 
   106      		
       
   107         iImage      = aImage;
    83         iImage      = aImage;
   108         iBaseUrl    = aBaseUrl;
    84         iBaseUrl    = aBaseUrl;
   109         iSuffixUrl  = aSuffixUrl;
    85         iSuffixUrl  = aSuffixUrl;
   110 
    86 
   111         setHandle(_createDocument(
    87         setHandle(_createDocument(
   355             throw new NullPointerException(/*SF*/"The ID is null."/*SF*/);
   331             throw new NullPointerException(/*SF*/"The ID is null."/*SF*/);
   356         }
   332         }
   357         int elementHandle = _getElementById(
   333         int elementHandle = _getElementById(
   358                                 getNativeSVGProxyHandle(),
   334                                 getNativeSVGProxyHandle(),
   359                                 getHandle(),
   335                                 getHandle(),
   360                                 id );
   336                                 id);
   361         return M2GSVGElement.buildElement(elementHandle, this);
   337         return M2GSVGElement.buildElement(elementHandle, this);
   362     }
   338     }
   363 
   339 
   364     /**
   340     /**
   365      * Returns the image
   341      * Returns the image
   440      */
   416      */
   441     public int getViewportWidth()
   417     public int getViewportWidth()
   442     {
   418     {
   443         return _getViewportWidth(
   419         return _getViewportWidth(
   444                    getNativeSVGProxyHandle(),
   420                    getNativeSVGProxyHandle(),
   445                    getHandle() );
   421                    getHandle());
   446     }
   422     }
   447 
   423 
   448 
   424 
   449     /**
   425     /**
   450      * Called by SVGImage upon creating an Event instance
   426      * Called by SVGImage upon creating an Event instance
   695             throw new IllegalArgumentException(/*SF*/"The width is negative."/*SF*/);
   671             throw new IllegalArgumentException(/*SF*/"The width is negative."/*SF*/);
   696         }
   672         }
   697         _setViewportWidth(
   673         _setViewportWidth(
   698             getNativeSVGProxyHandle(),
   674             getNativeSVGProxyHandle(),
   699             getHandle(),
   675             getHandle(),
   700             width );
   676             width);
   701         Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   677         Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   702                    "setViewportWidth:" + width + " - end");
   678                    "setViewportWidth:" + width + " - end");
   703     }
   679     }
   704 
   680 
   705     /**
   681     /**
  1242                                             String aSuffixUrl,
  1218                                             String aSuffixUrl,
  1243                                             String aData,
  1219                                             String aData,
  1244                                             ExternalResourceHandler aHandler)
  1220                                             ExternalResourceHandler aHandler)
  1245     throws IOException
  1221     throws IOException
  1246     {
  1222     {
  1247     		
  1223 
  1248         if ((aData == null) || (aData.equals("")))
  1224         if ((aData == null) || (aData.equals("")))
  1249         {
  1225         {
  1250         		
  1226 
  1251             throw new IOException(
  1227             throw new IOException(
  1252                 /*SF*/"The SVG document does not conform to the XML 1.0 specification."/*SF*/);
  1228                 /*SF*/"The SVG document does not conform to the XML 1.0 specification."/*SF*/);
  1253         }
  1229         }
  1254 
  1230 
  1255         M2GDocument document = new M2GDocument(aImage, aBaseUrl, aSuffixUrl, aData);
  1231         M2GDocument document = new M2GDocument(aImage, aBaseUrl, aSuffixUrl, aData);
  1315     private native static int _getElementById(
  1291     private native static int _getElementById(
  1316         int aSvgProxyHandle, int aDocumentHandle,
  1292         int aSvgProxyHandle, int aDocumentHandle,
  1317         String aId);
  1293         String aId);
  1318 
  1294 
  1319     private static native int _getViewportHeight(
  1295     private static native int _getViewportHeight(
  1320          int aSvgProxyHandle, int aDocumentHandle);
  1296         int aSvgProxyHandle, int aDocumentHandle);
  1321 
  1297 
  1322     private static native int _getViewportWidth(
  1298     private static native int _getViewportWidth(
  1323          int aSvgProxyHandle, int aDocumentHandle);
  1299         int aSvgProxyHandle, int aDocumentHandle);
  1324 
  1300 
  1325     private native static int _isElementInDOM(
  1301     private native static int _isElementInDOM(
  1326          int aSvgProxyHandle, int aDocumentHandle,
  1302         int aSvgProxyHandle, int aDocumentHandle,
  1327         int aElementHandle);
  1303         int aElementHandle);
  1328 
  1304 
  1329     private static native int _requestCompleted(
  1305     private static native int _requestCompleted(
  1330         int aSvgProxyHandle, int aDocumentHandle,
  1306         int aSvgProxyHandle, int aDocumentHandle,
  1331         String aUri, byte[] aResourceData);
  1307         String aUri, byte[] aResourceData);