Author: ruschein
Date: 2010-10-01 15:43:33 -0700 (Fri, 01 Oct 2010)
New Revision: 22128

Removed:
   core3/work-api/trunk/src/main/java/org/cytoscape/work/SuperTask.java
   core3/work-api/trunk/src/test/java/org/cytoscape/work/SuperTaskTest.java
Log:
Obsolete.

Deleted: core3/work-api/trunk/src/main/java/org/cytoscape/work/SuperTask.java
===================================================================
--- core3/work-api/trunk/src/main/java/org/cytoscape/work/SuperTask.java        
2010-10-01 22:10:24 UTC (rev 22127)
+++ core3/work-api/trunk/src/main/java/org/cytoscape/work/SuperTask.java        
2010-10-01 22:43:33 UTC (rev 22128)
@@ -1,191 +0,0 @@
-package org.cytoscape.work;
-
-
-/**
- * Provides a means for nested subtasks to be
- * grouped together under one <code>SuperTask</code>.
- *
- * <p><code>SuperTask</code> behaves as follows:</p>
- * <ul>
- *
- * <li><b>Threads </b><code>SuperTask</code> executes all of its subtasks
- * in the same thread provided by <code>TaskManager</code>.</li>
- *
- * <li><b>Execution Order </b><code>SuperTask</code> executes all of its 
subtasks
- * in the same order as given in its constructor.</li>
- *
- * <li><b>Cancelling </b>If <code>SuperTask</code> is canceled, it will call 
the
- * currently executing <code>Task</code>'s <code>cancel</code> method.
- * It will not execute any following <code>Task</code>s waiting to be 
executed.</li>
- *
- * <li><b>Title </b><code>SuperTask</code>'s title is what is given in the
- * constructor.</li>
- *
- * <li><b>Status Message </b>If the currently executing subtask sets a title 
that is not null and is
- * not an empty string, <code>SuperTask</code> will set its status message to
- * "<i>subtask title</i><code>:</code><i>subtask status message</i>".
- * However, if the subtask's title is not set, is null, or is an empty string,
- * <code>SuperTask</code> will set its status message to the subtask's status
- * message.</li>
- *
- * <li><b>Progress </b><code>SuperTask</code> divides its progress equally 
between
- * each of its subtasks unless weights are specified. For example, if there 
are four subtasks: when
- * the first subtask is executing, it will set its progress to 0%; when
- * the second subtask is executing, it will set its progress to 25%;
- * and so on. This behavior can be modified by specifying weights.</li>
-
- * <li><b>Exceptions </b>If a subtask throws an exception, subtasks that 
follow will not be
- * executed.</li>
- * </ul>
- *
- * @author Pasteur
- */
-public class SuperTask implements Task {
-       private final Task[] subtasks;
-       private final double[] weights;
-       private double weightSum = 0.0;
-
-       private boolean cancelled = false;
-       private int currentTaskIndex = -1;
-       private double partialSum = 0.0;
-
-       /**
-        * Constructs a <code>SuperTask</code> with a given list of
-        * subtasks and a title.
-        *
-        * <p>The constructor can take an array of <code>Task</code>s:</p>
-        * <p><pre><code>
-        * Task[] tasks = {
-        *  new MyTask1(),
-        *  new MyTask2(),
-        *  new MyTask3()
-        * };
-        * SuperTask superTask = new SuperTask("Example", tasks);
-        * </code></pre></p>
-        *
-        * <p>This constructor is also a convenience that employs Java's 
variable
-        * arguments syntactic sugar:</p>
-        *
-        * <p><code>new SuperTask("Example", new MyTask1(), new MyTask2(),
-        * new MyTask3());</code></p>
-        *
-        * @param subtasks The subtasks to be grouped together by
-        * <code>SuperTask</code>. The order of <code>subtasks</code> is the
-        * order of execution. Each subtask has an equal amount of the progress 
bar.
-        */
-       public SuperTask(final Task ... subtasks) {
-               this.subtasks = subtasks;
-               this.weights = new double[subtasks.length];
-               for (int i = 0; i < weights.length; i++) {
-                       weights[i] = 1.0;
-                       weightSum += weights[i];
-               }
-       }
-
-       /**
-        * Constructs a <code>SuperTask</code> with a given list of
-        * subtasks, a title, and weights for each subtask.
-        *
-        * This constructor allows one to specify the weights of each
-        * subtask. Weights specify how much of the progress bar
-        * is given to each subtask. A weight can be any positive number,
-        * as the proportion of the progress bar is measured against
-        * the weight's ratio to the total sum of all weights.
-        * To allocate 25% of the progress bar to the first task, 50% to the 
second,
-        * and 25% to the third, one may do the following:
-        *
-        * <p><pre><code>
-        * Task[] tasks = {
-        *  new MyTask1(),
-        *  new MyTask2(),
-        *  new MyTask3()
-        * };
-        *
-        * double[] weights = {
-        *  2.0,
-        *  4.0,
-        *  2.0
-        * };
-        *
-        * SuperTask superTask = new SuperTask("Example", tasks, weights);
-        * </code></pre></p>
-        *
-        * @param subtasks The subtasks to be grouped together by
-        * <code>SuperTask</code>. The order of <code>subtasks</code> is the
-        * order of execution.
-        * @param weights The weights allotted to each subtask. All weights
-        * must be a positive number.
-        * @throws IllegalArgumentException if the length of 
<code>weights</code>
-        * and <code>subtasks</code> are not equal or if any of the weights are 
less than 0.0.
-        */
-       public SuperTask(final Task[] subtasks, final double[] weights) {
-               this.subtasks = subtasks;
-               this.weights = weights;
-
-               if (weights.length != subtasks.length)
-                       throw new IllegalArgumentException("weights and 
subtasks must have the same length");
-               for (int i = 0; i < weights.length; i++) {
-                       if (weights[i] < 0.0)
-                               throw new 
IllegalArgumentException(String.format("weight[%d] cannot be less than 0.0", 
i));
-                       weightSum += weights[i];
-               }
-       }
-
-       public void run(TaskMonitor superTaskMonitor) throws Exception {
-               superTaskMonitor.setProgress(0.0);
-               final TaskMonitor subTaskMonitor = new 
SubTaskMonitor(superTaskMonitor);
-               for (currentTaskIndex = 0; (currentTaskIndex < subtasks.length) 
&& (!cancelled); currentTaskIndex++) {
-                       subtasks[currentTaskIndex].run(subTaskMonitor);
-                       partialSum += weights[currentTaskIndex];
-               }
-
-               cancelled = false;
-               currentTaskIndex = -1;
-               partialSum = 0.0;
-       }
-
-       public synchronized void cancel() {
-               if (cancelled)
-                       return;
-
-               // currentTaskIndex is copied into another variable
-               // in order to prevent the situation where currentTaskIndex is
-               // being incremented while another thread is executing cancel().
-               final int index = currentTaskIndex;
-               cancelled = true;
-               if (index >= 0 && index < subtasks.length)
-                       subtasks[index].cancel();
-       }
-
-       public synchronized boolean cancelled() {
-               return this.cancelled;
-       }
-
-       class SubTaskMonitor implements TaskMonitor {
-               final TaskMonitor superTaskMonitor;
-               String subtitle = null;
-
-               public SubTaskMonitor(TaskMonitor superTaskMonitor)
-               {
-                       this.superTaskMonitor = superTaskMonitor;
-               }
-
-               public void setTitle(String subtitle)
-               {
-                       this.subtitle = subtitle;
-               }
-
-               public void setProgress(double subprogress)
-               {
-                       superTaskMonitor.setProgress((partialSum + 
weights[currentTaskIndex] * subprogress) / weightSum);
-               }
-
-               public void setStatusMessage(String subStatusMessage)
-               {
-                       if (subtitle == null || subtitle.length() == 0)
-                               
superTaskMonitor.setStatusMessage(subStatusMessage);
-                       else
-                               
superTaskMonitor.setStatusMessage(String.format("%s: %s", subtitle, 
subStatusMessage));
-               }
-       }
-}

Deleted: 
core3/work-api/trunk/src/test/java/org/cytoscape/work/SuperTaskTest.java
===================================================================
--- core3/work-api/trunk/src/test/java/org/cytoscape/work/SuperTaskTest.java    
2010-10-01 22:10:24 UTC (rev 22127)
+++ core3/work-api/trunk/src/test/java/org/cytoscape/work/SuperTaskTest.java    
2010-10-01 22:43:33 UTC (rev 22128)
@@ -1,85 +0,0 @@
-/*
- Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-package org.cytoscape.work;
-
-
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.*;
-
-
-public class SuperTaskTest {
-       @Test
-       public final void testConstructor1() {
-               final Task t1 = mock(Task.class);
-               final Task t2 = mock(Task.class);
-               final Task t3 = mock(Task.class);
-               new SuperTask(t1, t2, t3);
-       }
-
-       @Test
-       public final void testConstructor2() {
-               final Task[] tasks = new Task[] { mock(Task.class), 
mock(Task.class), mock(Task.class) };
-               final double[] weights = new double[] { 1.0, 2.0, 3.0 };
-               new SuperTask(tasks, weights);
-       }
-
-       @Test(expected=IllegalArgumentException.class)
-       public final void testWrongNumberOfWeights() {
-               final Task[] tasks = new Task[] { mock(Task.class), 
mock(Task.class), mock(Task.class) };
-               final double[] weights = new double[] { 1.0, 2.0 };
-               new SuperTask(tasks, weights);
-       }
-
-       @Test(expected=IllegalArgumentException.class)
-       public final void testInvalidNegativeWeight() {
-               final Task[] tasks = new Task[] { mock(Task.class), 
mock(Task.class), mock(Task.class) };
-               final double[] weights = new double[] { 1.0, 2.0, -3.0 };
-               new SuperTask(tasks, weights);
-       }
-
-       @Test
-       public final void testCancel() {
-               final Task[] tasks = new Task[] { mock(Task.class), 
mock(Task.class), mock(Task.class) };
-               final double[] weights = new double[] { 1.0, 2.0, 3.0 };
-               final SuperTask superTask = new SuperTask(tasks, weights);
-               superTask.cancel();
-               assertTrue("Invalid cancellation state!", 
superTask.cancelled());
-       }
-
-       @Test
-       public final void testRunAndSubTaskMonitor() throws Exception {
-               final Task[] tasks = new Task[] { mock(Task.class), 
mock(Task.class), mock(Task.class) };
-               final double[] weights = new double[] { 1.0, 2.0, 3.0 };
-               final SuperTask superTask = new SuperTask(tasks, weights);
-               final TaskMonitor taskMonitor = mock(TaskMonitor.class);
-               superTask.run(taskMonitor);
-       }
-}

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to