Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
[Trac tickets]
authorpreecej <preecej@localhost>
Wed, 4 Jul 2012 22:29:31 +0000 (22:29 +0000)
committerpreecej <preecej@localhost>
Wed, 4 Jul 2012 22:29:31 +0000 (22:29 +0000)
Closed: 204,200,203,202,198
Held: 193,188,186
Working on Trac tickets: 149,157

svn path=/; revision=352

Annotation/src/ie/dcu/apps/ist/AppWindow.java
Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java
Annotation/src/ie/dcu/apps/ist/actions/OpenAction.java
Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java
Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java
Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java
Annotation/src/ie/dcu/apps/ist/labelling/Labels.java
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java
Annotation/src/ie/dcu/segment/SegmentationContext.java

index e2e98b6332d2bb8aeb384a8c14aa2efc0aec22ee..cd242d4726c8970c1ff488ae57ce99d2e6b3b6ee 100644 (file)
@@ -325,11 +325,11 @@ public class AppWindow extends ApplicationWindow implements FileDropListener {
                
                tools.add(new Separator());
                tools.add(actions.get(ConfigureSegmenterAction.class));
-               */
+
                MenuManager go = addMenu(bar, "&Go");
                go.add(actions.get(NextAction.class));
                go.add(actions.get(PreviousAction.class));
-               
+               */
                MenuManager help = addMenu(bar, "&Help");
 
                help.add(actions.get(HelpAction.class));
index ce71c837a28fa33a0febec6983a0ff7c901eeabc..be8654ca96d14e8f0991b0cf44595614764ac5c0 100644 (file)
@@ -54,13 +54,13 @@ public class ExportImageMapAction extends AppAction{
                                        exporter.setZipFile(zipFile+IMGMAP_EXTENSION);
                                        
                                        exporter.setImageFile(result.image);
-                                       exporter.setObjectLink(result.link);
+                                       //exporter.setObjectLink(result.link);
                                        exporter.setExportShape(result.shape);
-                                       exporter.setObjectDescription(result.description);
+                                       //exporter.setObjectDescription(result.description);
                                        
                                        // Export
                                        try {
-                                               exporter.export(result.folder,masks);
+                                               exporter.export(result.folder,result.open,result.exportFolder,masks);
                                        } catch (IOException e) {
                                                handleError(e);
                                                return;
index fbfb5187716c221f4ad7471224ce53055969eef6..2b98513f197471e79d1082c6ac9da42444b5ef2b 100644 (file)
@@ -43,7 +43,7 @@ public class OpenAction extends AppAction {
                try {
                        // clear the decks
                        window.getView().resetView();
-
+                       
                        if (SegmentationContext.isContextFile(file)) {
                        
                                // Load context
@@ -56,7 +56,7 @@ public class OpenAction extends AppAction {
                                window.setContext(SegmentationContext.loadImageMap(file));
                                status("Opened segmentation context %s successfully", name);
                        }                       
-                       else {
+                       else { // JP - majority of cases (opening an img or zip file to annotate)
                                // Create context
                                window.setContext(SegmentationContext.create(file));
                                status("Opened image file %s successfully", name);
index 549a62cda43530b59e9acafc869d6c8de097bbc6..7d0d27d099f13ba03999a82de5b101fa176c6f62 100644 (file)
@@ -45,37 +45,41 @@ public class SaveAction extends AppAction {
                        ExportDialog.Result result = dialog.open();
                        
                        if (result != null) {
-                               
                                // Grab image and mask
-                               
-                                       BufferedImage image = ImageConverter.convert(ctx.getImageData());
-                                       // Setup exporter
-                                       Exporter exporter = new Exporter(image);
+                               BufferedImage image = ImageConverter.convert(ctx.getImageData());
+
+                               // Setup exporter
+                               Exporter exporter = new Exporter(image);
+
+                               // save the annotated zip file
+                               String zipFile = result.zipFile; 
+                               exporter.setZipFile(zipFile+IMGMAP_EXTENSION);
+
+                               exporter.setImageFile(result.image);
+
+                               // save add'l html image map and uncompressed img files, if desired
+                               if (result.open) {
                                        exporter.setEffect(result.effect);
-                                       exporter.setHtmlFile("imagemap.html");
-                                       
-                                       // Taking html file name and making the same as filename of imagemap
-                                       String zipFile = result.zipFile; 
-                                       exporter.setZipFile(zipFile+IMGMAP_EXTENSION);
-                                       
-                                       exporter.setImageFile(result.image);
-                                       exporter.setObjectLink(result.link);
+                                       exporter.setHtmlFile(zipFile+".html");
+                                       //exporter.setObjectLink(result.link);
                                        exporter.setExportShape(result.shape);
-                                       exporter.setObjectDescription(result.description);
+                                       //exporter.setObjectDescription(result.description);
+                               }
+                               
+                               // Export
+                               try {
+                                       exporter.export(result.folder,result.open,result.exportFolder,masks);
+                               } catch (IOException e) {
+                                       handleError(e);
+                                       return;
+                               } catch (ExportException e) {
+                                       handleError(e);
+                                       return;
+                               } 
                                        
-                                       // Export
-                                       try {
-                                               exporter.export(result.folder,masks);
-                                       } catch (IOException e) {
-                                               handleError(e);
-                                               return;
-                                       } catch (ExportException e) {
-                                               handleError(e);
-                                               return;
-                                       } 
                                // for opening the image after saving as ImageMap
                                if (result.open) {
-                                       File file = new File(result.folder, result.html);
+                                       File file = new File(result.folder, result.html); // TODO: will need to change this to .exportFolder
                                        Program program = Program.findProgram(".html");
                                        if (program != null) {
                                                program.execute(file.getAbsolutePath());
index 8bbf3942a56b320ad795646fde68480eae8629a5..f4904ed9b69389ae9ae149a7060c4193eb70c4dd 100644 (file)
@@ -27,11 +27,12 @@ public class ExportDialog extends Dialog {
 
        public class Result {
                public final File folder;
+               public final File exportFolder;
                public final String html;
                public final String zipFile;
                public final String image;
-               public final String link;
-               public final String description;
+               //public final String link;
+               //public final String description;
                public final AreaShape shape;
                public final RolloverEffect effect;
                public final boolean open;
@@ -39,12 +40,15 @@ public class ExportDialog extends Dialog {
                Result() {
                        folder = new File(folderText.getText().trim());
                        //html = htmlText.getText().trim();
-                       html = "imagemap.html";
                        zipFile = zipFileName.getText().trim();
+                       html = zipFile+".html";
+                       exportFolder = new File(folderText.getText().trim() + "/" + zipFile + "_HTML_export");
                        image = "image";
-                       link = linkText.getText().trim();
-                       description = descriptionText.getText();
-                       shape = getShape();
+                       // JP - URL specification disabled until it can be applied to individual segments  
+                       //link = linkText.getText().trim();
+                       //description = descriptionText.getText();
+                       //shape = getShape();
+                       shape = AreaShape.valueOf("Polygon"); // JP - only one option for now
                        effect = getEffect();
                        open = openButton.getSelection();
                }
@@ -78,7 +82,7 @@ public class ExportDialog extends Dialog {
        
        // Effects
        private final String[] ROLLOVER_EFFECTS = {
-               "Outline Object", "Darken Background", "Highlight Object"
+               "Darken Background", "Outline Object", "Highlight Object"
        };
        
        // Shapes
@@ -87,7 +91,7 @@ public class ExportDialog extends Dialog {
        };
        
        // Default title
-       private static final String TITLE = "Export HTML Image Map";
+       private static final String TITLE = "Save Annotation";
 
        public ExportDialog(Shell shell) {
                super(shell);
@@ -134,17 +138,18 @@ public class ExportDialog extends Dialog {
                buttons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
                
                // Form content
-               label(widgets, "Export folder:");
+               label(widgets, "Select folder:");
                folderText = text(widgets, "");
                browseButton = button(widgets, "Browse...");
-               label(widgets, "Target zip file name:");
-               zipFileName = text(widgets, "annotated");
+               label(widgets, "Name your .zip file:");
+               zipFileName = text(widgets, "");
                label(widgets, ".zip");
                //spacer(widgets);
                /*label(widgets, "File name:");
                imageText = text(widgets, "image");
                spacer(widgets);*/
                hline(widgets);
+               /* TODO: enhance this later to work for multiple segments
                label(widgets, "Export shape:");
                shapeRadios = radios(widgets, SHAPES);
                // TODO: Enable when available
@@ -156,13 +161,15 @@ public class ExportDialog extends Dialog {
                label(widgets, "Object description:");
                descriptionText = text(widgets, "");
                spacer(widgets);
+               */
+               // HTML image map options
+               openButton = checkbox(widgets, 
+                               "Create HTML image map and open in browser", true, 3); // TODO: change back to false once exportFolder works
+               // TODO: cascade the next two controls to disabled on the value of openButton
                effectCheck = checkbox(widgets, "Rollover effect:", true, 1);
                effectCombo = combo(widgets, ROLLOVER_EFFECTS);
                spacer(widgets);
-               hline(widgets);
-               openButton = checkbox(widgets, 
-                               "Open image map in browser after export completes", true, 3);
-               
+               //hline(widgets);
                // Button bar
                expander(buttons);
                cancelButton = new Button(buttons, SWT.PUSH);
index 1ed82c1b29673db2da31502e0f133ba7879f3e19..83b8054b4efcd1308da892855195f89c58b9584c 100644 (file)
@@ -107,7 +107,7 @@ public class Exporter {
                this.exportShape = shape;
        }
 
-       public void export(File folder, List<SegmentationMask> masks) throws IOException, ExportException {
+       public void export(File folder, boolean exportHTML, File exportFolder, List<SegmentationMask> masks) throws IOException, ExportException {
                
                // Create a zip file for saving imageMaps
                file = new File(folder,zipFile);
@@ -209,8 +209,8 @@ public class Exporter {
                                                break;
                                        }
                                        
-                                       area.setAlt(objectDescription);
-                                       area.setHref(objectLink);
+                                       //area.setAlt(objectDescription);
+                                       //area.setHref(objectLink);
                                        
                                        if (effect != null) {
                                                
@@ -220,7 +220,8 @@ public class Exporter {
                                                                        imageName, mask.layerNumber));
                                                area.addAttr("onmouseout", 
                                                                String.format("rollover(document.%s, image0)", imageName));
-                                               area.addAttr("title",mask.ontologyTerm.getName());
+                                               area.addAttr("title",mask.ontologyTerm.getName() 
+                                                               + " {" + mask.ontologyTerm.getAccessionId() + "}");
                                        }
                                        
                                        map.addArea(area);
@@ -241,7 +242,11 @@ public class Exporter {
                        map.exportToFile(out);*/
                        
                        // Exporting to Folder
-                       map.exportToFile(new File(folder, htmlFile));
+                       if (exportHTML) {
+                               // TODO: need to detect presence of exportFolder here and create it if it doesn't exist
+                               //map.exportToFile(new File(exportFolder, htmlFile));
+                               map.exportToFile(new File(folder, htmlFile)); // TEST: temporary (replace with exportFolder once created)
+                       }
                }
                finally 
                {
@@ -273,7 +278,7 @@ public class Exporter {
                  DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
                  
                  Document document = documentBuilder.newDocument();
-                 Element rootElement = document.createElement("Image_data");
+                 Element rootElement = document.createElement("image_data");
                  document.appendChild(rootElement);
                  
                  Element imageElement = document.createElement("image_filename");
@@ -281,7 +286,7 @@ public class Exporter {
                  
                  Element speciesElement = document.createElement("species");
                  speciesElement.setAttribute("name", SegmentationView.speciesCombo.getText());
-                 speciesElement.setAttribute("ubio_id", "Ubio:12345");
+                 speciesElement.setAttribute("ubio_id", (SegmentationView.speciesCombo.getData(SegmentationView.speciesCombo.getText())).toString());
                  rootElement.appendChild(speciesElement);
                  
                  Element curatorElement = document.createElement("curator_name");
@@ -304,7 +309,7 @@ public class Exporter {
                          Element segmentElement = document.createElement("segment");
                          segmentsElement.appendChild(segmentElement);
                          
-                         String url = "url";
+                         String url = "";
                          Element urlElem = document.createElement("url");
                          urlElem.appendChild(document.createTextNode(url));
                          segmentElement.appendChild(urlElem);
index 862d974e5aa62ade41092e70cfe26568289cdba9..0eafac8b14552954eaafa45d13ed07408b7673f1 100644 (file)
@@ -106,7 +106,7 @@ public class Labels
                                        for(int i = 0 ; i < nlist.getLength();i++) {
                                                //get the employee element
                                                Element el = (Element)nlist.item(i);
-                                               namBankId = new String(DatatypeConverter.parseBase64Binary(getTagValue("namebankID", el)));
+                                               namBankId = getTagValue("namebankID", el);
                                                nameBankString = new String(DatatypeConverter.parseBase64Binary(getTagValue("nameString", el)));
                                                SpeciesTerm species = new SpeciesTerm(nameBankString,namBankId);
                                                speciesTerms.add(species);
index 0fdcf1b5caac4795be1d20bf4b2de8c9893e338f..2483b250063e72372a6f6badc8fe8e319e3521cf 100644 (file)
@@ -18,8 +18,6 @@ import java.io.InputStreamReader;
 import java.lang.reflect.InvocationTargetException;
 import java.net.*;
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.Properties;
 import java.util.logging.*;
 
@@ -225,7 +223,7 @@ public class SegmentationView extends Composite {
                m.add(new Separator());
                m.add(getAction(Tool.AutoApply));
                m.add(getAction(Tool.Apply));
-               m.add(getAction(Tool.SegmenterOptions));
+               //m.add(getAction(Tool.SegmenterOptions));
                m.update(true);
        }
        
@@ -253,16 +251,24 @@ public class SegmentationView extends Composite {
         * TODO: then recall this method from the Open (Open Recent), Go Next, Go Previous, and Close...when you add Close 
         */
        public void resetView() {
-               comboLabel.deselectAll();
                Tool.OperatingMode.action.setChecked(false);
                resetViewSelectionToolbar(painters.get("Combined"));
+               // clear metadata
+               comboLabel.deselectAll();
+               comboLabel.setEnabled(false);
                clearTermDetailTable();
                clearTermSynonymTable();
                collectionId.setText("");
                comment.setText("");
                curatorCombo.deselectAll();
                speciesCombo.deselectAll();
-               
+               // clear segment data (term labels, layers, image coords)
+               if (view.getContext() != null) {
+                       ArrayList<SegmentationMask> segMasks = view.getContext().getSegmentationMasks();  
+                       if (segMasks.size() > 0)
+                               segMasks.clear();
+                       SegmentationMask.numberOfLayers = 0; // reset the layer counter for the next image
+               }
        }
        
        private String parseAccessionIdFromComboLabel(Combo comboLabel) {
@@ -1158,9 +1164,9 @@ public class SegmentationView extends Composite {
                case AssignButton:
                        assignLabel();
                        break;
-               case SegmenterOptions:
-                       showSegmenterOptions();
-                       break;
+               //case SegmenterOptions:
+                       //showSegmenterOptions();
+                       //break;
                }
                
                updateToolStates();
@@ -1190,7 +1196,7 @@ public class SegmentationView extends Composite {
                        Tool.OperatingMode.action.setChecked(getLabelMode());
                        Tool.Clear.action.setEnabled(canClear());
                        Tool.AutoApply.action.setChecked(auto);
-                       Tool.SegmenterOptions.action.setEnabled(canShowOptions());
+                       //Tool.SegmenterOptions.action.setEnabled(canShowOptions());
                        Tool.Foreground.action.setEnabled(!getLabelMode() && canZoomIn());
                        Tool.Background.action.setEnabled(!getLabelMode() && canZoomIn());
                        Tool.OperatingMode.action.setEnabled(canZoomIn());
@@ -1198,7 +1204,7 @@ public class SegmentationView extends Composite {
                                                
                        // Always enabled if view enabled
                        Tool.SetBrushSize.action.setEnabled(true);
-                       Tool.SegmenterOptions.action.setEnabled(true);
+                       //Tool.SegmenterOptions.action.setEnabled(true);
                        Tool.SetPainter.action.setEnabled(true);
                        Tool.Repaint.action.setEnabled(true);
                        Tool.AutoApply.action.setEnabled(true);
index 89ea60002191437109a7fbcf2a0d4290571b6a29..f75458fa14a296ceda43a656e63f3e64e0526cd0 100644 (file)
@@ -9,6 +9,7 @@ import ie.dcu.util.FileUtils;
 
 import java.io.*;
 import java.util.ArrayList;
+import java.util.logging.Logger;
 import java.util.zip.*;
 
 import javax.xml.bind.DatatypeConverter;
@@ -38,6 +39,8 @@ import org.xml.sax.InputSource;
  */
 public class SegmentationContext {
 
+       private static final Logger log = Logger.getLogger(SegmentationContext.class.getName()); // Logger
+
        /**
         * The file extension given to a this object when it is saved on a disk
         */
@@ -541,6 +544,8 @@ public class SegmentationContext {
                                                }
                                                SegmentationView.speciesCombo.setText(speciesTermName);
                                        SegmentationView.speciesCombo.setData(speciesTermName,speciesTermId);
+                                       /*log.info(SegmentationView.speciesCombo.getText() + ":" 
+                                                       + (SegmentationView.speciesCombo.getData(speciesTermName)).toString());*/ // TEST
                                        SegmentationView.curatorCombo.setText(curatorName);
                                                SegmentationView.collectionId.setText(collectionId);
                                                SegmentationView.comment.setText(comment);