diff --git a/core/src/build/conf/checkstyle.xml b/core/src/build/conf/checkstyle.xml index a08dbad..d23ff3c 100644 --- a/core/src/build/conf/checkstyle.xml +++ b/core/src/build/conf/checkstyle.xml @@ -161,7 +161,7 @@ - + diff --git a/core/src/main/java/edu/umd/cs/piccolo/activities/PActivityScheduler.java b/core/src/main/java/edu/umd/cs/piccolo/activities/PActivityScheduler.java index 13a01ab..50d6f63 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/activities/PActivityScheduler.java +++ b/core/src/main/java/edu/umd/cs/piccolo/activities/PActivityScheduler.java @@ -61,16 +61,32 @@ private boolean animating; private final ArrayList processingActivities; + /** + * Constructs an instance of PActivityScheduler. All activities it will schedule will + * take place on children of the rootNode provided. + * + * @param rootNode + */ public PActivityScheduler(final PRoot rootNode) { root = rootNode; activities = new ArrayList(); processingActivities = new ArrayList(); } + /** + * Returns the node from which all activities will be attached. + * + * @return this scheduler's associated root node + */ public PRoot getRoot() { return root; } + /** + * Adds the given activity to the scheduler if not already found. + * + * @param activity activity to be scheduled + */ public void addActivity(final PActivity activity) { addActivity(activity, false); } @@ -79,6 +95,9 @@ * Add this activity to the scheduler. Sometimes it's useful to make sure * that an activity is run after all other activities have been run. To do * this set processLast to true when adding the activity. + * + * @param activity activity to be scheduled + * @param processLast whether or not this activity should be performed after all other scheduled activities */ public void addActivity(final PActivity activity, final boolean processLast) { if (activities.contains(activity)) { @@ -101,6 +120,11 @@ } } + /** + * Removes the given activity from the scheduled activities. Does nothing if it's not found. + * + * @param activity the activity to be removed + */ public void removeActivity(final PActivity activity) { if (!activities.contains(activity)) { return; @@ -114,12 +138,19 @@ } } + /** + * Removes all activities from the list of scheduled activities. + */ public void removeAllActivities() { activitiesChanged = true; activities.clear(); stopActivityTimer(); } + /** + * Returns a reference to the current activities list. Handle with care. + * @return reference to the current activities list. + */ public List getActivitiesReference() { return activities; } @@ -127,6 +158,8 @@ /** * Process all scheduled activities for the given time. Each activity is * given one "step", equivalent to one frame of animation. + * + * @param currentTime the current unix time in milliseconds. */ public void processActivities(final long currentTime) { final int size = activities.size(); @@ -156,14 +189,25 @@ return animating; } + /** + * Starts the current activity timer. Multiple calls to this method are ignored. + */ protected void startActivityTimer() { getActivityTimer().start(); } + /** + * Stops the current activity timer. + */ protected void stopActivityTimer() { getActivityTimer().stop(); } + /** + * Returns the activity timer. Creating it if necessary. + * + * @return a Timer instance. + */ protected Timer getActivityTimer() { if (activityTimer == null) { activityTimer = root.createTimer(PUtil.ACTIVITY_SCHEDULER_FRAME_DELAY, new ActionListener() { diff --git a/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java b/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java index d6ac953..ab30908 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java +++ b/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java @@ -74,8 +74,7 @@ } /** - * Create a new PColorActivity. - *

+ * Create a new PColorActivity. * * @param duration the length of one loop of the activity * @param stepRate the amount of time between steps of the activity @@ -112,6 +111,10 @@ destination = newDestination; } + /** + * Overrides it's parent to ensure that the source color is the color of the + * node being animated. + */ protected void activityStarted() { if (getFirstLoop()) { source = target.getColor(); @@ -119,6 +122,11 @@ super.activityStarted(); } + /** + * Interpolates the target node's color by mixing the source color and the destination color. + * + * @param zeroToOne 0 = all source color, 1 = all destination color + */ public void setRelativeTargetValue(final float zeroToOne) { super.setRelativeTargetValue(zeroToOne); final float red = source.getRed() + zeroToOne * (destination.getRed() - source.getRed()); diff --git a/core/src/main/java/edu/umd/cs/piccolo/activities/PInterpolatingActivity.java b/core/src/main/java/edu/umd/cs/piccolo/activities/PInterpolatingActivity.java index 364d76f..0c78074 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/activities/PInterpolatingActivity.java +++ b/core/src/main/java/edu/umd/cs/piccolo/activities/PInterpolatingActivity.java @@ -46,8 +46,22 @@ */ public class PInterpolatingActivity extends PActivity { + /** + * Specifies that interpolation will be from the source value to the + * destination value. + */ public static final int SOURCE_TO_DESTINATION = 1; + + /** + * Specifies that interpolation will be from the destination value to the + * source value. + */ public static final int DESTINATION_TO_SOURCE = 2; + + /** + * Specifies that interpolation proceed from the source to the destination + * then back to the source. Can be used to perform flashes. source value. + */ public static final int SOURCE_TO_DESTINATION_TO_SOURCE = 3; private int mode; @@ -118,6 +132,8 @@ /** * Return the number of times the activity should automatically reschedule * itself after it has finished. + * + * @return number of times to repeat this activity */ public int getLoopCount() { return loopCount; @@ -126,6 +142,8 @@ /** * Set the number of times the activity should automatically reschedule * itself after it has finished. + * + * @param loopCount number of times to repeat this activity */ public void setLoopCount(final int loopCount) { this.loopCount = loopCount; @@ -134,6 +152,8 @@ /** * Return true if the activity is executing its first loop. Subclasses * normally initialize their source state on the first loop. + * + * @return true if executing first loop */ public boolean getFirstLoop() { return firstLoop; @@ -143,15 +163,30 @@ * Set if the activity is executing its first loop. Subclasses normally * initialize their source state on the first loop. This method will rarely * need to be called, unless your are reusing activities. + * + * @param firstLoop true if executing first loop */ public void setFirstLoop(final boolean firstLoop) { this.firstLoop = firstLoop; } + /** + * Returns whether this interpolation accelerates and then decelerates as it + * interpolates. + * + * @return true if accelerations are being applied apply + */ public boolean getSlowInSlowOut() { return slowInSlowOut; } + /** + * Sets whether this interpolation accelerates and then decelerates as it + * interpolates. + * + * @param isSlowInSlowOut true if this interpolation inovolves some + * accelerations + */ public void setSlowInSlowOut(final boolean isSlowInSlowOut) { slowInSlowOut = isSlowInSlowOut; } @@ -226,6 +261,11 @@ } } + /** + * Computes relative target value taking the mode into account. + * + * @param zeroToOne Percentage of activity completed + */ protected void setRelativeTargetValueAdjustingForMode(float zeroToOne) { switch (mode) { case SOURCE_TO_DESTINATION: