Need help or advice ? Come to the Icy club ! - Every Wenesday morning from 9h30 to 12h30 - Francois Jacob Building - Main hall - Pasteur
Register

moveAllSelectedROI

by oeway / Wei Ouyang

Move all selected ROIs together

version 1 (last version):

download to use and modify in Icy. How do I use scripts ? A Problem ? ask the community.
Changelog for this version: initial version
//Move all selected roi together
//Usage
//Select all ROIs you want to move together
//run this script, and you will found a red point ROI on the left-top corner of current sequence
//drag the red point


//Author Will Ouyang


importClass(Packages.icy.type.collection.array.Array1DUtil)
importClass(Packages.icy.roi.ROIListener)
importClass(Packages.icy.roi.ROI2DPoint)
importClass(Packages.java.awt.geom.Point2D)
importClass(Packages.java.awt.Color)
importClass(Packages.java.util.HashMap)
seq = getSequence()
if (seq == null) throw "Please open a sequence first"
 
rois = seq.getROI2Ds()
if (rois.isEmpty()) throw "No ROI on the sequence"
roi = rois.get(0)

anchor = new ROI2DPoint(0,0)
anchor.setColor(Color.red)
seq.addROI(anchor, true)
lastPos = anchor.getPosition2D()
var pl = new HashMap()
size = rois.size()
for(i = 0;i< size ;i++ )
{
	roi = rois.get(i)
	if(roi.isSelected())
	if(roi != anchor)
	{
		pl.put(roi,roi.getPosition2D())
	}
}
anchor.setSelected(true)
anchor.addListener(new ROIListener(){
	roiChanged: function(ev) {
		anchor = ev.getSource()
		curPos =  anchor.getPosition2D()
		for(i = 0;i< size ;i++ )
		{
			roi = rois.get(i)
			if(roi == anchor)
				continue
			try
			{
				p = pl.get(roi)
				roi.setPosition(new Point2D.Double(p.getX()+curPos.getX(),p.getY()+curPos.getY()))
			}
			catch(e)
			{
			}
		}
    	}
})




Documentation

Move all selected roi together

Usage

  • Select all ROIs you want to move together
  • run this script, and you will found a red point ROI on the left-top corner of current sequence
  • drag the red point


Icy script publication Id : D3B8M4