+ * Since 2.2, it is possible to listener on important events of the animator using
This package contains AnimatorListener
interface.
*
* @author David Kaspar
*/
public abstract class Animator {
+ private CopyOnWriteArrayListAnimatorListener
.
+ * It contains a reference to the animator and animation progress value which is can be used only in case of
+ * AnimatorListener.animatorPreTick
and AnimatorListener.animatorPostTick
methods.
+ *
+ * @author David Kaspar
+ */
+public final class AnimatorEvent {
+
+ private Animator animator;
+ private double progress;
+
+ AnimatorEvent (Animator animator) {
+ this (animator, Double.NaN);
+ }
+
+ AnimatorEvent (Animator animator, double progress) {
+ this.animator = animator;
+ this.progress = progress;
+ }
+
+ /**
+ * Returns the related animator instance.
+ * @return the animator
+ */
+ public Animator getAnimator () {
+ return animator;
+ }
+
+ /**
+ * The animation progress value. Contains valid value only when the event is received as an argument of
+ * AnimatorListener.animatorPreTick
and AnimatorListener.animatorPostTick
methods.
+ * @return the progress value; valid range is from 0.0 to 1.0 where 0.0 represents animator-start and 1.0 represents animator-end;
+ * Double.NaN if the progress value is not available
+ */
+ public double getProgress () {
+ return progress;
+ }
+
+}
Index: graph/lib/src/org/netbeans/api/visual/animator/AnimatorListener.java
===================================================================
RCS file: graph/lib/src/org/netbeans/api/visual/animator/AnimatorListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ graph/lib/src/org/netbeans/api/visual/animator/AnimatorListener.java 17 Apr 2007 10:00:22 -0000
@@ -0,0 +1,64 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+package org.netbeans.api.visual.animator;
+
+/**
+ * This interface is used for notifying about important events on Animator
.
+ *
+ * @author David Kaspar
+ * @since 2.2
+ */
+public interface AnimatorListener {
+
+ /**
+ * Called when an animator is invoked to be started.
+ * @param event the animator event
+ * @since 2.2
+ */
+ void animatorStarted (AnimatorEvent event);
+
+ /**
+ * Called when an animator is changed, so the animation has to be restarted.
+ * @param event the animator event
+ * @since 2.2
+ */
+ void animatorReset (AnimatorEvent event);
+
+ /**
+ * Called when an animator is finished - means it was running for 500+ms.
+ * @param event the animator event
+ * @since 2.2
+ */
+ void animatorFinished (AnimatorEvent event);
+
+ /**
+ * Called immediately before the animator performs a tick of an animation.
+ * @param event the animator event
+ * @since 2.2
+ */
+ void animatorPreTick (AnimatorEvent event);
+
+ /**
+ * Called immediately after the animator performs a tick of an animation.
+ * @param event the animator event
+ * @since 2.2
+ */
+ void animatorPostTick (AnimatorEvent event);
+
+}
Index: graph/lib/src/org/netbeans/api/visual/animator/SceneAnimator.java
===================================================================
RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/animator/SceneAnimator.java,v
--- graph/lib/src/org/netbeans/api/visual/animator/SceneAnimator.java 14 Nov 2006 10:04:15 -0000 1.13
+++ graph/lib/src/org/netbeans/api/visual/animator/SceneAnimator.java 17 Apr 2007 10:00:22 -0000
@@ -188,6 +188,42 @@
colorAnimator.setForegroundColor (widget, targetForegroundColor);
}
+ /**
+ * Returns the preferred location animator which animates preferred location of all widgets in the scene.
+ * @return the preferred location animator
+ * @since 2.2
+ */
+ public Animator getPreferredLocationAnimator () {
+ return preferredLocationAnimator;
+ }
+
+ /**
+ * Returns the preferred bounds animator which animates preferred bounds of all widgets in the scene.
+ * @return the preferred bounds animator
+ * @since 2.2
+ */
+ public Animator getPreferredBoundsAnimator () {
+ return preferredBoundsAnimator;
+ }
+
+ /**
+ * Returns the zoom animator.
+ * @return the zoom animator
+ * @since 2.2
+ */
+ public Animator getZoomAnimator () {
+ return zoomAnimator;
+ }
+
+ /**
+ * Returns the color animator which animates background and foreground colors of all widgets in the scene.
+ * @return the preferred location animator
+ * @since 2.2
+ */
+ public Animator getColorAnimator () {
+ return colorAnimator;
+ }
+
private class UpdateTask implements Runnable {
public void run () {
Index: graph/lib/src/org/netbeans/api/visual/animator/package.html
===================================================================
RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/animator/package.html,v
--- graph/lib/src/org/netbeans/api/visual/animator/package.html 13 Mar 2007 10:46:27 -0000 1.3
+++ graph/lib/src/org/netbeans/api/visual/animator/package.html 17 Apr 2007 10:00:22 -0000
@@ -21,5 +21,6 @@
SceneAnimator
classes which is used for controlling animations on a scene.
Also you can supply your own animator by implementing Animator
class.
+Also you can listen on each animator using AnimatorListener
interface.