本文整理了Java中ij.gui.Toolbar
类的一些代码示例,展示了Toolbar
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar
类的具体详情如下:
包路径:ij.gui.Toolbar
类名称:Toolbar
[英]The ImageJ toolbar.
[中]ImageJ工具栏。
代码示例来源:origin: net.imagej/ij
static void repaintTool(int tool) {
if (IJ.getInstance()!=null) {
Toolbar tb = getInstance();
Graphics g = tb.getGraphics();
if (IJ.debugMode) IJ.log("Toolbar.repaintTool: "+tool+" "+g);
if (g==null) return;
if (Prefs.antialiasedTools)
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
tb.drawButton(g, tool);
if (g!=null) g.dispose();
}
}
代码示例来源:origin: net.imagej/ij
public static void restoreTools() {
Toolbar tb = Toolbar.getInstance();
if (tb!=null) {
if (tb.getToolId()>=UNUSED)
tb.setTool(RECTANGLE);
tb.installStartupMacros();
}
}
代码示例来源:origin: net.imagej/ij
void setForegroundColor(ImageProcessor ip) {
if (defaultColor!=null)
ip.setColor(defaultColor);
else if (!Double.isNaN(defaultValue))
ip.setValue(defaultValue);
else
ip.setColor(Toolbar.getForegroundColor());
colorSet = true;
}
代码示例来源:origin: stackoverflow.com
setContentView(R.layout.activity_testing_action_bar);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("Toolbar Test 1");
toolbar.inflateMenu(R.menu.menu_testing_action_bar);
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.nav_tint));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
toolbar.setTitle("Toolbar Test 2");
toolbar.getMenu().clear();
toolbar.inflateMenu(R.menu.menu_settings);
toolbar.setNavigationIcon(null);
toolbar.setBackgroundColor(getResources().getColor(R.color.red));
} else {
toolbar.setTitle("Toolbar Test 1");
toolbar.getMenu().clear();
toolbar.inflateMenu(R.menu.menu_testing_action_bar);
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.nav_tint));
toolbar.setBackgroundColor(getResources().getColor(R.color.primary));
代码示例来源:origin: net.imagej/ij
public static void removeMacroTools() {
if (instance!=null) {
if (instance.getToolId()>=CUSTOM1)
instance.setTool(RECTANGLE);
instance.resetTools();
instance.repaint();
}
}
代码示例来源:origin: mpicbg/mpicbg
@Override
public void run( String arg )
{
ij = IJ.getInstance();
imp = IJ.getImage();
window = imp.getWindow();
canvas = imp.getCanvas();
canvas.addKeyListener( this );
window.addKeyListener( this );
canvas.addMouseMotionListener( this );
canvas.addMouseListener( this );
ij.addKeyListener( this );
init();
imp.getProcessor().snapshot();
Toolbar.getInstance().setTool( Toolbar.RECTANGLE );
painter = new PaintThread();
painter.start();
}
代码示例来源:origin: net.imagej/ij
Roi roi = getRoi();
if (roi!=null && !roi.isArea())
roi = null;
if (cut && roi==null && !IJ.isMacro()) {
IJ.error("Edit>Cut", "This command requires an area selection");
return;
if (!batchMode) IJ.showStatus(msg+ "ing...");
ImageProcessor ip = getProcessor();
ImageProcessor ip2;
ip2 = ip.crop();
clipboard = new ImagePlus("Clipboard", ip2);
if (roi!=null)
clipboard.setRoi((Roi)roi.clone());
if (cut) {
ip.snapshot();
ip.setColor(Toolbar.getBackgroundColor());
ip.fill();
if (roi!=null && roi.getType()!=Roi.RECTANGLE) {
getMask();
ip.reset(ip.getMask());
} setColor(Toolbar.getForegroundColor());
Undo.setup(Undo.FILTER, this);
updateAndDraw();
代码示例来源:origin: fiji/Trainable_Segmentation
if (null == WindowManager.getCurrentImage())
trainingImage = IJ.openImage();
if (null == trainingImage) return; // user canceled open dialog
trainingImage = new ImagePlus("Trainable Segmentation",WindowManager.getCurrentImage().getProcessor().duplicate());
if ( Math.max(trainingImage.getWidth(), trainingImage.getHeight()) > 1024 &&
!IJ.showMessageWithCancel("Warning", "At least one dimension of the image \n" +
"is larger than 1024 pixels. \n" +
"Feature stack creation and classifier training \n" +
trainingImage.setProcessor("Trainable Segmentation", trainingImage.getProcessor().duplicate().convertToByte(true));
displayImage.setProcessor("Trainable Segmentation", trainingImage.getProcessor().duplicate());
ij.gui.Toolbar.getInstance().setTool(ij.gui.Toolbar.FREELINE);
代码示例来源:origin: net.imagej/ij
boolean drawOrFill(int mode) {
int[] indexes = getIndexes();
ImagePlus imp = WindowManager.getCurrentImage();
imp.deleteRoi();
ImageProcessor ip = imp.getProcessor();
ip.setColor(Toolbar.getForegroundColor());
ip.snapshot();
Undo.setup(Undo.FILTER, imp);
Filler filler = mode==LABEL?new Filler():null;
int slice = imp.getCurrentSlice();
for (int i=0; i<indexes.length; i++) {
Roi roi = (Roi)rois.get(indexes[i]);
int type = roi.getType();
if (roi==null) continue;
if (mode==FILL&&(type==Roi.POLYLINE||type==Roi.FREELINE||type==Roi.ANGLE))
imp.setSlice(slice2);
ip = imp.getProcessor();
ip.setColor(Toolbar.getForegroundColor());
if (slice2!=slice) Undo.reset();
case DRAW: roi.drawPixels(ip); break;
case FILL: ip.fill(roi); break;
case LABEL:
roi.drawPixels(ip);
filler.drawLabel(imp, ip, i+1, roi.getBounds());
break;
代码示例来源:origin: mpicbg/mpicbg_
imp = IJ.getImage();
ip = imp.getProcessor();
ipOrig = ip.duplicate();
mesh = new SpringMesh( numX, imp.getWidth(), imp.getHeight(), 0.01f, Float.MAX_VALUE, 0.9f );
Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Add_and_drag_handles." ) );
ill.start();
imp.getCanvas().addMouseListener( this );
imp.getCanvas().addMouseMotionListener( this );
imp.getCanvas().addKeyListener( this );
代码示例来源:origin: mpicbg/mpicbg
@Override
public void run( final String arg )
{
/* cleanup */
m.clear();
imp = IJ.getImage();
target = imp.getProcessor();
source = target.duplicate();
source.setInterpolationMethod( ImageProcessor.BILINEAR );
init();
createMapping();
painter = new MappingThread(
imp,
source,
target,
pleaseRepaint,
mapping,
interpolate );
painter.start();
Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Add_and_drag_handles." ) );
imp.getCanvas().addMouseListener( this );
imp.getCanvas().addMouseMotionListener( this );
imp.getCanvas().addKeyListener( this );
imp.getWindow().addKeyListener( this );
IJ.getInstance().addKeyListener( this );
}
代码示例来源:origin: mpicbg/mpicbg
tuples.clear();
imp = IJ.getImage();
if ( imp.isComposite() && ( ( CompositeImage )imp ).getMode() == CompositeImage.COMPOSITE )
final int z = imp.getSlice();
final int t = imp.getFrame();
for ( int c = 1; c <= imp.getNChannels(); ++c )
final int i = imp.getStackIndex( c, z, t );
final ImageProcessor target = imp.getStack().getProcessor( i );
final ImageProcessor source = target.duplicate();
source.setInterpolationMethod( ImageProcessor.BILINEAR );
tuples.add( new Tuple( source, target ) );
final ImageProcessor target = imp.getProcessor();
final ImageProcessor source = target.duplicate();
source.setInterpolationMethod( ImageProcessor.BILINEAR );
tuples.add( new Tuple( source, target ) );
Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Drag_the_handles." ) );
imp.getCanvas().addMouseListener( this );
imp.getCanvas().addMouseMotionListener( this );
imp.getCanvas().addKeyListener( this );
代码示例来源:origin: net.imagej/ij
public ImageProcessor expandImage(ImageProcessor ipOld, int wNew, int hNew, int xOff, int yOff) {
ImageProcessor ipNew = ipOld.createProcessor(wNew, hNew);
if (zeroFill)
ipNew.setValue(0.0);
else
ipNew.setColor(Toolbar.getBackgroundColor());
ipNew.fill();
ipNew.insert(ipOld, xOff, yOff);
return ipNew;
}
代码示例来源:origin: sc.fiji/Fiji_Plugins
public void run(ImageProcessor ip) {
int in = Toolbar.getForegroundColor().getRGB();
int out = Toolbar.getBackgroundColor().getRGB();
int w = ip.getWidth();
int[] pixels = (int[])ip.getPixels();
Roi roi = image.getRoi();
if (roi == null) {
Gradient g = new Gradient(w, ip.getHeight(), in, out);
while (g.fwd())
pixels[g.x + g.y * w] = g.color;
}
else {
Rectangle rect = roi.getBounds();
Gradient g = new Gradient(rect.width, rect.height,
in, out);
while (g.fwd()) {
int x = rect.x + g.x;
int y = rect.y + g.y;
if (roi.contains(x, y))
pixels[x + y * w] = g.color;
}
}
}
代码示例来源:origin: net.imagej/ij
static void setColor(int red, int green, int blue, boolean foreground) {
if (red<0) red=0; if (green<0) green=0; if (blue<0) blue=0;
if (red>255) red=255; if (green>255) green=255; if (blue>255) blue=255;
Color c = new Color(red, green, blue);
if (foreground) {
Toolbar.setForegroundColor(c);
ImagePlus img = WindowManager.getCurrentImage();
if (img!=null)
img.getProcessor().setColor(c);
} else
Toolbar.setBackgroundColor(c);
}
代码示例来源:origin: net.imagej/ij
void showDialog() {
Color fc =Toolbar.getForegroundColor();
String fname = getColorName(fc, "black");
Color bc =Toolbar.getBackgroundColor();
String bname = getColorName(bc, "white");
Color sc =Roi.getColor();
String sname = getColorName(sc, "yellow");
GenericDialog gd = new GenericDialog("Colors");
if (fc2!=fc) Toolbar.setForegroundColor(fc);
if (bc2!=bc) Toolbar.setBackgroundColor(bc);
if (sc2!=sc) {
Roi.setColor(sc);
ImagePlus imp = WindowManager.getCurrentImage();
if (imp!=null && imp.getRoi()!=null) imp.draw();
bc2 = getColor(bname, Color.white);
sc2 = getColor(sname, Color.yellow);
if (fc2!=fc) Toolbar.setForegroundColor(fc2);
if (bc2!=bc) Toolbar.setBackgroundColor(bc2);
if (sc2!=sc) {
Roi.setColor(sc2);
ImagePlus imp = WindowManager.getCurrentImage();
if (imp!=null) imp.draw();
Toolbar.getInstance().repaint();
代码示例来源:origin: net.imagej/ij
public void label(ImageProcessor ip) {
if (!IJ.isMacro()) {
IJ.error("Label", "To label a selection, enable \"Add to overlay\" in Analyze>\nSet Measurements and press 'm' (Analyze>Measure).");
return;
}
if (Analyzer.getCounter()==0) {
IJ.error("Label", "Measurement counter is zero");
return;
}
if (Analyzer.firstParticle<Analyzer.lastParticle)
drawParticleLabels(ip);
else {
ip.setColor(Toolbar.getForegroundColor());
ImageCanvas ic = imp.getCanvas();
if (ic!=null) {
double mag = ic.getMagnification();
if (mag<1.0) {
int lineWidth = 1;
lineWidth = (int)(lineWidth/mag);
ip.setLineWidth(lineWidth);
}
}
roi.drawPixels(ip);
ip.setLineWidth(1);
drawLabel(ip);
}
}
代码示例来源:origin: net.imagej/ij
public void eventOccurred(int eventID) {
switch (eventID) {
case IJEventListener.FOREGROUND_COLOR_CHANGED:
String c = Integer.toHexString(Toolbar.getForegroundColor().getRGB());
c = "#"+c.substring(2);
IJ.log("Changed foreground color to "+c);
break;
case IJEventListener.BACKGROUND_COLOR_CHANGED:
c = Integer.toHexString(Toolbar.getBackgroundColor().getRGB());
c = "#"+c.substring(2);
IJ.log("Changed background color to "+c);
break;
case IJEventListener.TOOL_CHANGED:
String name = IJ.getToolName();
IJ.log("Switched to the "+name+(name.endsWith("Tool")?"":" tool"));
break;
case IJEventListener.COLOR_PICKER_CLOSED:
IJ.log("Color picker closed");
break;
case IJEventListener.LOG_WINDOW_CLOSED:
IJ.removeEventListener(this);
Executer.removeCommandListener(this);
ImagePlus.removeImageListener(this);
Roi.removeRoiListener(this);
IJ.showStatus("Log window closed; EventListener stopped");
break;
}
}
代码示例来源:origin: sc.fiji/Fiji_Plugins
public void run(ImageProcessor ip) {
Roi roi = image.getRoi();
if (roi == null || roi.getType() != roi.LINE) {
IJ.error("Need a linear selection");
return;
}
Line line = (Line)roi;
if (line.getLength() == 0) {
IJ.error("Line too short");
return;
}
int from = Toolbar.getBackgroundColor().getRGB();
int to = Toolbar.getForegroundColor().getRGB();
makeLinearGradient(ip, from, to, line);
image.updateAndDraw();
}
代码示例来源:origin: net.imagej/ij
public void itemStateChanged(ItemEvent e) {
Choice choice = (Choice)e.getSource();
String item = choice.getSelectedItem();
Color color = getColor(item, Color.black);
if (choice==fchoice)
Toolbar.setForegroundColor(color);
else if (choice==bchoice)
Toolbar.setBackgroundColor(color);
else if (choice==schoice) {
Roi.setColor(color);
ImagePlus imp = WindowManager.getCurrentImage();
if (imp!=null && imp.getRoi()!=null) imp.draw();
Toolbar.getInstance().repaint();
}
}
内容来源于网络,如有侵权,请联系作者删除!