From: lingutln Date: Thu, 31 May 2012 19:34:56 +0000 (+0000) Subject: Data storage functionality completed. Done by Nikhil. X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=768ad1a814e8482614f88f15d3b4da25f7e3b397;p=old-jaiswallab-svn%2F.git Data storage functionality completed. Done by Nikhil. svn path=/; revision=340 --- diff --git a/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java b/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java index 3a62a7f..f72882f 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java @@ -51,8 +51,8 @@ public class ExportImageMapAction extends AppAction{ exporter.setHtmlFile(result.html); // Taking html file name and making the same as filename of imagemap - int dotIndex = result.html.indexOf('.'); - String zipFile = result.html.substring(0, dotIndex); + int dotIndex = result.image.indexOf('.'); + String zipFile = result.image.substring(0, dotIndex); exporter.setZipFile(zipFile+IMGMAP_EXTENSION); exporter.setImageFile(result.image); diff --git a/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java b/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java index 2821edb..e1fe18a 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java @@ -52,7 +52,7 @@ public class SaveAction extends AppAction { // Setup exporter Exporter exporter = new Exporter(image); exporter.setEffect(result.effect); - exporter.setHtmlFile(result.html); + exporter.setHtmlFile("imagemap.html"); // Taking html file name and making the same as filename of imagemap int dotIndex = result.html.indexOf('.'); diff --git a/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java b/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java index 6807637..8feeb30 100644 --- a/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java +++ b/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java @@ -37,7 +37,8 @@ public class ExportDialog extends Dialog { Result() { folder = new File(folderText.getText().trim()); - html = htmlText.getText().trim(); + //html = htmlText.getText().trim(); + html = "imagemap.html"; image = imageText.getText().trim(); link = linkText.getText().trim(); description = descriptionText.getText(); @@ -133,11 +134,11 @@ public class ExportDialog extends Dialog { label(widgets, "Export folder:"); folderText = text(widgets, ""); browseButton = button(widgets, "Browse..."); - label(widgets, "HTML file name:"); - htmlText = text(widgets, "imagemap.html"); - spacer(widgets); - label(widgets, "Image file name:"); - imageText = text(widgets, "image.png"); + //label(widgets, "HTML file name:"); + //htmlText = text(widgets, "imagemap.html"); + //spacer(widgets); + label(widgets, "File name:"); + imageText = text(widgets, "image"); spacer(widgets); hline(widgets); label(widgets, "Export shape:"); @@ -217,12 +218,12 @@ public class ExportDialog extends Dialog { return false; } - String htmlFile = htmlText.getText().trim(); + /*String htmlFile = htmlText.getText().trim(); if (htmlFile.equals("")) { validationError("The HTML file name cannot be empty"); htmlText.setFocus(); return false; - } + }*/ String imageFile = imageText.getText().trim(); if (imageFile.equals("")) { diff --git a/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java b/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java index 037b02c..557a0a9 100644 --- a/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java +++ b/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java @@ -119,10 +119,7 @@ public class Exporter { map.setImageName(imageName); map.setCuratorName(SegmentationView.curatorCombo.getText()); map.setSpeciesName(SegmentationView.speciesCombo.getText()); - if(!(SegmentationView.collectionId.getText().equals(""))) - { - map.setCollectionId(Integer.parseInt(SegmentationView.collectionId.getText())); - } + map.setCollectionId(SegmentationView.collectionId.getText()); map.setComments(SegmentationView.comment.getText()); List preloads = new ArrayList(); @@ -228,6 +225,10 @@ public class Exporter { map.addArea(area); } + + // Generating coordinates files + + } // Create an entry for the imageMap (code for saving image map file into the zip file) @@ -321,7 +322,26 @@ public class Exporter { String annotationId = mask.ontologyTerm.getAccessionId(); Element annotationIdElem = document.createElement("annotation_id"); annotationIdElem.appendChild(document.createTextNode(annotationId)); - segmentElement.appendChild(annotationIdElem); + segmentElement.appendChild(annotationIdElem); + + // Functionality for saving polygon coordinates + + ContourTracer tracer = new ContourTracer(mask, SegmentationMask.FOREGROUND); + List trace = tracer.trace(); + + String polygonCoords = ""; + for (Polygon polygon : trace) + { + for (int i = 0; i < polygon.npoints; i++) + { + polygonCoords = polygonCoords+polygon.xpoints[i]+","+polygon.ypoints[i]+","; + } + } + + Element polygonCoordsElem = document.createElement("polygon_coords"); + polygonCoordsElem.appendChild(document.createTextNode(polygonCoords)); + segmentElement.appendChild(polygonCoordsElem); + } TransformerFactory transformerFactory = TransformerFactory.newInstance(); @@ -329,6 +349,7 @@ public class Exporter { DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(out); + transformer.transform(source, result); }catch (ParserConfigurationException pce) { diff --git a/Annotation/src/ie/dcu/apps/ist/export/imagemap/ImageMap.java b/Annotation/src/ie/dcu/apps/ist/export/imagemap/ImageMap.java index f09ba48..670c1bf 100644 --- a/Annotation/src/ie/dcu/apps/ist/export/imagemap/ImageMap.java +++ b/Annotation/src/ie/dcu/apps/ist/export/imagemap/ImageMap.java @@ -31,7 +31,7 @@ public class ImageMap { private String mapName; private String curatorName; private String speciesName; - private int collectionId; + private String collectionId; private String comments; private final List areas; private final List preloads; @@ -111,11 +111,11 @@ public class ImageMap { this.speciesName = speciesName; } - public int getCollectionId() { + public String getCollectionId() { return collectionId; } - public void setCollectionId(int collectionId) { + public void setCollectionId(String collectionId) { this.collectionId = collectionId; } diff --git a/Annotation/src/ie/dcu/segment/SegmentationContext.java b/Annotation/src/ie/dcu/segment/SegmentationContext.java index 4831a5b..4d4e21e 100644 --- a/Annotation/src/ie/dcu/segment/SegmentationContext.java +++ b/Annotation/src/ie/dcu/segment/SegmentationContext.java @@ -541,6 +541,7 @@ public class SegmentationContext { } } SegmentationView.speciesCombo.setText(speciesTermName); + SegmentationView.speciesCombo.setData(speciesTermName,speciesTermId); SegmentationView.curatorCombo.setText(curatorName); SegmentationView.collectionId.setText(collectionId); SegmentationView.comment.setText(comment); @@ -632,8 +633,7 @@ public class SegmentationContext { } - - public static Document loadXMLFromZip(InputStream in) throws Exception + public static Document loadXMLFromZip(InputStream in) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder();