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));
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;
try {
// clear the decks
window.getView().resetView();
-
+
if (SegmentationContext.isContextFile(file)) {
// Load context
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);
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());
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;
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();
}
// Effects
private final String[] ROLLOVER_EFFECTS = {
- "Outline Object", "Darken Background", "Highlight Object"
+ "Darken Background", "Outline Object", "Highlight Object"
};
// Shapes
};
// Default title
- private static final String TITLE = "Export HTML Image Map";
+ private static final String TITLE = "Save Annotation";
public ExportDialog(Shell shell) {
super(shell);
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
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);
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);
break;
}
- area.setAlt(objectDescription);
- area.setHref(objectLink);
+ //area.setAlt(objectDescription);
+ //area.setHref(objectLink);
if (effect != null) {
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);
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
{
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");
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");
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);
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);
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.*;
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);
}
* 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) {
case AssignButton:
assignLabel();
break;
- case SegmenterOptions:
- showSegmenterOptions();
- break;
+ //case SegmenterOptions:
+ //showSegmenterOptions();
+ //break;
}
updateToolStates();
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());
// 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);
import java.io.*;
import java.util.ArrayList;
+import java.util.logging.Logger;
import java.util.zip.*;
import javax.xml.bind.DatatypeConverter;
*/
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
*/
}
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);