Author: ruschein
Date: 2011-04-04 13:55:49 -0700 (Mon, 04 Apr 2011)
New Revision: 24656
Added:
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/TunableAbstractCyWriter.java
core3/io-api/trunk/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
core3/io-api/trunk/src/test/java/org/cytoscape/io/write/
core3/io-api/trunk/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
Removed:
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/AbstractCyWriter.java
Modified:
core3/core-task-impl/trunk/pom.xml
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyNetworkViewWriter.java
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyTableWriter.java
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/ViewWriter.java
Log:
Moved AbstractCyWriter into io-api from core-task-impl.
Modified: core3/core-task-impl/trunk/pom.xml
===================================================================
--- core3/core-task-impl/trunk/pom.xml 2011-04-04 20:55:20 UTC (rev 24655)
+++ core3/core-task-impl/trunk/pom.xml 2011-04-04 20:55:49 UTC (rev 24656)
@@ -116,6 +116,13 @@
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
+ <artifactId>io-api</artifactId>
+ <version>3.0.0-alpha3-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
<artifactId>property-api</artifactId>
<version>3.0.0-alpha4-SNAPSHOT</version>
</dependency>
Deleted:
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/AbstractCyWriter.java
===================================================================
---
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/AbstractCyWriter.java
2011-04-04 20:55:20 UTC (rev 24655)
+++
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/AbstractCyWriter.java
2011-04-04 20:55:49 UTC (rev 24656)
@@ -1,116 +0,0 @@
-
-package org.cytoscape.task.internal.io;
-
-import org.cytoscape.work.AbstractTask;
-import org.cytoscape.work.TaskMonitor;
-import org.cytoscape.work.Tunable;
-import org.cytoscape.work.util.ListSingleSelection;
-import org.cytoscape.io.CyFileFilter;
-import org.cytoscape.io.write.CyWriter;
-import org.cytoscape.io.write.CyWriterManager;
-
-import java.io.File;
-
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.ArrayList;
-
-/**
- * An abstract utility implementation of a Task that writes a user defined
- * file to a file type determined by a provided writer manager. This class
- * is meant to be extended for specific file types such that the appropriate
- * {@link org.cytoscape.io.write.CyWriter} can be identified.
- */
-public abstract class AbstractCyWriter<T extends CyWriterManager> extends
AbstractTask
- implements CyWriter {
-
- private File outputFile;
-
- /**
- * The method sets the file to be written. This field should not
- * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
- * processing. This method is the "setter" portion of a
- * getter/setter tunable method pair.
- * @param f The file to be written.
- */
- public final void setOutputFile(File f) {
- if ( f != null )
- outputFile = f;
- }
-
- /**
- * This method gets the file to be written. This method should not
- * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
- * processing. This method is the "getter" portion of a
- * getter/setter tunable method pair.
- * @return The file to be written.
- */
- @Tunable(description="Select the output file name")
- public final File getOutputFile() {
- return outputFile;
- }
-
- /**
- * The list of file type options generated by the file types
- * available from the CyWriterManager. This field should not
- * be set directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
- * processing.
- */
- @Tunable(description = "Select the export file format")
- public final ListSingleSelection<String> options;
-
- private final Map<String,CyFileFilter> descriptionFilterMap;
-
- /**
- * The CyWriterManager specified in the constructor.
- */
- protected final T writerManager;
-
- /**
- * @param writerManager The CyWriterManager to be used to determine
which
- * {@link org.cytoscape.io.write.CyWriter} to be used to write the file
chosen by the user.
- */
- public AbstractCyWriter(T writerManager) {
- if ( writerManager == null )
- throw new NullPointerException("CyWriterManager is
null");
- this.writerManager = writerManager;
-
- descriptionFilterMap = new TreeMap<String,CyFileFilter>();
- for ( CyFileFilter f :
writerManager.getAvailableWriterFilters() )
- descriptionFilterMap.put( f.getDescription(), f );
-
- options = new ListSingleSelection<String>( new
ArrayList<String>( descriptionFilterMap.keySet() ) );
- }
-
- /**
- * This method processes the chosen input file and output type and
attempts
- * to write the file.
- * @param tm The {@link org.cytoscape.work.TaskMonitor} provided by the
TaskManager execution environment.
- */
- public final void run(TaskMonitor tm) throws Exception {
- if ( outputFile == null )
- throw new NullPointerException("Output file has not be
specified!");
-
- String desc = options.getSelectedValue();
- if ( desc == null )
- throw new NullPointerException("No file type has been
specified!");
-
- CyFileFilter filter = descriptionFilterMap.get(desc);
- if ( filter == null )
- throw new NullPointerException("No file filter found
for specified file type!");
-
- CyWriter writer = getWriter(filter,outputFile);
- if ( writer == null )
- throw new NullPointerException("No CyWriter found for
specified file type!");
-
- insertTasksAfterCurrentTask( writer );
- }
-
- /**
- * Should return a {@link org.cytoscape.io.write.CyWriter} object for
writing the specified file of the specified type.
- * @param filter The specific type of file to be written.
- * @param out The file that will be written.
- */
- protected abstract CyWriter getWriter(CyFileFilter filter, File out)
throws Exception;
-
-}
Modified:
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyNetworkViewWriter.java
===================================================================
---
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyNetworkViewWriter.java
2011-04-04 20:55:20 UTC (rev 24655)
+++
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyNetworkViewWriter.java
2011-04-04 20:55:49 UTC (rev 24656)
@@ -1,6 +1,6 @@
-
package org.cytoscape.task.internal.io;
+
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.io.CyFileFilter;
import org.cytoscape.io.write.CyNetworkViewWriterFactory;
@@ -9,11 +9,11 @@
import java.io.File;
+
/**
* A utility Task implementation specifically for writing a {@link
org.cytoscape.view.model.CyNetworkView}.
*/
-public final class CyNetworkViewWriter extends
AbstractCyWriter<CyNetworkViewWriterManager> {
-
+public final class CyNetworkViewWriter extends
TunableAbstractCyWriter<CyNetworkViewWriterManager> {
// the view to be written
private final CyNetworkView view;
@@ -22,10 +22,10 @@
* {@link org.cytoscape.io.write.CyNetworkViewWriterFactory} to use to
write the file.
* @param view The {@link org.cytoscape.view.model.CyNetworkView} to be
written out.
*/
- public CyNetworkViewWriter(CyNetworkViewWriterManager writerManager,
CyNetworkView view ) {
+ public CyNetworkViewWriter(CyNetworkViewWriterManager writerManager,
CyNetworkView view ) {
super(writerManager);
- if ( view == null )
- throw new NullPointerException("View is null");
+ if (view == null)
+ throw new NullPointerException("View is null!");
this.view = view;
}
Modified:
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyTableWriter.java
===================================================================
---
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyTableWriter.java
2011-04-04 20:55:20 UTC (rev 24655)
+++
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/CyTableWriter.java
2011-04-04 20:55:49 UTC (rev 24656)
@@ -12,7 +12,7 @@
/**
* A utility Task implementation specifically for writing {@link
org.cytoscape.model.CyTable} objects.
*/
-public final class CyTableWriter extends
AbstractCyWriter<CyTableWriterManager> {
+public final class CyTableWriter extends
TunableAbstractCyWriter<CyTableWriterManager> {
private final CyTable table;
Copied:
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/TunableAbstractCyWriter.java
(from rev 24650,
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/AbstractCyWriter.java)
===================================================================
---
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/TunableAbstractCyWriter.java
(rev 0)
+++
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/TunableAbstractCyWriter.java
2011-04-04 20:55:49 UTC (rev 24656)
@@ -0,0 +1,57 @@
+package org.cytoscape.task.internal.io;
+
+
+import org.cytoscape.work.Tunable;
+import org.cytoscape.work.util.ListSingleSelection;
+import org.cytoscape.io.CyFileFilter;
+import org.cytoscape.io.write.AbstractCyWriter;
+import org.cytoscape.io.write.CyWriterManager;
+
+import java.io.File;
+
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.ArrayList;
+
+
+/**
+ * An abstract utility implementation of a Task that writes a user defined
+ * file to a file type determined by a provided writer manager. This class
+ * is meant to be extended for specific file types such that the appropriate
+ * {@link org.cytoscape.io.write.CyWriter} can be identified.
+ */
+public abstract class TunableAbstractCyWriter<T extends CyWriterManager>
extends AbstractCyWriter<T> {
+ /**
+ * This method gets the file to be written. This method should not
+ * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
+ * processing. This method is the "getter" portion of a
+ * getter/setter tunable method pair.
+ * @return The file to be written.
+ */
+ @Tunable(description="Select the output file name")
+ public final File getOutputFile() {
+ return outputFile;
+ }
+
+ /**
+ * The list of file type options generated by the file types
+ * available from the CyWriterManager. This field should not
+ * be set directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
+ * processing.
+ */
+ @Tunable(description = "Select the export file format")
+ public final ListSingleSelection<String> options;
+
+ protected final String getExportFileFormat() {
+ return options.getSelectedValue();
+ }
+
+ /**
+ * @param writerManager The CyWriterManager to be used to determine
which
+ * {@link org.cytoscape.io.write.CyWriter} to be used to write the file
chosen by the user.
+ */
+ public TunableAbstractCyWriter(T writerManager) {
+ super(writerManager);
+ options = new ListSingleSelection<String>(new
ArrayList<String>(descriptionFilterMap.keySet()));
+ }
+}
Modified:
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/ViewWriter.java
===================================================================
---
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/ViewWriter.java
2011-04-04 20:55:20 UTC (rev 24655)
+++
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/ViewWriter.java
2011-04-04 20:55:49 UTC (rev 24656)
@@ -1,6 +1,6 @@
-
package org.cytoscape.task.internal.io;
+
import org.cytoscape.view.model.View;
import org.cytoscape.view.presentation.RenderingEngine;
import org.cytoscape.io.CyFileFilter;
@@ -9,12 +9,12 @@
import java.io.File;
+
/**
* A utility Task implementation that will write the specified View to the
* the specified image file using the specified RenderingEngine.
*/
-public final class ViewWriter extends
AbstractCyWriter<PresentationWriterManager> {
-
+public final class ViewWriter extends
TunableAbstractCyWriter<PresentationWriterManager> {
private final View<?> view;
private final RenderingEngine<?> re;
@@ -24,7 +24,7 @@
* @param view The View object to be written to the specified file.
* @param re The RenderingEngine used to generate the image to be
written to the file.
*/
- public ViewWriter(final PresentationWriterManager writerManager, final
View<?> view, final RenderingEngine<?> re ) {
+ public ViewWriter(final PresentationWriterManager writerManager, final
View<?> view, final RenderingEngine<?> re ) {
super(writerManager);
if ( view == null )
Copied:
core3/io-api/trunk/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
(from rev 24650,
core3/core-task-impl/trunk/src/main/java/org/cytoscape/task/internal/io/AbstractCyWriter.java)
===================================================================
---
core3/io-api/trunk/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
(rev 0)
+++
core3/io-api/trunk/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
2011-04-04 20:55:49 UTC (rev 24656)
@@ -0,0 +1,107 @@
+package org.cytoscape.io.write;
+
+
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+import org.cytoscape.work.Tunable;
+import org.cytoscape.work.util.ListSingleSelection;
+import org.cytoscape.io.CyFileFilter;
+import org.cytoscape.io.write.CyWriter;
+import org.cytoscape.io.write.CyWriterManager;
+
+import java.io.File;
+
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.ArrayList;
+
+
+/**
+ * An abstract utility implementation of a Task that writes a user defined
+ * file to a file type determined by a provided writer manager. This class
+ * is meant to be extended for specific file types such that the appropriate
+ * {@link org.cytoscape.io.write.CyWriter} can be identified.
+ */
+public abstract class AbstractCyWriter<T extends CyWriterManager> extends
AbstractTask
+ implements CyWriter
+{
+ protected File outputFile;
+
+ /**
+ * The method sets the file to be written. This field should not
+ * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
+ * processing. This method is the "setter" portion of a
+ * getter/setter tunable method pair.
+ * @param f The file to be written.
+ */
+ public final void setOutputFile(File f) {
+ if ( f != null )
+ outputFile = f;
+ }
+
+ /**
+ * This method gets the file to be written. This method should not
+ * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
+ * processing. This method is the "getter" portion of a
+ * getter/setter tunable method pair.
+ * @return The file to be written.
+ */
+ public File getOutputFile() {
+ return outputFile;
+ }
+
+ abstract protected String getExportFileFormat();
+
+ protected final Map<String,CyFileFilter> descriptionFilterMap;
+
+ /**
+ * The CyWriterManager specified in the constructor.
+ */
+ protected final T writerManager;
+
+ /**
+ * @param writerManager The CyWriterManager to be used to determine
which
+ * {@link org.cytoscape.io.write.CyWriter} to be used to write the file
chosen by the user.
+ */
+ public AbstractCyWriter(T writerManager) {
+ if (writerManager == null)
+ throw new NullPointerException("CyWriterManager is
null");
+ this.writerManager = writerManager;
+
+ descriptionFilterMap = new TreeMap<String,CyFileFilter>();
+ for (CyFileFilter f : writerManager.getAvailableWriterFilters())
+ descriptionFilterMap.put(f.getDescription(), f);
+ }
+
+ /**
+ * This method processes the chosen input file and output type and
attempts
+ * to write the file.
+ * @param tm The {@link org.cytoscape.work.TaskMonitor} provided by the
TaskManager execution environment.
+ */
+ public final void run(final TaskMonitor tm) throws Exception {
+ if (outputFile == null)
+ throw new NullPointerException("Output file has not be
specified!");
+
+ final String desc = getExportFileFormat();
+ if (desc == null)
+ throw new NullPointerException("No file type has been
specified!");
+
+ final CyFileFilter filter = descriptionFilterMap.get(desc);
+ if (filter == null)
+ throw new NullPointerException("No file filter found
for specified file type!");
+
+ final CyWriter writer = getWriter(filter, outputFile);
+ if (writer == null)
+ throw new NullPointerException("No CyWriter found for
specified file type!");
+
+ insertTasksAfterCurrentTask(writer);
+ }
+
+ /**
+ * Should return a {@link org.cytoscape.io.write.CyWriter} object for
writing the specified file of the specified type.
+ * @param filter The specific type of file to be written.
+ * @param out The file that will be written.
+ */
+ protected abstract CyWriter getWriter(CyFileFilter filter, File out)
throws Exception;
+
+}
Copied:
core3/io-api/trunk/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
(from rev 24649,
core3/io-api/trunk/src/test/java/org/cytoscape/io/DummyTest.java)
===================================================================
---
core3/io-api/trunk/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
(rev 0)
+++
core3/io-api/trunk/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
2011-04-04 20:55:49 UTC (rev 24656)
@@ -0,0 +1,28 @@
+package org.cytoscape.io.write;
+
+
+import java.io.File;
+
+import org.cytoscape.io.CyFileFilter;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+
+public abstract class AbstractCyWriterTest {
+ protected AbstractCyWriter cyWriter;
+ protected CyFileFilter fileFilter;
+
+ @Test
+ public void testOutputFile() {
+ final File outputFile = new File("dummy");
+ cyWriter.setOutputFile(outputFile);
+ assertEquals(outputFile, cyWriter.getOutputFile());
+ }
+
+ @Test
+ public void testGetWriter() throws Exception {
+ final File outputFile = new File("dummy");
+ assertNotNull(cyWriter.getWriter(fileFilter, outputFile));
+ }
+}
--
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.