Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Multi segment saving to imagemaps (partially done). Done by Nikhil.
authorlingutln <lingutln@localhost>
Thu, 26 Jan 2012 19:42:18 +0000 (19:42 +0000)
committerlingutln <lingutln@localhost>
Thu, 26 Jan 2012 19:42:18 +0000 (19:42 +0000)
svn path=/; revision=280

Annotation/src/ie/dcu/apps/ist/AppWindow.java
Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java
Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java
Annotation/src/ie/dcu/apps/ist/export/imagemap/ImageMap.java
Annotation/src/ie/dcu/segment/SegmentationContext.java

index 8694588a04bb8ef9bc49a1764bf23e1d4e8a21ab..d15733622c6818eedaf527cb2197be01e91c851b 100644 (file)
@@ -196,15 +196,10 @@ public class AppWindow extends ApplicationWindow implements FileDropListener {
                SegmentationContext ctx = getContext();
                
                if (ctx != null && !isExperimentMode()) {
-                       AnnotationManager am = ctx.getAnnotations();
-                       boolean hasObject = am.hasForegroundAnnotation() 
-                               && am.hasBackgroundAnnotation();
-               //      a.setEnabled(ExportImageMapAction.class, hasObject);
-                       a.setEnabled(ExportImageMapAction.class, true);//change after demo
-               
+                       a.setEnabled(ExportImageMapAction.class, ctx.hasSegmentationMasks());
+                       
                } else {
-                       //a.setEnabled(ExportImageMapAction.class, false);
-                       a.setEnabled(ExportImageMapAction.class, true);// change after demo
+                       a.setEnabled(ExportImageMapAction.class, false);
                }
        }
        
index bef17a8d4d36605db1b7958bfc38377ceffd5589..8b758a3602a4d3c6133f5f379f4e9954c8784fc0 100644 (file)
@@ -26,7 +26,9 @@ public class ExportImageMapAction extends AppAction{
        @Override 
        public void run() { 
                
-               if (window.hasContext()) {
+               SegmentationContext ctx = window.getContext();
+               
+               if (ctx.hasSegmentationMasks()) {
                        
                        // Get options from user
                        ExportDialog dialog = new ExportDialog(window.getShell());
@@ -35,35 +37,36 @@ public class ExportImageMapAction extends AppAction{
                        if (result != null) {
                                
                                // Grab image and mask
-                               SegmentationContext ctx = window.getContext();
-                               SegmentationMask mask = ctx.getSegmentationMasks().get(0);
-                               BufferedImage image = ImageConverter.convert(ctx.getImageData());
-                               
-                               // Setup exporter
-                               Exporter exporter = new Exporter(image, mask);
-                               exporter.setEffect(result.effect);
-                               exporter.setHtmlFile(result.html);
-                               exporter.setImageFile(result.image);
-                               exporter.setObjectLink(result.link);
-                               exporter.setExportShape(result.shape);
-                               exporter.setObjectDescription(result.description);
-                               String label = SegmentationView.comboLabel.getText();
-                       if(label.indexOf('{') != -1)
-                       {
-                               label = label.substring(0,label.indexOf('{')-1);
-                       }
-                       exporter.setTitle(label);
                                
-                               // Export
-                               try {
-                                       exporter.export(result.folder);
-                               } catch (IOException e) {
-                                       handleError(e);
-                                       return;
-                               } catch (ExportException e) {
-                                       handleError(e);
-                                       return;
-                               } 
+                               for (SegmentationMask mask : ctx.getSegmentationMasks())
+                               {
+                                       BufferedImage image = ImageConverter.convert(ctx.getImageData());
+                                       // Setup exporter
+                                       Exporter exporter = new Exporter(image, mask);
+                                       exporter.setEffect(result.effect);
+                                       exporter.setHtmlFile(result.html);
+                                       exporter.setImageFile(result.image);
+                                       exporter.setObjectLink(result.link);
+                                       exporter.setExportShape(result.shape);
+                                       exporter.setObjectDescription(result.description);
+                                       String label = SegmentationView.comboLabel.getText();
+                               if(label.indexOf('{') != -1)
+                               {
+                                       label = label.substring(0,label.indexOf('{')-1);
+                               }
+                               exporter.setTitle(label);
+                                       
+                                       // Export
+                                       try {
+                                               exporter.export(result.folder, mask.layerNumber);
+                                       } 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);
index 09fafa15bef2e7244ecf597954ededd9ffeec5b8..3418b85f27980fe23677d06ead78cd8c6d3ea27c 100644 (file)
@@ -98,7 +98,7 @@ public class Exporter {
                this.exportShape = shape;
        }
 
-       public void export(File folder) throws IOException, ExportException {
+       public void export(File folder, int layerNumber) throws IOException, ExportException {
                ContourTracer tracer = new ContourTracer(mask, SegmentationMask.FOREGROUND);
                List<Polygon> trace = tracer.trace();
                
@@ -106,7 +106,7 @@ public class Exporter {
                        throw new ExportException("No objects found");
                }
                
-               List<String> preloads = getPreloads(trace);
+               List<String> preloads = getPreloads(trace,layerNumber);
                
                // Write image
                ImageIO.write(image, "png", new File(folder, imageFile));
@@ -168,10 +168,10 @@ public class Exporter {
                        map.addArea(area);
                }
                
-               map.exportToFile(new File(folder, htmlFile));
+               map.exportToFile(new File(folder, layerNumber+htmlFile));
        }
        
-       private List<String> getPreloads(List<Polygon> trace) {
+       private List<String> getPreloads(List<Polygon> trace, int layerNumber) {
                List<String> preloads = new ArrayList<String>();
                preloads.add(imageFile);
                
@@ -179,7 +179,7 @@ public class Exporter {
                        
                        String basename = FileUtils.removeExtension(imageFile);
                        for (int i = 0; i < trace.size(); i++) {
-                               String filename = String.format("%s-%d.png", basename, i);
+                               String filename = String.format("%s-%d.png", basename, layerNumber);
                                preloads.add(filename);
                        }
                }
index 4125ccfb9de9ed380693f4c884049e56f24b5531..8c8ee38d3f93af4089ebde52edd15d9480ac1139 100644 (file)
@@ -130,7 +130,7 @@ public class ImageMap {
                subs.put("map-name", mapName);
                subs.put("contents", contents.toString());
                subs.put("preloads", preloads.toString());
-               
+               System.out.println("Contents coming as "+contents.toString());
                return substitute(template, subs);
        }
        
index a92c8288ea6021e9b60e5c86c05017253f1f0cd9..b7c095064d63387123087032aff2045f4c0282ea 100644 (file)
@@ -171,6 +171,15 @@ public class SegmentationContext {
                return segmentationMaskObjects;
        }
        
+       /**
+        * @return
+        * Returns boolean value based on whether there are segmentationMasks formed or not.
+        */
+       public boolean hasSegmentationMasks() {
+               
+               return segmentationMaskObjects.size() != 0;
+       }
+       
        /**
         * For highlighting the clicked segmentObject
         * @param x, mouse clicked point x