javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GSVGAnimationElement.java
changeset 80 d6dafc5d983f
parent 56 abc41079b313
child 87 1627c337e51e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GSVGAnimationElement.java	Fri Oct 15 12:29:39 2010 +0300
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2005 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.*;
+import com.nokia.mj.impl.utils.Logger;
+
+
+/**
+ * This interface represents an Animation element,
+ * which contains methods to control the timing of
+ * animations.
+ */
+public class M2GSVGAnimationElement
+        extends M2GSVGElement
+        implements SVGAnimationElement
+{
+    //--------------------------------------------------
+    // METHODS
+    //--------------------------------------------------
+    /**
+     * Constructor
+     * @param aElemnetHandle -
+     * @param aDocument -
+     */
+    public M2GSVGAnimationElement(int aElementHandle, M2GDocument aDocument)
+    {
+        super(aElementHandle, aDocument);
+    }
+
+    /**
+     * @see org.w3c.dom.svg.SVGAnimationElement#beginElementAt()
+     */
+    public void beginElementAt(float offset)
+    {
+        _beginElementAt(
+            getNativeSVGProxyHandle(),
+            getDocument().getHandle(), getHandle(), offset,
+            getDocument().getRootElement().getCurrentTime() );
+    }
+
+    /**
+     * Same as the beginElementAt with offset 0.0f
+     * @see org.w3c.dom.svg.SVGAnimationElement#beginElementAt()
+     */
+    public void beginElement()
+    {
+        beginElementAt(0.0f);
+    }
+
+    /**
+     * @see org.w3c.dom.svg.SVGAnimationElement#endElementAt()
+     */
+    public void endElementAt(float offset)
+    {
+        short endAttribute = _getEnumTrait(
+                                 getNativeSVGProxyHandle(),
+                                 getHandle(), M2GSVGConstants.AT_END );
+        // NOTE Native SVG engine checks that element is active so
+        // java side doesn't have to do that
+        if (endAttribute == M2GSVGConstants.ANIM_INDEFINITE)
+        {
+            Logger.LOG(Logger.EJavaUI, Logger.EInfo,
+                       "endElementAt() - Cannot stop this animation, indefinite attribute");
+        }
+        else
+        {
+            _endElementAt(
+                getNativeSVGProxyHandle(),
+                getDocument().getHandle(), getHandle(),
+                (offset + getDocument().getRootElement().getCurrentTime())    );
+        }
+    }
+
+
+    //--------------------------------------------------
+    // NATIVE METHODS
+    //--------------------------------------------------
+    private native void _beginElementAt(
+        int aSvgProxyHandle, int aDocumentHandle,
+        int aElementHandle, float aOffset, float aCurrentTime);
+
+    private native void _endElementAt(
+        int aSvgProxyHandle, int aDocumentHandle,
+        int aElementHandle, float aOffset);
+
+    private native boolean _isActive(
+        int aSvgProxyHandle, int aElementHandle);
+}