Author: kono
Date: 2009-03-09 15:05:27 -0700 (Mon, 09 Mar 2009)
New Revision: 16186
Modified:
core3/io-impl/trunk/pom.xml
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/util/ReadUtils.java
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/expression/ExpressionData.java
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/gml/GMLReader.java
core3/io-impl/trunk/src/main/java/org/cytoscape/io/write/internal/sif/InteractionWriter.java
Log:
Old task package had been removed.
Modified: core3/io-impl/trunk/pom.xml
===================================================================
--- core3/io-impl/trunk/pom.xml 2009-03-09 20:36:09 UTC (rev 16185)
+++ core3/io-impl/trunk/pom.xml 2009-03-09 22:05:27 UTC (rev 16186)
@@ -311,6 +311,11 @@
<artifactId>io-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>work-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.aspectj</groupId>
Modified:
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/util/ReadUtils.java
===================================================================
---
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/util/ReadUtils.java
2009-03-09 20:36:09 UTC (rev 16185)
+++
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/util/ReadUtils.java
2009-03-09 22:05:27 UTC (rev 16186)
@@ -33,10 +33,9 @@
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.io.internal.util;
-
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
@@ -45,22 +44,20 @@
import java.net.URL;
import org.cytoscape.io.util.StreamUtil;
+import org.cytoscape.work.TaskMonitor;
-import cytoscape.task.TaskMonitor;
-
-
/**
*/
public class ReadUtils {
-
+
private static final String LINE_SEP =
System.getProperty("line.separator");
-
+
private StreamUtil streamUtil;
public ReadUtils(StreamUtil streamUtil) {
this.streamUtil = streamUtil;
}
-
+
/**
* A string that defines a simplified java regular expression for a URL.
* This may need to be updated to be more precise.
@@ -68,23 +65,26 @@
public static final String urlPattern =
"^(jar\\:)?(\\w+\\:\\/+\\S+)(\\!\\/\\S*)?$";
/**
- * DOCUMENT ME!
- *
- * @param name DOCUMENT ME!
- *
- * @return DOCUMENT ME!
+ * DOCUMENT ME!
+ *
+ * @param name
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
*/
public InputStream getInputStream(String name) {
return getInputStream(name, null);
}
/**
- * DOCUMENT ME!
- *
- * @param name DOCUMENT ME!
- * @param monitor DOCUMENT ME!
- *
- * @return DOCUMENT ME!
+ * DOCUMENT ME!
+ *
+ * @param name
+ * DOCUMENT ME!
+ * @param monitor
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
*/
public InputStream getInputStream(String name, TaskMonitor monitor) {
InputStream in = null;
@@ -93,27 +93,25 @@
if (name.matches(urlPattern)) {
URL u = new URL(name);
// in = u.openStream();
- // Use URLUtil to get the InputStream since we might be using
a proxy server
+ // Use URLUtil to get the InputStream since we
might be using a
+ // proxy server
// and because pages may be cached:
in = streamUtil.getBasicInputStream(u);
} else
in = new FileInputStream(name);
} catch (IOException ioe) {
ioe.printStackTrace();
-
- if (monitor != null)
- monitor.setException(ioe, ioe.getMessage());
}
return in;
}
/**
- *
- * @param filename
- * File to read in
- *
- * @return The contents of the given file as a string.
+ *
+ * @param filename
+ * File to read in
+ *
+ * @return The contents of the given file as a string.
*/
public String getInputString(String filename) {
try {
@@ -129,23 +127,24 @@
}
/**
- *
- * @param inputStream
- * An InputStream
- *
- * @return The contents of the given file as a string.
+ *
+ * @param inputStream
+ * An InputStream
+ *
+ * @return The contents of the given file as a string.
*/
public String getInputString(InputStream inputStream) throws
IOException {
-
+
final StringBuilder sb = new StringBuilder();
String line;
- final BufferedReader br = new BufferedReader(new
InputStreamReader(inputStream));
+ final BufferedReader br = new BufferedReader(new
InputStreamReader(
+ inputStream));
while ((line = br.readLine()) != null)
sb.append(line + LINE_SEP);
br.close();
-
+
return sb.toString();
}
}
Modified:
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/expression/ExpressionData.java
===================================================================
---
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/expression/ExpressionData.java
2009-03-09 20:36:09 UTC (rev 16185)
+++
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/expression/ExpressionData.java
2009-03-09 22:05:27 UTC (rev 16186)
@@ -44,18 +44,23 @@
//--------------------------------------------------------------------
package org.cytoscape.io.read.internal.expression;
-import cytoscape.task.TaskMonitor;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyRow;
-import org.cytoscape.model.CyDataTable;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import org.cytoscape.model.CyDataTable;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyRow;
+import org.cytoscape.work.TaskMonitor;
+
//--------------------------------------------------------------------
/**
@@ -484,13 +489,13 @@
/* parse rest of file line by line */
if (taskMonitor != null) {
- taskMonitor.setStatus("Reading in Data...");
+ taskMonitor.setStatusMessage("Reading in Data...");
}
for (int ii = lineCount; ii < lines.length; ii++) {
if (taskMonitor != null) {
double percentComplete = ((double) ii /
lines.length) * 100.0;
- taskMonitor.setPercentCompleted((int)
percentComplete);
+ taskMonitor.setProgress(percentComplete);
}
parseOneLine(lines[ii], ii, expectPvals,
mappingByKeyAttribute, attributeToId, hasCOMMON);
@@ -1082,7 +1087,7 @@
int currentCoordinate = (condNum *
geneNames.size()) + i;
int matrixSize = condNames.length *
geneNames.size();
double percent = ((double)
currentCoordinate / matrixSize) * 100.0;
- taskMonitor.setPercentCompleted((int)
percent);
+ taskMonitor.setProgress(percent);
}
}
}
Modified:
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/gml/GMLReader.java
===================================================================
---
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/gml/GMLReader.java
2009-03-09 20:36:09 UTC (rev 16185)
+++
core3/io-impl/trunk/src/main/java/org/cytoscape/io/read/internal/gml/GMLReader.java
2009-03-09 22:05:27 UTC (rev 16186)
@@ -38,6 +38,7 @@
import java.awt.Color;
import java.awt.geom.Point2D;
+import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.ArrayList;
@@ -63,11 +64,9 @@
import org.cytoscape.vizmap.ArrowShape;
import org.cytoscape.vizmap.NodeShape;
import org.cytoscape.vizmap.VisualPropertyType;
+import org.cytoscape.work.TaskMonitor;
-import cytoscape.task.PercentUtil;
-import cytoscape.task.TaskMonitor;
-
/**
* This class is responsible for converting a gml object tree into cytoscape
* objects New features to the current version: 1. Small bug fixes. 2.
Translate
@@ -159,7 +158,6 @@
Vector<String> node_names;
private TaskMonitor taskMonitor;
- private PercentUtil percentUtil;
// Name for the new visual style
String styleName;
@@ -228,7 +226,6 @@
*/
public void setTaskMonitor(TaskMonitor monitor) {
this.taskMonitor = monitor;
- percentUtil = new PercentUtil(3);
}
public CyNetwork getReadNetwork() {
@@ -254,15 +251,11 @@
/**
* DOCUMENT ME!
*/
- public void read() {
+ public void read() throws IOException {
try {
keyVals = (new GMLParser(inputStream)).parseList();
} catch (Exception io) {
io.printStackTrace();
-
- if (taskMonitor != null)
- taskMonitor.setException(io, io.getMessage());
-
throw new RuntimeException(io.getMessage());
}
@@ -331,7 +324,8 @@
for (int idx = 0; idx < nodes.size(); idx++) {
// Report Status Value
if (taskMonitor != null) {
-
taskMonitor.setPercentCompleted(percentUtil.getGlobalPercent(2, idx,
nodes.size()));
+ // TODO: set proper number
+
//taskMonitor.setPercentCompleted(percentUtil.getGlobalPercent(2, idx,
nodes.size()));
}
String label = node_labels.get(idx);
@@ -356,7 +350,8 @@
for (int idx = 0; idx < sources.size(); idx++) {
// Report Status Value
if (taskMonitor != null) {
-
taskMonitor.setPercentCompleted(percentUtil.getGlobalPercent(3, idx,
sources.size()));
+ // TODO: set proper number
+
//taskMonitor.setPercentCompleted(percentUtil.getGlobalPercent(3, idx,
sources.size()));
}
if (gml_id2order.containsKey(sources.get(idx)) &&
gml_id2order.containsKey(targets.get(idx))) {
@@ -401,7 +396,8 @@
for (Iterator it = list.iterator(); it.hasNext();) {
// Report Progress Value
if (taskMonitor != null) {
-
taskMonitor.setPercentCompleted(percentUtil.getGlobalPercent(1, counter,
list.size()));
+ //TODO: set proper number
+
//taskMonitor.setPercentCompleted(percentUtil.getGlobalPercent(1, counter,
list.size()));
counter++;
}
Modified:
core3/io-impl/trunk/src/main/java/org/cytoscape/io/write/internal/sif/InteractionWriter.java
===================================================================
---
core3/io-impl/trunk/src/main/java/org/cytoscape/io/write/internal/sif/InteractionWriter.java
2009-03-09 20:36:09 UTC (rev 16185)
+++
core3/io-impl/trunk/src/main/java/org/cytoscape/io/write/internal/sif/InteractionWriter.java
2009-03-09 22:05:27 UTC (rev 16186)
@@ -36,17 +36,15 @@
*/
package org.cytoscape.io.write.internal.sif;
-import cytoscape.task.TaskMonitor;
-import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyRow;
-
import java.io.IOException;
import java.io.Writer;
-import java.util.Iterator;
import java.util.List;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.work.TaskMonitor;
+
// TODO make this implement CyNetworkWriter!
/**
* A few utility methods to assist in writing SIF files.
@@ -105,7 +103,7 @@
if (taskMonitor != null) {
// Report on Progress
double percent = ((double) i++ /
nodeList.size()) * 100.0;
- taskMonitor.setPercentCompleted((int) percent);
+ taskMonitor.setProgress(percent);
}
String canonicalName =
node.attrs().get("name",String.class);
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---