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;
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);
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;
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() {
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;
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);
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);
}
}
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";
this.mapName = "imagemap";
this.areas = new LinkedList<MapArea>();
this.preloads = new LinkedList<String>();
+ this.metadata = new LinkedList<String>();
}
public String getPageTitle() {
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);
}
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);
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');
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();
<map name="${map-name}" id="${map-name}">
${contents}
</map>
+ <table border = '1'>
+${image_metadata}
+ </table>
</body>
</html>
\ No newline at end of file
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.*;
// 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;
SetLabel,
AssignButton,
SetCurator,
- SegmenterOptions,
- CollectionId;
+ SegmenterOptions;
private ToolAction action;
};
}
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);
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);
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();
}