Author: scooter
Date: 2011-06-15 13:01:29 -0700 (Wed, 15 Jun 2011)
New Revision: 25761
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/visual/customgraphic/PersistImageTask.java
Log:
General clean-up to avoid NPE's when the .cytoscape/images directory
doesn't exist. Also log the error as oppsed to printing a backtrace
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/visual/customgraphic/PersistImageTask.java
===================================================================
---
cytoscape/trunk/application/src/main/java/cytoscape/visual/customgraphic/PersistImageTask.java
2011-06-15 19:57:01 UTC (rev 25760)
+++
cytoscape/trunk/application/src/main/java/cytoscape/visual/customgraphic/PersistImageTask.java
2011-06-15 20:01:29 UTC (rev 25761)
@@ -40,10 +40,21 @@
taskMonitor
.setStatus("Saving image library to your local
disk.\n\nPlease wait...");
taskMonitor.setPercentCompleted(-1);
+
+ // Does the directory exist?
+ if (!location.exists()) {
+ // No, create it
+ if (!location.mkdir()) {
+ logger.warning("Unable to create image library
directory: "+location);
+ return;
+ }
+ }
// Remove all existing files
final File[] files = location.listFiles();
- for (File old : files)
- old.delete();
+ if (files != null && files.length > 0) {
+ for (File old : files)
+ old.delete();
+ }
final long startTime = System.currentTimeMillis();
final CustomGraphicsManager pool =
Cytoscape.getVisualMappingManager()
@@ -65,7 +76,7 @@
exService.submit(new
SaveImageTask(location, cg.getIdentifier().toString(),
ImageUtil.toBufferedImage(img)));
} catch (Exception e) {
- e.printStackTrace();
+ logger.warning("Unable to save images",
e);
}
}
@@ -83,7 +94,7 @@
"Image Metadata");
} catch (IOException e) {
taskMonitor.setException(e, "Could not save image
metadata.");
- e.printStackTrace();
+ logger.warning("Could not save image metadata.",e);
}
long endTime = System.currentTimeMillis();
--
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.