Revision: 678
Author: allain.lalonde
Date: Thu Oct 8 13:24:19 2009
Log: Attacking some checkstyle complaints.
http://code.google.com/p/piccolo2d/source/detail?r=678
Modified:
/piccolo2d.java/trunk/core/src/build/conf/checkstyle.xml
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PActivityScheduler.java
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PInterpolatingActivity.java
=======================================
--- /piccolo2d.java/trunk/core/src/build/conf/checkstyle.xml Mon Aug 3
19:46:04 2009
+++ /piccolo2d.java/trunk/core/src/build/conf/checkstyle.xml Thu Oct 8
13:24:19 2009
@@ -161,7 +161,7 @@
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
- <module name="VisibilityModifier"/>
+ <!-- For P2d 2.0: <module name="VisibilityModifier"/> -->
<!-- Miscellaneous other checks. -->
=======================================
---
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PActivityScheduler.java
Tue Jul 28 12:46:54 2009
+++
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PActivityScheduler.java
Thu Oct 8 13:24:19 2009
@@ -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()
{
=======================================
---
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java
Tue Jul 28 13:58:25 2009
+++
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java
Thu Oct 8 13:24:19 2009
@@ -74,8 +74,7 @@
}
/**
- * Create a new PColorActivity.
- * <P>
+ * 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());
=======================================
---
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PInterpolatingActivity.java
Tue Jul 28 13:58:25 2009
+++
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PInterpolatingActivity.java
Thu Oct 8 13:24:19 2009
@@ -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:
--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---