From: lingutln Date: Fri, 10 Feb 2012 02:46:16 +0000 (+0000) Subject: svn path=/; revision=297 X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=7979d3462da19fb522a7924f597892c6982e559b;p=old-jaiswallab-svn%2F.git svn path=/; revision=297 --- diff --git a/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java b/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java index ef8b1f6..ed9fd59 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java @@ -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); 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 0e5a1db..fdd1628 100644 --- a/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java +++ b/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java @@ -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 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 preloads = new ArrayList(); 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); } } 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 a92ba04..6f7f7ad 100644 --- a/Annotation/src/ie/dcu/apps/ist/export/imagemap/ImageMap.java +++ b/Annotation/src/ie/dcu/apps/ist/export/imagemap/ImageMap.java @@ -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 areas; private final List preloads; - + private final List metadata; + public ImageMap() { // set defaults : this.pageTitle = "Image Map"; @@ -38,6 +43,7 @@ public class ImageMap { this.mapName = "imagemap"; this.areas = new LinkedList(); this.preloads = new LinkedList(); + this.metadata = new LinkedList(); } 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 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(" Species Name ").append(getSpeciesName()).append(""); + metadata.append(" Curator Name ").append(getCuratorName()).append(""); + metadata.append(" Collection Id ").append(getCollectionId()).append(""); + metadata.append(" Comments ").append(getComments()).append(""); + 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(); diff --git a/Annotation/src/ie/dcu/apps/ist/export/imagemap/template.html b/Annotation/src/ie/dcu/apps/ist/export/imagemap/template.html index 159d2a1..1b10f02 100644 --- a/Annotation/src/ie/dcu/apps/ist/export/imagemap/template.html +++ b/Annotation/src/ie/dcu/apps/ist/export/imagemap/template.html @@ -34,5 +34,8 @@ ${preloads} ${contents} + +${image_metadata} +
\ No newline at end of file diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index b928b26..031225b 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -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); diff --git a/Annotation/src/ie/dcu/apps/ist/widgets/AnnotatedImageControl.java b/Annotation/src/ie/dcu/apps/ist/widgets/AnnotatedImageControl.java index 7371d49..757d175 100644 --- a/Annotation/src/ie/dcu/apps/ist/widgets/AnnotatedImageControl.java +++ b/Annotation/src/ie/dcu/apps/ist/widgets/AnnotatedImageControl.java @@ -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(); }