ImageJ base code to get access to all the classes and their methods to test new Plugins. https://imagejdocu.tudor.lu/howto/plugins/the_imagej_eclipse_howto
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

40 lines
1.2 KiB

// Moves the selection left and down a specified distance in pixels.
xy = split(getArgument());
if (lengthOf(xy)!=2) {
dx = 10;
dy = 10;
} else {
dx = parseFloat(xy[0]);
if (isNaN(dx)) dx = 10;
dy = parseFloat(xy[1]);
if (isNaN(dy)) dy = 10;
}
getPixelSize(unit, pixelWidth, pixelHeight);
if (unit=="pixel") unit = "pixels";
dxc = dx*pixelWidth;
dyc = dy*pixelHeight;
Dialog.create("Move");
Dialog.addNumber("Delta_X ("+unit+"):", dxc);
Dialog.addNumber("Delta_Y ("+unit+"):", dyc);
Dialog.show();
dx = Dialog.getNumber()/pixelWidth;
dy = Dialog.getNumber()/pixelHeight;
moveSelection(dx, dy);
return toString(dx)+" "+toString(dy);
function moveSelection(dx, dy) {
getBoundingRect(x, y, width, height);
if (selectionType==0)
makeRectangle(x+dx, y+dy, width, height);
else if (selectionType==1)
makeOval(x+dx, y+dy, width, height);
else {
getSelectionCoordinates(xCoordinates, yCoordinates);
for (i=0; i<xCoordinates.length; i++) {
xCoordinates[i] += dx;
yCoordinates[i] += dy;
}
makeSelection(selectionType, xCoordinates, yCoordinates);
}
}