Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
svn path=/; revision=297
authorlingutln <lingutln@localhost>
Fri, 10 Feb 2012 02:46:16 +0000 (02:46 +0000)
committerlingutln <lingutln@localhost>
Fri, 10 Feb 2012 02:46:16 +0000 (02:46 +0000)
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/apps/ist/export/imagemap/template.html
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java
Annotation/src/ie/dcu/apps/ist/widgets/AnnotatedImageControl.java

index ef8b1f68d0a2f92234e78078ad48b1f57c68103f..ed9fd591d9fd85f03ef03703c93393f3c0aa3615 100644 (file)
@@ -2,7 +2,6 @@ package ie.dcu.apps.ist.actions;
 
 import ie.dcu.apps.ist.dialogs.ExportDialog;
 import ie.dcu.apps.ist.export.imagemap.*;
-import ie.dcu.apps.ist.views.*;
 import ie.dcu.segment.*;
 import ie.dcu.swt.ImageConverter;
 
@@ -41,20 +40,14 @@ public class ExportImageMapAction extends AppAction{
                                
                                        BufferedImage image = ImageConverter.convert(ctx.getImageData());
                                        // Setup exporter
-                                       Exporter exporter = new Exporter(image, masks);
+                                       Exporter exporter = new Exporter(image);
                                        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,masks);
index 0e5a1dbe27c7c8aad455c08612d8adca6d3a53b4..fdd16283e065c3fe0e188d86aa623850f38be9e8 100644 (file)
@@ -1,5 +1,6 @@
 package ie.dcu.apps.ist.export.imagemap;
 
+import ie.dcu.apps.ist.views.SegmentationView;
 import ie.dcu.image.ContourTracer;
 import ie.dcu.segment.SegmentationMask;
 import ie.dcu.util.FileUtils;
