javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GSVGImage.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".
    37         extends SVGImage
    37         extends SVGImage
    38 {
    38 {
    39     //--------------------------------------------------
    39     //--------------------------------------------------
    40     // STATIC CONSTANTS
    40     // STATIC CONSTANTS
    41     //--------------------------------------------------
    41     //--------------------------------------------------
    42     /* Optimization: static finals changed to local variables
    42 
    43     private static final String NULL_TYPE_ESTR =
       
    44       "The type is null.";
       
    45     private static final String ILLEGAL_VALUS_ESTR =
       
    46       "The x or y values are negative.";
       
    47     private static final String EVENT_TYPE_NOT_SUPPORTED_ESTR =
       
    48       "The event type is not supported.";
       
    49     private static final String INVALID_ELEMENT_ESTR =
       
    50       "Invalid element.";
       
    51     public static final String URI_IS_NULL_ESTR =
       
    52       "The URI is null.";
       
    53     */
       
    54 
    43 
    55     //--------------------------------------------------
    44     //--------------------------------------------------
    56     //  VARIABLES
    45     //  VARIABLES
    57     //--------------------------------------------------
    46     //--------------------------------------------------
    58     M2GDocument iDocument = null;
    47     M2GDocument iDocument = null;
   196         if ((element != null) && (element instanceof M2GSVGElement))
   185         if ((element != null) && (element instanceof M2GSVGElement))
   197         {
   186         {
   198             _focusOn(
   187             _focusOn(
   199                 ((M2GSVGElement)element).getNativeSVGProxyHandle(),
   188                 ((M2GSVGElement)element).getNativeSVGProxyHandle(),
   200                 ((M2GSVGElement)element).getDocument().getHandle(),
   189                 ((M2GSVGElement)element).getDocument().getHandle(),
   201                 ((M2GSVGElement)element).getHandle() );
   190                 ((M2GSVGElement)element).getHandle());
   202         }
   191         }
   203         tempNode = element;
   192         tempNode = element;
   204         while (tempNode != null)
   193         while (tempNode != null)
   205         {
   194         {
   206             iDocument.handleEvent(new M2GEvent(
   195             iDocument.handleEvent(new M2GEvent(
   337     {
   326     {
   338         if (stream == null)
   327         if (stream == null)
   339         {
   328         {
   340             throw new NullPointerException();
   329             throw new NullPointerException();
   341         }
   330         }
   342 				
   331 
   343 
   332 
   344         String strData = new String(StreamUtils.readBytesFromStream(stream, -1));
   333         String strData = new String(StreamUtils.readBytesFromStream(stream, -1));
   345 
   334 
   346         // Default handler is used if the specified handler is null
   335         // Default handler is used if the specified handler is null
   347         if (handler == null)
   336         if (handler == null)
   349             handler = M2GConnectionFactory.getExternalResourceHandler(null);
   338             handler = M2GConnectionFactory.getExternalResourceHandler(null);
   350         }
   339         }
   351 
   340 
   352         // Creates and setups svg image
   341         // Creates and setups svg image
   353         M2GSVGImage image = new M2GSVGImage();
   342         M2GSVGImage image = new M2GSVGImage();
   354         
   343 
   355         M2GDocument document = M2GDocument.buildDocument(
   344         M2GDocument document = M2GDocument.buildDocument(
   356                                    image,
   345                                    image,
   357                                    baseUrl,
   346                                    baseUrl,
   358                                    suffixUrl,
   347                                    suffixUrl,
   359                                    strData,
   348                                    strData,
   360                                    handler);
   349                                    handler);
   361         // Checks document validity
   350         // Checks document validity
   362 				
   351 
   363         image.setDocument(document);
   352         image.setDocument(document);
   364         
   353 
   365         if (handler != null)
   354         if (handler != null)
   366         {
   355         {
   367             // Gets size of external resources
   356             // Gets size of external resources
   368             int itemCount = _getExternalListSize(
   357             int itemCount = _getExternalListSize(
   369                                 document.getNativeSVGProxyHandle(),
   358                                 document.getNativeSVGProxyHandle(),
   381                 {
   370                 {
   382                     document.invokeResourceHandler(url);
   371                     document.invokeResourceHandler(url);
   383                 }
   372                 }
   384             }
   373             }
   385         }
   374         }
   386         
   375 
   387         // initialise the viewport
   376         // initialise the viewport
   388         _initViewport(document.getNativeSVGProxyHandle(),
   377         _initViewport(document.getNativeSVGProxyHandle(),
   389                       document.getHandle());
   378                       document.getHandle());
   390         
   379 
   391 
   380 
   392         return image;
   381         return image;
   393     }
   382     }
   394 
   383 
   395     /**
   384     /**
   452 
   441 
   453     //--------------------------------------------------
   442     //--------------------------------------------------
   454     // NATIVE METHODS
   443     // NATIVE METHODS
   455     //--------------------------------------------------
   444     //--------------------------------------------------
   456     private native static int _dispatchMouseEvent(
   445     private native static int _dispatchMouseEvent(
   457         int aSvgProxyHandle,int aDocumentHandle, 
   446         int aSvgProxyHandle,int aDocumentHandle,
   458         int aX, int aY);
   447         int aX, int aY);
   459 
   448 
   460     private native static void _focusOn(
   449     private native static void _focusOn(
   461         int aSvgProxyHandle,int aDocumentHandle, 
   450         int aSvgProxyHandle,int aDocumentHandle,
   462         int aSvgElementHandle);
   451         int aSvgElementHandle);
   463 
   452 
   464     private native static void _focusOut(
   453     private native static void _focusOut(
   465         int aSvgProxyHandle,int aDocumentHandle, 
   454         int aSvgProxyHandle,int aDocumentHandle,
   466         int aSvgElementHandle);
   455         int aSvgElementHandle);
   467 
   456 
   468     native static int _getExternalListSize(
   457     native static int _getExternalListSize(
   469          int aSvgProxyHandle, int aDocumentHandle);
   458         int aSvgProxyHandle, int aDocumentHandle);
   470 
   459 
   471     native static String _getExternalListItem(
   460     native static String _getExternalListItem(
   472         int aSvgProxyHandle, int aDocumentHandle,
   461         int aSvgProxyHandle, int aDocumentHandle,
   473         int aIndex);
   462         int aIndex);
   474 
   463