From 202ccf140a09b4c60ae4d04f38eb9ec94d5bba35 Mon Sep 17 00:00:00 2001 From: lingutln Date: Tue, 5 Jun 2012 20:53:56 +0000 Subject: [PATCH] Coordinates saving functionality and some UI alignments. Done by Nikhil. svn path=/; revision=342 --- .../src/ie/dcu/apps/ist/PainterRegistry.java | 11 ++++--- .../dcu/apps/ist/views/SegmentationView.java | 2 +- .../ie/dcu/segment/SegmentationContext.java | 29 +++++++++---------- .../src/ie/dcu/segment/SegmentationMask.java | 3 ++ .../dcu/segment/painters/CombinedPainter.java | 6 ++-- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java b/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java index 7b437b0..ed5d6fc 100644 --- a/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java +++ b/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java @@ -16,10 +16,13 @@ public class PainterRegistry { private void init() { add(new CombinedPainter()); add(new OriginalPainter()); - add(new MarkupPainter()); - add(new MaskPainter()); - add(new ForegroundOnlyPainter()); - add(new OutlineOverlayPainter()); + /* + * Commented different views of segmentation. Currently original and combined painter are enabled + */ + //add(new MarkupPainter()); + //add(new MaskPainter()); + //add(new ForegroundOnlyPainter()); + //add(new OutlineOverlayPainter()); } diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index 9e0d223..7bd5766 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -210,7 +210,7 @@ public class SegmentationView extends Composite { private void createToolMainToolbar() { ToolBarManager m = new ToolBarManager(mainToolbar); m.add(getAction(Tool.Foreground)); - m.add(getAction(Tool.Background)); + //m.add(getAction(Tool.Background)); m.add(getAction(Tool.OperatingMode)); m.add(getAction(Tool.FormSegment)); m.add(new Separator()); diff --git a/Annotation/src/ie/dcu/segment/SegmentationContext.java b/Annotation/src/ie/dcu/segment/SegmentationContext.java index 4d4e21e..89ea600 100644 --- a/Annotation/src/ie/dcu/segment/SegmentationContext.java +++ b/Annotation/src/ie/dcu/segment/SegmentationContext.java @@ -215,10 +215,13 @@ public class SegmentationContext { public static void disableAllSegments() { - for(SegmentationMask currentSegmentMask : segmentationMaskObjects) + if (!(segmentationMaskObjects.isEmpty())) { - currentSegmentMask.enabled = false; - } + for(SegmentationMask currentSegmentMask : segmentationMaskObjects) + { + currentSegmentMask.enabled = false; + } + } } /** @@ -464,6 +467,7 @@ public class SegmentationContext { String speciesTermName = "", collectionId = "", comment = "", curatorName = "",speciesTermId = ""; int width = 0,height = 0; int noOfSegments = 0; + int noOfChildern = 0; String [][] tempStorage = null; SegmentationContext ctx = null; @@ -472,7 +476,7 @@ public class SegmentationContext { while ((entry = in.getNextEntry()) != null) { String name = entry.getName(); - if (name.equals("image.png")) { + if (name.equals("image")) { imageData = SwtUtils.loadImageData(in); ctx = new SegmentationContext(imageData, file); width = imageData.width; @@ -480,13 +484,7 @@ public class SegmentationContext { } else if (name.startsWith("markup")) { - String[] temp; - temp = name.split("-"); - int layerNumber = Integer.parseInt(temp[1].substring(0, temp[1].indexOf("."))); SegmentationMask mask = new SegmentationMask(width,height); - mask.layerNumber = layerNumber; - - InputStream input = zip.getInputStream(entry); segmentationMaskObjects.add(setMaskPixelValues(input,mask,width,height)); } @@ -522,7 +520,8 @@ public class SegmentationContext { // getting collection ids NodeList nlist = docEle.getElementsByTagName("segment"); noOfSegments = nlist.getLength(); - tempStorage = new String[nlist.getLength()][4]; + noOfChildern = nlist.item(0).getChildNodes().getLength(); + tempStorage = new String[noOfSegments][noOfChildern]; if(nlist != null && nlist.getLength() > 0) { for(int i = 0 ; i < nlist.getLength();i++) @@ -540,7 +539,7 @@ public class SegmentationContext { } } - SegmentationView.speciesCombo.setText(speciesTermName); + SegmentationView.speciesCombo.setText(speciesTermName); SegmentationView.speciesCombo.setData(speciesTermName,speciesTermId); SegmentationView.curatorCombo.setText(curatorName); SegmentationView.collectionId.setText(collectionId); @@ -551,17 +550,17 @@ public class SegmentationContext { System.out.println("XML exception"+e.toString()); } } - } } - catch(Exception ex) + catch(Exception e) { + System.out.println("Exception is "+e.toString()); } finally { for(int i = 0 ; i < noOfSegments;i++) { - for(int x = 0 ; x < 4;x++) + for(int x = 0 ; x < noOfChildern;x++) { if (x == 1) { diff --git a/Annotation/src/ie/dcu/segment/SegmentationMask.java b/Annotation/src/ie/dcu/segment/SegmentationMask.java index c9a0783..56cb6f3 100644 --- a/Annotation/src/ie/dcu/segment/SegmentationMask.java +++ b/Annotation/src/ie/dcu/segment/SegmentationMask.java @@ -67,6 +67,9 @@ public class SegmentationMask extends ByteMatrix{ //The layering number of the segmentation mask. public int layerNumber; + + //The color of the mask + public String maskColor; @Deprecated //The name(label) associated with each segment. - replaced with Term object diff --git a/Annotation/src/ie/dcu/segment/painters/CombinedPainter.java b/Annotation/src/ie/dcu/segment/painters/CombinedPainter.java index b9e2842..9e2064a 100644 --- a/Annotation/src/ie/dcu/segment/painters/CombinedPainter.java +++ b/Annotation/src/ie/dcu/segment/painters/CombinedPainter.java @@ -106,6 +106,7 @@ public class CombinedPainter implements SegmentationPainter { if (isNewMaskDataRequired(mask)) { mask.maskImageData = createMaskData(mask.getBounds()); } + byte main_index = 9; // Blit in pixels for (int y = 0, i = 0; y < mask.height; y++) { int rowOffset = y * mask.maskImageData.bytesPerLine; @@ -131,12 +132,13 @@ public class CombinedPainter implements SegmentationPainter { // the buffer), so we can't directly copy in at the same index as the // mask. mask.maskImageData.data[x + rowOffset] = index; - //System.out.println(mask.maskImageData.data[x + rowOffset]); + // However, the alpha data is always aligned correctly mask.maskImageData.alphaData[i] = alpha; // Next location in the mask i++; + main_index = index; } } // Create new mask @@ -262,7 +264,7 @@ public class CombinedPainter implements SegmentationPainter { } public void dispose() { - /*// Dispose mask +/* // Dispose mask if (maskImage != null) { if (!maskImage.isDisposed()) { maskImage.dispose(); -- 2.34.1