@@ -26,12 +27,10 @@ public class Exporter {
        private String imageName = "image";
        private String objectDescription = "";
        private String objectLink = "";
-       private String title = "";
        private AreaShape exportShape = AreaShape.Polygon;
        
-       public Exporter(BufferedImage image, List<SegmentationMask> masks) {
+       public Exporter(BufferedImage image) {
                this.image = image;
-       //      this.masks = masks;
        }
        
        public RolloverEffect getEffect() {
@@ -65,14 +64,6 @@ public class Exporter {
        public void setImageName(String imageName) {
                this.imageName = imageName;
        }
-
-       public String getTitle() {
-               return title;
-       }
-
-       public void setTitle(String title) {
-               this.title = title;
-       }
        
        public String getObjectDescription() {
                return objectDescription;
@@ -104,6 +95,10 @@ public class Exporter {
                ImageMap map = new ImageMap();
                map.setImageHref(imageFile);
                map.setImageName(imageName);
+               map.setCuratorName(SegmentationView.curatorCombo.getText());
+               map.setSpeciesName(SegmentationView.speciesCombo.getText());
+               map.setCollectionId(Integer.parseInt(SegmentationView.collectionId.getText()));
+               map.setComments(SegmentationView.comment.getText());
                
                List<String> preloads = new ArrayList<String>();
                map.addPreload(imageFile);
@@ -127,7 +122,7 @@ public class Exporter {
                                for (Polygon object : trace) {
                                        RenderedImage im = effect.createEffect(image, object);
                                        // '0' for Rollover effect 
-                                       File output = new File(folder, preloads.get(0));
+                                       File output = new File(folder, preloads.get(i));
                                        ImageIO.write(im, "png", output);
                                }
                        }
index a92ba040318afdce73dd9b66e31ba84894dcf31a..6f7f7adff6ee9da036865aba5736d6e406b1674d 100644 (file)
@@ -26,9 +26,14 @@ public class ImageMap {
        private String imageHref;
        private String imageAlt;
        private String mapName;
+       private String curatorName;
+       private String speciesName;
+       private int collectionId;
+       private String comments;
        private final List<MapArea> areas;
        private final List<String> preloads;
-       
+       private final List<String> metadata;
+               
        public ImageMap() {
                // set defaults :
                this.pageTitle = "Image Map";
@@ -38,6 +43,7 @@ public class ImageMap {
                this.mapName = "imagemap";
                this.areas = new LinkedList<MapArea>();
                this.preloads = new LinkedList<String>();
+               this.metadata = new LinkedList<String>();
        }
 
        public String getPageTitle() {
@@ -84,6 +90,41 @@ public class ImageMap {
                this.mapName = mapName;
        }
 
+       public String getCuratorName() {
+               return curatorName;
+       }
+
+       public void setCuratorName(String curatorName) {
+               assert (curatorName != null);
+               this.curatorName = curatorName;
+       }
+       
+       public String getSpeciesName() {
+               return speciesName;
+       }
+
+       public void setSpeciesName(String speciesName) {
+               assert (speciesName != null);
+               this.speciesName = speciesName;
+       }
+       
+       public int getCollectionId() {
+               return collectionId;
+       }
+
+       public void setCollectionId(int collectionId) {
+               this.collectionId = collectionId;
+       }
+       
+       public String getComments() {
+               return comments;
+       }
+
+       public void setComments(String comments) {
+               assert (comments != null);
+               this.comments = comments;
+       }
+       
        public void addArea(MapArea area) {
                areas.add(area);
        }
@@ -100,13 +141,17 @@ public class ImageMap {
                return preloads;
        }
 
+       public List<String> metadata() {
+               return metadata;
+       }
+       
        public String export() {
                String template = loadTemplate();
                
                // Create preloads buffer
                StringBuffer preloads = new StringBuffer();
+               StringBuffer metadata = new StringBuffer();
                int idx = 0;
-               //System.out.println("Preloads coming as before"+preloads());
                for (String s : preloads()) {
                        HtmlTag.indent(preloads, 8);
                        preloads.append("var image").append(idx);
@@ -116,7 +161,14 @@ public class ImageMap {
                        preloads.append(".src = '").append(s).append("'\n");
                        idx++;
                }
-               //System.out.println("Preloads coming as after"+preloads.toString());
+               
+               // Adding table and values for metadata 
+               HtmlTag.indent(metadata, 8);
+               metadata.append("<tr> <td> Species Name </td><td>").append(getSpeciesName()).append("</td></tr>");
+               metadata.append("<tr> <td> Curator Name </td><td>").append(getCuratorName()).append("</td></tr>");
+               metadata.append("<tr> <td> Collection Id </td><td>").append(getCollectionId()).append("</td></tr>");
+               metadata.append("<tr> <td> Comments </td><td>").append(getComments()).append("</td></tr>");
+               
                StringBuffer contents = new StringBuffer();
                for (MapArea area : areas) {
                        contents.append('\n');
@@ -131,12 +183,14 @@ public class ImageMap {
                subs.put("map-name", mapName);
                subs.put("contents", contents.toString());
                subs.put("preloads", preloads.toString());
+               subs.put("image_metadata", metadata.toString());
                return substitute(template, subs);
        }
        
        public void exportToFile(File file) throws IOException {
                FileWriter writer = new FileWriter(file);
                try {
+                       System.out.println("Content"+export().toString());
                        writer.append(export());
                } finally {
                        writer.close();
index 159d2a18ae052dbf171ea317403d66c49d22b1cd..1b10f02b448e84da6ac341c40ac7067b0fd4557f 100644 (file)
@@ -34,5 +34,8 @@ ${preloads}
     <map name="${map-name}" id="${map-name}">
 ${contents}
     </map>
+       <table border = '1'>
+${image_metadata}
+       </table>
 </body>
 </html>
\ No newline at end of file
index b928b269bde5e8f3f854ba6185d5e8d04c48ada5..031225bfb5baeb824de75c4a3e23441f6a0bca56 100644 (file)
@@ -26,7 +26,6 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.*;
 import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.*;
 import org.eclipse.swt.widgets.*;
 
@@ -74,11 +73,11 @@ public class SegmentationView extends Composite {
        // Combo box housing the selectable views
        private Combo combo;
 
-       public static Combo comboLabel,curatorCombo,dummyCombo;
+       public static Combo comboLabel,curatorCombo,speciesCombo;
        
        private static Button assign;
        
-       private static Text collectionId, comment;
+       public static Text collectionId, comment;
        
        // Current segmentation tool
        private Segmenter segmenter;
@@ -115,8 +114,7 @@ public class SegmentationView extends Composite {
                SetLabel,
                AssignButton,
                SetCurator,
-               SegmenterOptions,
-               CollectionId;
+               SegmenterOptions;
                
                private ToolAction action;
        };
@@ -334,6 +332,22 @@ public class SegmentationView extends Composite {
        }
        
        private void createTermDetailFields() {
+               
+               // Combo box and label for curator
+               SwtUtils.addLabelToComposite(termDetailComposite, "Species Name");
+               speciesCombo = SwtUtils.addComboToComposite(termDetailComposite, 150, SWT.READ_ONLY);
+               speciesCombo.setToolTipText( getAction(Tool.SetPainter).getToolTipText());
+               speciesCombo.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               execute(Tool.SetPainter, null);
+                       }
+               });
+               //Temporary list items, need to be populated through Ubio web service
+               speciesCombo.add("Species One");
+               speciesCombo.add("Species Two");
+               speciesCombo.add("Species Three");
+               speciesCombo.add("Species Four");
+               
                // Combo box and label for curator
                SwtUtils.addLabelToComposite(termDetailComposite, getAction(Tool.SetCurator).getText());
                curatorCombo = SwtUtils.addComboToComposite(termDetailComposite, 150, SWT.READ_ONLY);
@@ -346,9 +360,11 @@ public class SegmentationView extends Composite {
                String[] curatorsList = AppWindow.props.getProperty("CuratorNamesList").split(",");
                for(String curator : curatorsList)
                        curatorCombo.add(curator);
+               
                // text field for collection Id
                SwtUtils.addLabelToComposite(termDetailComposite, "Collection Id");
                collectionId = SwtUtils.addTextFieldToComposite(termDetailComposite, 140);
+               
                // Comments Text Area
                SwtUtils.addLabelToComposite(termDetailComposite, "Comments");
                comment = SwtUtils.addTextAreaToComposite(termDetailComposite, 150);
index 7371d49ffa25394119ceb7cca13961441484775d..757d1758ca84e76f3cdd0e3d8bd7d16342bd3003 100644 (file)
@@ -437,6 +437,10 @@ public class AnnotatedImageControl extends Composite {
                                if(view.imageContains(mouseClickedPoint))
                                {
                                        enableClickedSegment(view.canvasToImage(mouseClickedPoint));
+                                       // For setting the comboLabel value and tooltip on clicking a segment
+                                       String segmentName = ctx.getEnabledMask().segmentName;
+                                       getCanvas().setToolTipText(segmentName);
+                                       SegmentationView.comboLabel.setText(segmentName);
                                }
                                repaint();
                        }