本文整理汇总了Java中ij.gui.ImageCanvas类的典型用法代码示例。如果您正苦于以下问题:Java ImageCanvas类的具体用法?Java ImageCanvas怎么用?Java ImageCanvas使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageCanvas类属于ij.gui包,在下文中一共展示了ImageCanvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createListeners
import ij.gui.ImageCanvas; //导入依赖的package包/类
private void createListeners() {
//IJ.log("createListeners");
if(srcImp == null) {
return;
}
ImageCanvas canvas = srcImp.getCanvas();
if(canvas == null) {
return;
}
canvas.addMouseListener(this);
canvas.addMouseMotionListener(this);
canvas.addKeyListener(this);
ImagePlus.addImageListener(this);
Font font = live.getFont();
live.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
live.setForeground(Color.red);
}
示例2: killListeners
import ij.gui.ImageCanvas; //导入依赖的package包/类
/**
* Kill listeners.
*/
public void killListeners ()
{
if(imp != null)
{
final ImageWindow iw = imp.getWindow();
final ImageCanvas ic = iw.getCanvas();
ic.removeKeyListener(pa);
ic.removeMouseListener(pa);
ic.removeMouseMotionListener(pa);
ic.addMouseMotionListener(ic);
ic.addMouseListener(ic);
ic.addKeyListener(IJ.getInstance());
}
}
示例3: ImageCanvas3D
import ij.gui.ImageCanvas; //导入依赖的package包/类
public ImageCanvas3D(final int width, final int height, final UIAdapter uia) {
super(SimpleUniverse.getPreferredConfiguration());
this.ui = uia;
setPreferredSize(new Dimension(width, height));
final ByteProcessor ip = new ByteProcessor(width, height);
roiImagePlus = new RoiImagePlus("RoiImage", ip);
roiImageCanvas = new ImageCanvas(roiImagePlus) {
/* prevent ROI to enlarge/move on mouse click */
@Override
public void mousePressed(final MouseEvent e) {
if (!ui.isMagnifierTool() && !ui.isPointTool()) super.mousePressed(e);
}
};
roiImageCanvas.removeKeyListener(ij.IJ.getInstance());
roiImageCanvas.removeMouseListener(roiImageCanvas);
roiImageCanvas.removeMouseMotionListener(roiImageCanvas);
roiImageCanvas.disablePopupMenu(true);
background =
new Background(new Color3f(UniverseSettings.defaultBackground));
background.setCapability(Background.ALLOW_COLOR_WRITE);
addListeners();
}
示例4: getLowerZoomLevel2
import ij.gui.ImageCanvas; //导入依赖的package包/类
/** Enable zooming out up to the point where the display becomes 10 pixels in width or height. */
protected double getLowerZoomLevel2(final double currentMag) {
// if it is 1/72 or lower, then:
if (Math.abs(currentMag - 1/72.0) < 0.00000001 || currentMag < 1/72.0) { // lowest zoomLevel in ImageCanvas is 1/72.0
// find nearest power of two under currentMag
// start at level 7, which is 1/128
int level = 7;
double scale = currentMag;
while (scale * srcRect.width > MIN_DIMENSION && scale * srcRect.height > MIN_DIMENSION) {
scale = 1 / Math.pow(2, level);
// if not equal and actually smaller, break:
if (Math.abs(scale - currentMag) != 0.00000001 && scale < currentMag) break;
level++;
}
return scale;
} else {
return ImageCanvas.getLowerZoomLevel(currentMag);
}
}
示例5: getHigherZoomLevel2
import ij.gui.ImageCanvas; //导入依赖的package包/类
protected double getHigherZoomLevel2(final double currentMag) {
// if it is not 1/72 and its lower, then:
if (Math.abs(currentMag - 1/72.0) > 0.00000001 && currentMag < 1/72.0) { // lowest zoomLevel in ImageCanvas is 1/72.0
// find nearest power of two above currentMag
// start at level 14, which is 0.00006103515625 (0.006 %)
int level = 14; // this value may be increased in the future
double scale = currentMag;
while (level >= 0) {
scale = 1 / Math.pow(2, level);
if (scale > currentMag) break;
level--;
}
return scale;
} else {
return ImageCanvas.getHigherZoomLevel(currentMag);
}
}
示例6: removeListeners
import ij.gui.ImageCanvas; //导入依赖的package包/类
private void removeListeners() {
//IJ.log("removeListeners");
if(srcImp == null) {
return;
}
ImageCanvas canvas = srcImp.getCanvas();
canvas.removeMouseListener(this);
canvas.removeMouseMotionListener(this);
canvas.removeKeyListener(this);
ImagePlus.removeImageListener(this);
Font font = live.getFont();
live.setFont(new Font(font.getName(), Font.PLAIN, font.getSize()));
live.setForeground(Color.black);
}
示例7: showStatus
import ij.gui.ImageCanvas; //导入依赖的package包/类
/**Displays a message in the ImageJ status bar.*/
public static void showStatus(String s) {
if (ij!=null) ij.showStatus(s);
ImagePlus imp = WindowManager.getCurrentImage();
ImageCanvas ic = imp!=null?imp.getCanvas():null;
if (ic!=null)
ic.setShowCursorStatus(s.length()==0?true:false);
}
示例8: permuteImages
import ij.gui.ImageCanvas; //导入依赖的package包/类
private void permuteImages (
) {
// Swap image canvas
final ImageCanvas swapIc = sourceIc;
sourceIc = targetIc;
targetIc = swapIc;
// Swap ImagePlus
final ImagePlus swapImp = sourceImp;
sourceImp = targetImp;
targetImp = swapImp;
// Swap Mask
final unwarpJMask swapMsk = sourceMsk;
sourceMsk=targetMsk;
targetMsk=swapMsk;
// Swap Point Handlers
final unwarpJPointHandler swapPh = sourcePh;
sourcePh = targetPh;
targetPh = swapPh;
setSecondaryPointHandlers();
// Inform the Toolbar about the change
tb.setSource(sourceImp, sourcePh);
tb.setTarget(targetImp, targetPh);
// Restart the computation with each image
source =
new unwarpJImageModel(sourceImp.getProcessor(), false);
source.setPyramidDepth(imagePyramidDepth+min_scale_image);
source.getThread().start();
target =
new unwarpJImageModel(targetImp.getProcessor(), true);
target.setPyramidDepth(imagePyramidDepth+min_scale_image);
target.getThread().start();
}
示例9: killListeners
import ij.gui.ImageCanvas; //导入依赖的package包/类
public void killListeners (
) {
final ImageWindow iw = imp.getWindow();
final ImageCanvas ic = iw.getCanvas();
ic.removeKeyListener(pa);
ic.removeMouseListener(pa);
ic.removeMouseMotionListener(pa);
ic.addMouseMotionListener(ic);
ic.addMouseListener(ic);
ic.addKeyListener(IJ.getInstance());
}
示例10: unwarpJPointHandler
import ij.gui.ImageCanvas; //导入依赖的package包/类
public unwarpJPointHandler (
final ImagePlus imp,
final unwarpJPointToolbar tb,
final unwarpJMask mask,
final unwarpJDialog dialog
) {
super(0, 0, imp.getWidth(), imp.getHeight(), imp);
this.imp = imp;
this.tb = tb;
this.dialog=dialog;
pa = new unwarpJPointAction(imp, this, tb, dialog);
final ImageWindow iw = imp.getWindow();
final ImageCanvas ic = iw.getCanvas();
iw.requestFocus();
iw.removeKeyListener(IJ.getInstance());
iw.addKeyListener(pa);
ic.removeMouseMotionListener(ic);
ic.removeMouseListener(ic);
ic.removeKeyListener(IJ.getInstance());
ic.addKeyListener(pa);
ic.addMouseListener(pa);
ic.addMouseMotionListener(pa);
setSpectrum();
started = true;
this.mask=mask;
clearMask();
}
示例11: PointHandler
import ij.gui.ImageCanvas; //导入依赖的package包/类
/**
* Constructor with graphical capabilities, create an instance of PointHandler.
*
* @param imp pointer to the image
* @param tb pointer to the toolbar
* @param mask pointer to the mask
* @param dialog pointer to the bUnwarpJ dialog
*/
public PointHandler (
final ImagePlus imp,
final PointToolbar tb,
final Mask mask,
final MainDialog dialog)
{
super(0, 0, imp.getWidth(), imp.getHeight(), imp);
this.imp = imp;
this.tb = tb;
this.dialog = dialog;
this.pa = new PointAction(imp, this, tb, dialog);
final ImageWindow iw = imp.getWindow();
final ImageCanvas ic = iw.getCanvas();
//iw.requestFocus();
iw.removeKeyListener(IJ.getInstance());
iw.addKeyListener(pa);
ic.removeMouseMotionListener(ic);
ic.removeMouseListener(ic);
ic.removeKeyListener(IJ.getInstance());
ic.addKeyListener(pa);
ic.addMouseListener(pa);
ic.addMouseMotionListener(pa);
started = true;
this.mask = mask;
//clearMask(); // This line was commented to allow loading masks from the second slice of a stack.
}
示例12: mouseClicked
import ij.gui.ImageCanvas; //导入依赖的package包/类
public void mouseClicked(MouseEvent e)
{
if (e == null)
return;
ImageCanvas ic = imp.getCanvas();
int cx = ic.offScreenX(e.getX());
int cy = ic.offScreenY(e.getY());
final int radius = (int) Math.ceil(diameter * 500 / nmPerPixel);
final int radiusz = (int) Math.ceil(diameter * 500 / nmPerSlice);
if (sphere == null)
{
int inc = 2 * radius + 1;
int incz = 2 * radiusz + 1;
sphere = createEllipsoid(inc, inc, incz);
}
int xloc = cx - radius;
int yloc = cy - radius;
int offset = imp.getCurrentSlice() - radiusz;
ImageStack stack = imp.getImageStack();
for (int slice = 1; slice <= sphere.getSize(); slice++)
{
int i = slice + offset;
if (i < 1 || i > stack.getSize())
continue;
ImageProcessor ip = stack.getProcessor(i);
ImageProcessor ip2 = sphere.getProcessor(slice);
ip.copyBits(ip2, xloc, yloc, Blitter.MAX);
}
imp.updateAndDraw();
}
示例13: setImage
import ij.gui.ImageCanvas; //导入依赖的package包/类
public void setImage(ImagePlus srImage) {
System.out.print("Adding image to the Jframe...");
cleanFrame();
ImageCanvas ic = new ImageCanvas(srImage);
imageFrame.add(ic);
configure(srImage.getWidth(), srImage.getHeight());
System.out.println("[OK]");
}
示例14: mouseReleased
import ij.gui.ImageCanvas; //导入依赖的package包/类
public void mouseReleased(MouseEvent e)
{
if (dragging)
{
dragging = false;
Roi roi = activeImp.getRoi();
if (roi != null && roi.getType() == Roi.POINT && roi.getState() == Roi.NORMAL)
{
// Find the image x,y coords
ImageCanvas ic = activeImp.getCanvas();
int ox = ic.offScreenX(e.getX());
int oy = ic.offScreenY(e.getY());
//logMessage("Dropped coords " + ox + "," + oy);
int index = findRoiPointIndex((PointRoi) roi, ox, oy);
if (index >= 0)
{
if (assignDragged)
{
mapRoiPoint((PointRoi) roi, index);
}
else
{
addRoiPoint((PointRoi) roi, index);
}
}
}
}
}
示例15: FakeImageWindow
import ij.gui.ImageCanvas; //导入依赖的package包/类
public FakeImageWindow(ImagePlus imp, ImageCanvas ic, Display display) {
super(imp.getTitle());
this.display = display;
ij = IJ.getInstance();
this.imp = imp;
this.ic = ic;
imp.setWindow(this);
WindowManager.addWindow(this);
}