From 4da942c3d9a5b4a51fcbecc39f425c6c0946ac0b Mon Sep 17 00:00:00 2001 From: lingutln Date: Thu, 31 May 2012 20:45:20 +0000 Subject: [PATCH] Saving annotated images functionality and UI changes. Done by Nikhil. svn path=/; revision=341 --- .../ist/actions/ExportImageMapAction.java | 8 +++--- .../ie/dcu/apps/ist/actions/OpenAction.java | 1 + .../ie/dcu/apps/ist/actions/SaveAction.java | 3 +-- .../ie/dcu/apps/ist/dialogs/ExportDialog.java | 26 +++++++++++-------- .../apps/ist/export/imagemap/Exporter.java | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java b/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java index f72882f..ce71c83 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java @@ -31,7 +31,6 @@ public class ExportImageMapAction extends AppAction{ @Override public void run() { - SegmentationContext ctx = window.getContext(); List masks = ctx.getSegmentationMasks(); if (ctx.hasSegmentationMasks()) { @@ -39,9 +38,7 @@ public class ExportImageMapAction extends AppAction{ // Get options from user ExportDialog dialog = new ExportDialog(window.getShell()); ExportDialog.Result result = dialog.open(); - if (result != null) { - // Grab image and mask BufferedImage image = ImageConverter.convert(ctx.getImageData()); @@ -51,8 +48,9 @@ public class ExportImageMapAction extends AppAction{ exporter.setHtmlFile(result.html); // Taking html file name and making the same as filename of imagemap - int dotIndex = result.image.indexOf('.'); - String zipFile = result.image.substring(0, dotIndex); + int dotIndex = result.zipFile.indexOf('.'); + String zipFile = result.zipFile.substring(0, dotIndex); + System.out.println("Zip file name is : "+zipFile); exporter.setZipFile(zipFile+IMGMAP_EXTENSION); exporter.setImageFile(result.image); diff --git a/Annotation/src/ie/dcu/apps/ist/actions/OpenAction.java b/Annotation/src/ie/dcu/apps/ist/actions/OpenAction.java index ed1790c..991a319 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/OpenAction.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/OpenAction.java @@ -1,6 +1,7 @@ package ie.dcu.apps.ist.actions; import ie.dcu.apps.ist.*; +import ie.dcu.apps.ist.views.SegmentationView; import ie.dcu.segment.SegmentationContext; import java.io.*; diff --git a/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java b/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java index e1fe18a..549a62c 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java @@ -55,8 +55,7 @@ public class SaveAction extends AppAction { exporter.setHtmlFile("imagemap.html"); // Taking html file name and making the same as filename of imagemap - int dotIndex = result.html.indexOf('.'); - String zipFile = result.html.substring(0, dotIndex); + String zipFile = result.zipFile; exporter.setZipFile(zipFile+IMGMAP_EXTENSION); exporter.setImageFile(result.image); diff --git a/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java b/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java index 8feeb30..8bbf394 100644 --- a/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java +++ b/Annotation/src/ie/dcu/apps/ist/dialogs/ExportDialog.java @@ -28,6 +28,7 @@ public class ExportDialog extends Dialog { public class Result { public final File folder; public final String html; + public final String zipFile; public final String image; public final String link; public final String description; @@ -39,7 +40,8 @@ public class ExportDialog extends Dialog { folder = new File(folderText.getText().trim()); //html = htmlText.getText().trim(); html = "imagemap.html"; - image = imageText.getText().trim(); + zipFile = zipFileName.getText().trim(); + image = "image"; link = linkText.getText().trim(); description = descriptionText.getText(); shape = getShape(); @@ -61,6 +63,7 @@ public class ExportDialog extends Dialog { private Text folderText; private Button browseButton; private Text htmlText; + private Text zipFileName; private Text imageText; private Text linkText; private Button effectCheck; @@ -134,12 +137,13 @@ public class ExportDialog extends Dialog { label(widgets, "Export folder:"); folderText = text(widgets, ""); browseButton = button(widgets, "Browse..."); - //label(widgets, "HTML file name:"); - //htmlText = text(widgets, "imagemap.html"); + label(widgets, "Target zip file name:"); + zipFileName = text(widgets, "annotated"); + label(widgets, ".zip"); //spacer(widgets); - label(widgets, "File name:"); + /*label(widgets, "File name:"); imageText = text(widgets, "image"); - spacer(widgets); + spacer(widgets);*/ hline(widgets); label(widgets, "Export shape:"); shapeRadios = radios(widgets, SHAPES); @@ -218,19 +222,19 @@ public class ExportDialog extends Dialog { return false; } - /*String htmlFile = htmlText.getText().trim(); - if (htmlFile.equals("")) { + String zipFile = zipFileName.getText().trim(); + if (zipFile.equals("")) { validationError("The HTML file name cannot be empty"); - htmlText.setFocus(); + zipFileName.setFocus(); return false; - }*/ + } - String imageFile = imageText.getText().trim(); + /*String imageFile = imageText.getText().trim(); if (imageFile.equals("")) { validationError("The image file name cannot be empty"); imageText.setFocus(); return false; - } + }*/ return true; } 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 557a0a9..1ed82c1 100644 --- a/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java +++ b/Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java @@ -32,7 +32,7 @@ public class Exporter { private RolloverEffect effect; private String htmlFile = "imagemap.html"; - private String zipFile = "imagemap.zip"; + private String zipFile = ""; private String imageFile = "image.png"; private String imageName = "image"; private String objectDescription = ""; -- 2.34.1