怎样使用java读取java image 缩放

protected &boolean
canSetSourceRenderSize
&&&&&&&&&&如果此 ImageReadParam 允许设置源呈现维数,则为 true。
protected &BufferedImage
destination
&&&&&&&&&&当前目标 BufferedImage;如果没有设置目标图像,则为 null。
protected &int[]
destinationBands
&&&&&&&&&&要使用的目标 band 集合(int 数组的形式)。
protected &int
minProgressivePass
&&&&&&&&&&从源中读取的逐步传递的最小索引。
protected &int
numProgressivePasses
&&&&&&&&&&从源中读取的逐步传递的最大数量。
protected &Dimension
sourceRenderSize
&&&&&&&&&&如果 canSetSourceRenderSize 为 true,则为源的所需呈现宽度和高度;或者为 null。
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset
ImageReadParam()
&&&&&&&&&&构造一个 ImageReadParam。
canSetSourceRenderSize()
&&&&&&&&&&如果此 reader 允许通过使用 setSourceRenderSize 方法以任意大小将源图像呈现为解码过程的一部分,则返回 true。
&BufferedImage
getDestination()
&&&&&&&&&&返回当前由 setDestination 方法设置的 BufferedImage,如果没有设置,则返回 null。
getDestinationBands()
&&&&&&&&&&返回 band 索引的集合,数据将置于该集合中。
getSourceMaxProgressivePass()
&&&&&&&&&&如果 getSourceNumProgressivePasses 等于 Integer.MAX_VALUE,则返回 Integer.MAX_VALUE。
getSourceMinProgressivePass()
&&&&&&&&&&返回将被解码的第一个逐步传递的索引。
getSourceNumProgressivePasses()
&&&&&&&&&&返回将被解码的逐步传递的数量。
&Dimension
getSourceRenderSize()
&&&&&&&&&&返回解码期间将呈现的源图像的宽度和高度,如果已经通过 setSourceRenderSize 方法设置了的话。
setDestination(BufferedImage&destination)
&&&&&&&&&&提供一个 BufferedImage,将其用作解码像素数据的目标。
setDestinationBands(int[]&destinationBands)
&&&&&&&&&&设置将在其中放置数据的目标 band 的索引。
setDestinationType(ImageTypeSpecifier&destinationType)
&&&&&&&&&&使用 ImageTypeSpecifier 设置目标图像的所需图像类型。
setSourceProgressivePasses(int&minPass,
int&numPasses)
&&&&&&&&&&设置将被解码的逐步传递的范围。
setSourceRenderSize(Dimension&size)
&&&&&&&&&&如果能够以任意大小呈现图像,则将源宽度和高度设置为所提供的值。
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setSourceBands, setSourceRegion, setSourceSubsampling
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canSetSourceRenderSize
protected boolean canSetSourceRenderSize
如果此 ImageReadParam 允许设置源呈现维数,则为 true。默认情况下,该值为 false。子类必须手工设置此值。
不支持设置源呈现大小的 ImageReader 应该将该值设置为 false。
sourceRenderSize
protected Dimension sourceRenderSize
如果 canSetSourceRenderSize 为 true,则为源的所需呈现宽度和高度;或者为 null。
不支持设置源呈现大小的 ImageReader 可以忽略此值。
destination
protected BufferedImage destination
当前目标 BufferedImage;如果没有设置目标图像,则为 null。默认情况下,该值为 null。
destinationBands
protected int[] destinationBands
要使用的目标 band 集合(int 数组的形式)。默认情况下,该值为 null,指示应该按顺序写入的所有目标 band。
minProgressivePass
protected int minProgressivePass
从源中读取的逐步传递的最小索引。默认情况下,该值被设置为 0,指示应该解码从第一个可用传递开始的传递。
子类应该确保此值为非负。
numProgressivePasses
protected int numProgressivePasses
从源中读取的逐步传递的最大数量。默认情况下,该值被设置为 Integer.MAX_VALUE,指示应该解码直至最后一个可用传递(包括)的传递。
子类应该确保此值为正数。此外,如果该值不是 Integer.MAX_VALUE,则 minProgressivePass + numProgressivePasses - 1 不应该超过 Integer.MAX_VALUE。
ImageReadParam
public ImageReadParam()
构造一个 ImageReadParam。
setDestinationType
public void setDestinationType(ImageTypeSpecifier&destinationType)
从类 IIOParam 复制的描述
使用 ImageTypeSpecifier 设置目标图像的所需图像类型。
在读取时,如果已经使用此方法设置目标区域的布局,则每次调用 ImageReader 的 read 方法都将返回一个新的 BufferedImage,它使用由所提供的类型说明符指定的格式。此方法的一个副作用是,任何由 ImageReadParam.setDestination(BufferedImage) 设置的目标 BufferedImage 将不再被设置为目标。换句话说,在调用 setDestination((BufferedImage)null) 时可以考虑此方法。
在写入时,或许会使用目标类型确定图像的颜色类型。SampleModel 信息将被忽略,其可以为 null。例如,一个 4 band 的图像可以表示 CMYK 或 RGBA 数据。如果设置了目标类型,则其 ColorModel 将重写该图像自身的所有 ColorModel。这在使用 setSourceBands 时极其重要,因为该图像的 ColorModel 将引用整个图像,而不是被写入的 band 的子集。
覆盖:类 IIOParam 中的 setDestinationType
参数:destinationType - 用来确定目标布局和颜色类型的 ImageTypeSpecifier。另请参见:IIOParam.getDestinationType()
setDestination
public void setDestination(BufferedImage&destination)
提供一个 BufferedImage,将其用作解码像素数据的目标。当前设置的图像将由 read、readAll 和 readRaster 方法写入,对该图像的引用将由这些方法返回。
来自上述那些方法的像素数据将从 getDestinationOffset 指定的偏移量开始写入。
如果 destination 为 null,则新创建的 BufferedImage 将由这些方法返回。
在读取时,检查该图像来验证其 ColorModel 和 SampleModel 是否对应于从 ImageReader 的 getImageTypes 方法返回的 ImageTypeSpecifier 之一。如果不对应,则 reader 将抛出 IIOException。
参数:destination - 要写入数据的 BufferedImage,或者为 null。另请参见:getDestination()
getDestination
public BufferedImage getDestination()
返回当前由 setDestination 方法设置的 BufferedImage,如果没有设置,则返回 null。
返回:要写入数据的 BufferedImage。另请参见:setDestination(java.awt.image.BufferedImage)
setDestinationBands
public void setDestinationBands(int[]&destinationBands)
设置将在其中放置数据的目标 band 的索引。索引不能重复。
null 值指示所有目标 band 都将被使用。
如果没有指定目标图像,选择目标 band 子集不会影响某一读取操作的输出图像中的 band 数;所创建的目标图像仍然拥有相同的 band 数,就像从未调用此方法一样。如果需要目标图像中不同数量的 band,则必须使用 ImageReadParam.setDestination 方法提供一幅图像。
在读取或写入时,如果指定了大于最大目标 band 索引的值,或者要使用的源 band 的数量和目标 band 的数量不同,则 reader 或 writer 将抛出 IllegalArgumentException。可以使用 ImageReader.checkReadParamBandSettings 方法自动进行此测试。
参数:destinationBands - 将要使用的整数 band 索引组成的数组。
IllegalArgumentException - 如果 destinationBands 包含一个负数或重复的值。另请参见:getDestinationBands(),
IIOParam.getSourceBands(),
ImageReader.checkReadParamBandSettings(javax.imageio.ImageReadParam, int, int)
getDestinationBands
public int[] getDestinationBands()
返回 band 索引的集合,数据将置于该集合中。如果没有设置任何值,则返回 null,指示将使用所有目标 band。
返回:要使用的目标 band 的索引;或者 null。另请参见:setDestinationBands(int[])
canSetSourceRenderSize
public boolean canSetSourceRenderSize()
如果此 reader 允许通过使用 setSourceRenderSize 方法以任意大小将源图像呈现为解码过程的一部分,则返回 true。如果此方法返回 false,那么调用 setSourceRenderSize 将抛出 UnsupportedOperationException。
返回:如果支持设置源呈现大小,则返回 true。另请参见:setSourceRenderSize(java.awt.Dimension)
setSourceRenderSize
public void setSourceRenderSize(Dimension&size)
throws UnsupportedOperationException
如果能够以任意大小呈现图像,则将源宽度和高度设置为所提供的值。注意,从 ImageReader 上的 getWidth 和 getHeight 方法返回的值不受此方法的影响;它们将继续返回图像的默认大小。类似地,如果图像被平铺,那么平铺宽度和高度也是根据默认大小给出的。
通常应该选定宽度和高度,使宽度与高度的比率接近近似的图像高宽比(从 ImageReader.getAspectRatio 中返回)。
如果此插件不允许设置呈现大小,则抛出 UnsupportedOperationException。
要移除呈现大小设置值,为 size 传入一个 null 值。
参数:size - 指示所需宽度和高度 Dimension。
IllegalArgumentException - 如果宽度或高度为负数或 0。
UnsupportedOperationException - 如果此插件不支持重新设置图像大小。另请参见:getSourceRenderSize(),
ImageReader.getWidth(int),
ImageReader.getHeight(int),
ImageReader.getAspectRatio(int)
getSourceRenderSize
public Dimension getSourceRenderSize()
返回解码期间将呈现的源图像的宽度和高度,如果已经通过 setSourceRenderSize 方法设置了的话。null 值指示没有进行设置。
返回:源图像的呈现宽度和高度(Dimension 的形式)。另请参见:setSourceRenderSize(java.awt.Dimension)
setSourceProgressivePasses
public void setSourceProgressivePasses(int&minPass,
int&numPasses)
设置将被解码的逐步传递的范围。此范围之外的传递将被忽略。
逐步传递是整个图像的重新编码,通常以逐步变高的有效分辨率进行,但要求有更高的传输带宽。最常使用的逐步编码是以 JPEG 格式进行的,其中连续的传递包括高频图像内容的更详细的表示形式。
将被解码的传递的实际数量是在解码期间根据流中可用的实际传递数来确定的。因此,如果 minPass + numPasses - 1 大于最后一个可用传递的索引,则解码将在该传递结束。
Integer.MAX_VALUE 的值为 numPasses 指示应该读取从 minPass 开始的所有传递。否则,最后一个传递的索引(即 minPass + numPasses - 1)一定不能超过 Integer.MAX_VALUE。
如果没有 unsetSourceProgressivePasses 方法,通过调用 setSourceProgressivePasses(0, Integer.MAX_VALUE) 可以达到相同的效果。
参数:minPass - 要解码的第一个传递的索引。numPasses - 要解码的传递的最大数量。
IllegalArgumentException - 如果 minPass 为负数,numPasses 为负数或 0,或者 numPasses 小于 Integer.MAX_VALUE,但 minPass + numPasses - 1 大于 INTEGER.MAX_VALUE。另请参见:getSourceMinProgressivePass(),
getSourceMaxProgressivePass()
getSourceMinProgressivePass
public int getSourceMinProgressivePass()
返回将被解码的第一个逐步传递的索引。如果没有设置任何值,则返回 0(此为修正值)。
返回:将被解码的第一个传递的索引。另请参见:setSourceProgressivePasses(int, int),
getSourceNumProgressivePasses()
getSourceMaxProgressivePass
public int getSourceMaxProgressivePass()
如果 getSourceNumProgressivePasses 等于 Integer.MAX_VALUE,则返回 Integer.MAX_VALUE。否则返回 getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1。
返回:将被读取的最后一个传递的索引;或者 Integer.MAX_VALUE。
getSourceNumProgressivePasses
public int getSourceNumProgressivePasses()返回将被解码的逐步传递的数量。如果没有设置任何值,则返回 Integer.MAX_VALUE(此为修正值)。返回:将被解码的传递的数量。另请参见:setSourceProgressivePasses(int, int), getSourceMinProgressivePass()
上一篇:下一篇:
ImageReadParam
责任申明:本站内容均整理自互联网,若有侵权,请联系我们。使用本站提供的任务技术内容造成不良后果,本站不负任何责任。
欢迎投稿,电子邮件:(#号换成@)&& QQ群1: &&当前位置: &
& 查看源码
imagej.java
imagej.java:源码内容
import&java.awt.*;
import&java.util.*;
import&java.awt.event.*;
import&java.io.*;
import&ij.gui.*;
import&ij.process.*;
import&ij.io.*;
import&ij.plugin.*;
import&ij.plugin.filter.*;
import&ij.text.*;
This&frame&is&the&main&ImageJ&class.
ImageJ&is&open-source.&You&are&free&to&do&anything&you&want
with&this&source&as&long&as&I&get&credit&for&my&work&and&you
offer&your&changes&to&me&so&I&can&possibly&add&them&to&the
&official&&version.
@author&Wayne&Rasband&&wayne@codon.nih.gov&
public&class&ImageJ&extends&Frame&implements&ActionListener,&
MouseListener,&KeyListener,&WindowListener,&ItemListener&{
public&static&final&String&VERSION&=&&1.20s&;
private&Toolbar&
private&Panel&statusB
private&ProgressBar&progressB
private&Label&statusL
private&TextPanel&textP
private&boolean&firstTime&=&
private&java.applet.Applet&&//&null&if&not&running&as&an&applet
private&Vector&classes&=&new&Vector();
private&static&PluginClassLoader&classL
private&boolean&notVerified&=&
/**&Creates&a&new&ImageJ&frame.&Set&applet&to&null&if&running&as&an&application.&*/
public&ImageJ(java.applet.Applet&applet)&{
super(&ImageJ&);
this.applet&=&
String&status&=&Prefs.load(this,&applet);
Menus&m&=&new&Menus(this,&applet);
m.addMenuBar();
m.installPopupMenu(this);
notVerified&=&
//&Tool&bar
Panel&panel&=&new&Panel();
panel.setLayout(new&GridLayout(2,&1));
toolbar&=&new&Toolbar();
toolbar.addKeyListener(this);
panel.add(toolbar);
//&Status&bar
statusBar&=&new&Panel();
statusBar.setLayout(new&BorderLayout());
statusBar.setForeground(Color.black);
statusBar.setBackground(Color.lightGray);
statusLine&=&new&Label();
statusLine.addKeyListener(this);
statusLine.addMouseListener(this);
statusBar.add(&Center&,&statusLine);
progressBar&=&new&ProgressBar(90,&16);
progressBar.addKeyListener(this);
progressBar.addMouseListener(this);
statusBar.add(&East&,&progressBar);
panel.add(statusBar);
add(&North&,&panel);
//&Text&panel
textPanel&=&new&TextPanel();
textPanel.setTitle(&results.txt&);
textPanel.setBackground(Color.white);
textPanel.setFont(new&Font(&Monospaced&,&Font.PLAIN,&12));
//Dimension&tbSize&=&toolbar.getPreferredSize();
//textPanel.setSize(tbSize.width+10,&250);
textPanel.addKeyListener(this);
add(&Center&,&textPanel);
IJ.init(this,&applet,&textPanel);
IJ.write(&ImageJ&&+VERSION);
if&(!status.equals(&&))
IJ.write(&&&&+status+&&&&);
IJ.showStatus(&&&&&+&Menus.nPlugins&+&&&plugin&commands&installed&);
addKeyListener(this);
addWindowListener(this);
setResizable(true);
Point&loc&=&getPreferredLocation();
Dimension&tbSize&=&toolbar.getPreferredSize();
setBounds(loc.x,&loc.y,&tbSize.width+10,&230);
//setLocation(loc.x,&loc.y);
setCursor(Cursor.getDefaultCursor());&//&work-around&for&JDK&1.1.8&bug
setVisible(true);
requestFocus();
public&Point&getPreferredLocation()&{
int&screenWidth&=&Toolkit.getDefaultToolkit().getScreenSize().
Dimension&tbsize&=&toolbar.getPreferredSize();
int&windowWidth&=&tbsize.width+10;
if&(screenWidth&&&832)
percent&=&0.8;
percent&=&0.9;
int&windowX&=&(int)(percent&*&(screenWidth&-&windowWidth));
if&(windowX&&&10)
windowX&=&10;
int&windowY&=&32;
return&new&Point(windowX,&windowY);
void&showStatus(String&s)&{
&&&&&&&&statusLine.setText(s);
public&ProgressBar&getProgressBar()&{
&&&&&&&&return&progressB
&&&&/**&Starts&executing&a&menu&command&in&a&separate&thread.&*/
&&&&void&doCommand(String&name)&{
new&Executer(name,&WindowManager.getCurrentImage());
void&wrongType(int&capabilities)&{
String&s&=&&This&command&requires&an&image&of&type:n&n&;
if&((capabilities&PlugInFilter.DOES_8G)!=0)&s&+=&&&&&&&8-bit&grayscalen&;
if&((capabilities&PlugInFilter.DOES_8C)!=0)&s&+=&&&&&&&8-bit&colorn&;
if&((capabilities&PlugInFilter.DOES_16)!=0)&s&+=&&&&&&&16-bit&grayscalen&;
if&((capabilities&PlugInFilter.DOES_32)!=0)&s&+=&&&&&&&32-bit&(float)&grayscalen&;
if&((capabilities&PlugInFilter.DOES_RGB)!=0)&s&+=&&&&&&RGB&colorn&;
IJ.error(s);
public&void&runFilterPlugIn(Object&theFilter,&String&cmd,&String&arg)&{
ImagePlus&imp&=&WindowManager.getCurrentImage();
int&capabilities&=&((PlugInFilter)theFilter).setup(arg,&imp);
if&((capabilities&PlugInFilter.DONE)!=0)
if&((capabilities&PlugInFilter.NO_IMAGE_REQUIRED)!=0)
{((PlugInFilter)theFilter).run(null);&}
if&(imp==null)
{IJ.noImage();&}
if&((capabilities&PlugInFilter.ROI_REQUIRED)!=0&&&&imp.getRoi()==null)
{IJ.error(&Selection&required&);&}
if&((capabilities&PlugInFilter.STACK_REQUIRED)!=0&&&&imp.getStackSize()==1)
{IJ.error(&Stack&required&);&}
int&type&=&imp.getType();
switch&(type)&{
case&ImagePlus.GRAY8:
if&((capabilities&PlugInFilter.DOES_8G)==0)
{wrongType(capabilities);&}
case&ImagePlus.COLOR_256:
if&((capabilities&PlugInFilter.DOES_8C)==0)
{wrongType(capabilities);&}
case&ImagePlus.GRAY16:
if&((capabilities&PlugInFilter.DOES_16)==0)
{wrongType(capabilities);&}
case&ImagePlus.GRAY32:
if&((capabilities&PlugInFilter.DOES_32)==0)
{wrongType(capabilities);&}
case&ImagePlus.COLOR_RGB:
if&((capabilities&PlugInFilter.DOES_RGB)==0)
{wrongType(capabilities);&}
int&slices&=&imp.getStackSize();
boolean&doesStacks&=&(capabilities&PlugInFilter.DOES_STACKS)!=0;
if&(!imp.lock())
&//&exit&if&image&is&in&use
imp.startTiming();
IJ.showStatus(cmd&+&&...&);
ImageProcessor&
ImageStack&stack&=&
if&(slices&1)
stack&=&imp.getStack();
if&(slices==1&||&!doesStacks&||&(stack!=null&&&&(stack.isRGB()&||&stack.isHSB())))&{
ip&=&imp.getProcessor();
if&((capabilities&PlugInFilter.NO_UNDO)!=0)
Undo.reset();
Undo.setup(Undo.FILTER,&imp);
ip.snapshot();
((PlugInFilter)theFilter).run(ip);
if&((capabilities&PlugInFilter.SUPPORTS_MASKING)!=0)
ip.reset(imp.getMask());&&//restore&image&outside&irregular&roi
Undo.reset();&//&can't&undo&stack&operations
int&n&=&stack.getSize();
int&currentSlice&=&imp.getCurrentSlice();
for&(int&i=1;&i&=n;&i++)&{
ip&=&stack.getProcessor(i);
((PlugInFilter)theFilter).run(ip);
IJ.showProgress((double)i/n);
System.gc();
Thread.yield();
int&current&=&imp.getCurrentSlice();
imp.setProcessor(null,stack.getProcessor(current));
IJ.showProgress(1.0);
IJ.showTime(imp,&imp.getStartTime(),&cmd&+&&:&&);
if&((capabilities&PlugInFilter.NO_CHANGES)==0)&{
imp.changes&=&
imp.updateAndDraw();
ImageWindow&win&=&imp.getWindow();
if&(win!=null)
win.running&=&
imp.unlock();
public&Object&runUserPlugIn(String&commandName,&String&className,&String&arg,&boolean&createNewLoader)&{
if&(applet!=null)
if&(notVerified)&{
//&check&for&duplicate&classes&in&the&plugins&folder
IJ.runPlugIn(&ij.plugin.Verifier&,&&&);
notVerified&=&
PluginClassLoader&
if&(createNewLoader)
loader&=&new&PluginClassLoader(Menus.getPlugInsPath());
if&(classLoader==null)
classLoader&=&new&PluginClassLoader(Menus.getPlugInsPath());
loader&=&classL
Object&thePlugIn&=&
thePlugIn&=&(loader.loadClass(className)).newInstance();&
if&(thePlugIn&instanceof&PlugIn)
((PlugIn)thePlugIn).run(arg);
else&if&(thePlugIn&instanceof&PlugInFilter)
runFilterPlugIn(thePlugIn,&commandName,&arg);
catch&(ClassNotFoundException&e)&{IJ.write(&PlugIn&not&found:&&+className);}
catch&(InstantiationException&e)&{IJ.write(&Unable&to&load&plugin&(ins)&);}
catch&(IllegalAccessException&e)&{IJ.write(&Unable&to&load&plugin&(acc)&);}
return&thePlugIn;
/**&Return&the&current&list&of&modifier&keys.&*/
public&static&String&modifiers(int&flags)&{&//??&needs&to&be&moved
String&s&=&&&[&&;
if&(flags&==&0)&return&&&;
if&((flags&&&Event.SHIFT_MASK)&!=&0)&s&+=&&Shift&&;
if&((flags&&&Event.CTRL_MASK)&!=&0)&s&+=&&Control&&;
if&((flags&&&Event.META_MASK)&!=&0)&s&+=&&Meta&&;
if&((flags&&&Event.ALT_MASK)&!=&0)&s&+=&&Alt&&;
s&+=&&]&&;
/**&Handle&menu&events.&*/
public&void&actionPerformed(ActionEvent&e)&{
if&((e.getSource()&instanceof&MenuItem))&{
MenuItem&item&=&(MenuItem)e.getSource();
String&cmd&=&e.getActionCommand();
if&(cmd!=null)
doCommand(cmd);
if&(IJ.debugMode)&IJ.write(&actionPerformed:&&+cmd);
/**&Handles&CheckboxMenuItem&state&changes.&*/
public&void&itemStateChanged(ItemEvent&e)&{
MenuItem&item&=&(MenuItem)e.getSource();
MenuComponent&parent&=&(MenuComponent)item.getParent();
String&cmd&=&e.getItem().toString();
if&((Menu)parent==Menus.window)
WindowManager.activateWindow(cmd,&item);
doCommand(cmd);
public&void&mousePressed(MouseEvent&e)&{
Undo.reset();
IJ.showStatus(IJ.freeMemory());
if&(IJ.debugMode)
IJ.write(&Windows:&&+WindowManager.getWindowCount());
public&void&mouseReleased(MouseEvent&e)&{}
public&void&mouseExited(MouseEvent&e)&{}
public&void&mouseClicked(MouseEvent&e)&{}
public&void&mouseEntered(MouseEvent&e)&{}
& public&void&keyPressed(KeyEvent&e)&{
int&keyCode&=&e.getKeyCode();
IJ.setKeyDown(keyCode);
if&(keyCode==e.VK_CONTROL&||&keyCode==e.VK_SHIFT)
char&keyChar&=&e.getKeyChar();
int&flags&=&e.getModifiers();
if&(IJ.debugMode)&IJ.write(&keyCode=&&+&keyCode&+&&&(&&+&KeyEvent.getKeyText(keyCode)
+&&)&keyChar=&&&+&keyChar&+&&&&(&&+&(int)keyChar&+&&)&&
+&KeyEvent.getKeyModifiersText(flags));
boolean&shift&=&(flags&&&e.SHIFT_MASK)&!=&0;
boolean&control&=&(flags&&&e.CTRL_MASK)&!=&0;
String&c&=&&&;
ImagePlus&imp&=&WindowManager.getCurrentImage();
boolean&isStack&=&(imp!=null)&&&&(imp.getStackSize()&1);
if&(imp!=null&&&&!control&&&&((keyChar&=32&&&&keyChar&=127)&||&keyChar=='b'&||&keyChar=='n'))&{
Roi&roi&=&imp.getRoi();
if&(roi&instanceof&TextRoi)&{
((TextRoi)roi).addChar(keyChar);
Hashtable&shortcuts&=&Menus.getShortcuts();
if&(shift)
c&=&(String)shortcuts.get(new&Integer(keyCode+200));
c&=&(String)shortcuts.get(new&Integer(keyCode));
if&(c==null)
switch(keyCode)&{
case&KeyEvent.VK_TAB:&WindowManager.putBehind();&
case&KeyEvent.VK_BACK_SPACE:&c=&Clear&;&&//&delete
case&KeyEvent.VK_EQUALS:&case&0xbb:&c=&Start&Animation&[=]&;&
case&KeyEvent.VK_SLASH:&case&0xbf:&c=&Reslice&[/]...&;&
case&KeyEvent.VK_COMMA:&case&0xbc:&c=&Previous&Slice&[&]&;&
case&KeyEvent.VK_PERIOD:&case&0xbe:&c=&Next&Slice&[&]&;&
case&KeyEvent.VK_LEFT:&case&KeyEvent.VK_RIGHT:&case&KeyEvent.VK_UP:&case&KeyEvent.VK_DOWN:&//&arrow&keys
Roi&roi&=&
if&(imp!=null)&roi&=&imp.getRoi();
if&(roi==null)&
if&((flags&&&KeyEvent.ALT_MASK)&!=&0)
roi.nudgeCorner(keyCode);
roi.nudge(keyCode);
case&KeyEvent.VK_F1:&case&KeyEvent.VK_F2:&case&KeyEvent.VK_F3:&case&KeyEvent.VK_F4:&//&function&keys
case&KeyEvent.VK_F5:&case&KeyEvent.VK_F6:&case&KeyEvent.VK_F7:&case&KeyEvent.VK_F8:
case&KeyEvent.VK_F9:&case&KeyEvent.VK_F10:&case&KeyEvent.VK_F11:&case&KeyEvent.VK_F12:
Toolbar.getInstance().selectTool(keyCode);
if&(imp!=null)&{
ImageWindow&win&=&imp.getWindow();
if&(win!=null)&{
ImageCanvas&ic&=&win.getCanvas();
Point&loc&=&ic.getCursorLoc();
if&(loc.x&0&&&&loc.y&0)
ic.setCursor(loc.x,&loc.y);
case&KeyEvent.VK_ESCAPE:
if&(imp!=null)
imp.getWindow().running&=&
case&KeyEvent.VK_ENTER:&this.toFront();&
if&(c!=null&&&&!c.equals(&&))
doCommand(c);
public&void&keyReleased(KeyEvent&e)&{
IJ.setKeyUp(e.getKeyCode());
public&void&keyTyped(KeyEvent&e)&{}
public&void&windowClosing(WindowEvent&e)&{
doCommand(&Quit&);
public&void&windowActivated(WindowEvent&e)&{
if&(IJ.isMacintosh())
this.setMenuBar(Menus.getMenuBar());
public&void&windowClosed(WindowEvent&e)&{}
public&void&windowDeactivated(WindowEvent&e)&{}
public&void&windowDeiconified(WindowEvent&e)&{}
public&void&windowIconified(WindowEvent&e)&{}
public&void&windowOpened(WindowEvent&e)&{}
/**Copies&text&from&the&ImageJ&window&to&the&system&clipboard.&Returns&0&if&the&system&clipboard
is&not&available&or&no&text&is&selected.&Clears&the&selection&if&&cut&&is&true.*/
public&int&copyText(boolean&cut)&{
boolean&isActiveWindow&=&getFocusOwner()!=
if&(!isActiveWindow)
int&count&=&&textPanel.copySelection();
if&(cut&&&&count&0)&textPanel.clearSelection();
textPanel.resetSelection();
/**&Clears&text&from&the&ImageJ&window.&Returns
false&if&the&ImageJ&window&is&not&active.&*/
public&boolean&clearText()&{
boolean&isActiveWindow&=&getFocusOwner()!=
if&(!isActiveWindow)
textPanel.clearSelection();
void&showAboutBox()&{
MessageDialog&d&=&new&MessageDialog(this,&&About&ImageJ...&,
&&&&&&&&&&ImageJ&&&+&VERSION&+&&n&&+
&Wayne&Rasband&(wayne@codon.nih.gov)n&&+
&National&Institutes&of&Health,&USAn&&+
&.nih.gov/ij/n&&+
&ImageJ&is&in&the&public&domain.&
/**&Adds&the&specified&class&to&a&Vector&to&keep&it&from&being
garbage&collected,&causing&static&fields&to&be&reset.&*/
public&void&register(Class&c)&{
if&(!classes.contains(c))
classes.addElement(c);
void&quit()&{
if&(applet==null)
Prefs.savePreferences();
if&(!WindowManager.closeAllWindows())
setVisible(false);
dispose();
if&(applet==null)
System.exit(0);
&&&&public&static&void&main(String&args[])&{
new&ImageJ(null);
}&//class&ImageJ
友情链接:
CopyRight & 2008- All Rights reserved. 苏ICP备
号 京公网安备:95

我要回帖

更多关于 java image类 的文章

 

随机推荐