ij.gui.Toolbar.getBackgroundColor()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中ij.gui.Toolbar.getBackgroundColor()方法的一些代码示例,展示了Toolbar.getBackgroundColor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.getBackgroundColor()方法的具体详情如下:
包路径:ij.gui.Toolbar
类名称:Toolbar
方法名:getBackgroundColor

Toolbar.getBackgroundColor介绍

暂无

代码示例

代码示例来源:origin: sc.fiji/Fiji_Plugins

public void run(ImageProcessor ip) {
  double background;
  if (mode == Mode.AUTOAUTOCROP || mode == Mode.AUTOSELECTION)
    background = guessBackground(ip);
  else if (ip instanceof ColorProcessor) {
    Color color = Toolbar.getBackgroundColor();
    background = (color.getRed() << 16) |
      (color.getGreen() << 8) | color.getBlue();
  }
  else {
    background =
      ip.getBestIndex(Toolbar.getBackgroundColor());
    if (!(ip instanceof ByteProcessor))
      background = ip.getMin() + background *
        (ip.getMax() - ip.getMin()) / 255.0;
  }
  Rectangle rect = getBoundingBox(ip, ip.getRoi(), background);
  switch (mode) {
    case SELECTION:
    case AUTOSELECTION:
      image.setRoi(rect);
      break;
    case AUTOCROP: case AUTOAUTOCROP:
      crop(image, rect);
      break;
  }
}

代码示例来源: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: 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: net.imagej/ij

void editColor() {
  Color c  = background?Toolbar.getBackgroundColor():Toolbar.getForegroundColor();
  ColorChooser cc = new ColorChooser((background?"Background":"Foreground")+" Color", c, false);
  c = cc.getColor();
  if (background)
    Toolbar.setBackgroundColor(c);
  else
    Toolbar.setForegroundColor(c);
}

代码示例来源:origin: imagej/ImageJA

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: imagej/ImageJA

void editColor() {
  Color c  = background?Toolbar.getBackgroundColor():Toolbar.getForegroundColor();
  ColorChooser cc = new ColorChooser((background?"Background":"Foreground")+" Color", c, false);
  c = cc.getColor();
  if (background)
    Toolbar.setBackgroundColor(c);
  else
    Toolbar.setForegroundColor(c);
}

代码示例来源:origin: imagej/ImageJA

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) {
  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 drawLabel(ImagePlus imp, ImageProcessor ip, int count, Rectangle r) {
  Color foreground = Toolbar.getForegroundColor();
  Color background = Toolbar.getBackgroundColor();
  if (foreground.equals(background)) {
    foreground = Color.black;
    background = Color.white;
  }
  int size = 9;
  ImageCanvas ic = imp.getCanvas();
  if (ic!=null) {
    double mag = ic.getMagnification();
    if (mag<1.0)
      size /= mag;
  }
  if (size==9 && r.width>50 && r.height>50)
    size = 12;
  ip.setFont(new Font("SansSerif", Font.PLAIN, size));
  String label = "" + count;
  int w =  ip.getStringWidth(label);
  int x = r.x + r.width/2 - w/2;
  int y = r.y + r.height/2 + Math.max(size/2,6);
  FontMetrics metrics = ip.getFontMetrics();
  int h =  metrics.getHeight();
  ip.setColor(background);
  ip.setRoi(x-1, y-h+2, w+1, h-3);
  ip.fill();
  ip.resetRoi();
  ip.setColor(foreground);
  ip.drawString(label, x, y);
}

代码示例来源: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

public void refreshBackground(boolean backgroundInFront) {
  //Boundary for Background Selection
  setColor(0x444444);
  drawRect((w*2)-12, 276, (w*2)+4, (h*2)+4);
  setColor(0x999999);
  drawRect((w*2)-11, 277, (w*2)+2, (h*2)+2);
  setRoi((w*2)-10, 278, w*2, h*2);//Paints the Background Color
  Color bg = Toolbar.getBackgroundColor();
  setColor(bg);
  fill();
  if (backgroundInFront)
    drawLabel("B", bg, w*4-18, 278+h*2);
}

代码示例来源:origin: imagej/ImageJA

public void refreshBackground(boolean backgroundInFront) {
  //Boundary for Background Selection
  setColor(0x444444);
  drawRect((w*2)-12, 276, (w*2)+4, (h*2)+4);
  setColor(0x999999);
  drawRect((w*2)-11, 277, (w*2)+2, (h*2)+2);
  setRoi((w*2)-10, 278, w*2, h*2);//Paints the Background Color
  Color bg = Toolbar.getBackgroundColor();
  setColor(bg);
  fill();
  if (backgroundInFront)
    drawLabel("B", bg, w*4-18, 278+h*2);
}

代码示例来源:origin: net.imagej/ij

public void clear(ImageProcessor ip) {
   ip.setColor(Toolbar.getBackgroundColor());
  if (isLineSelection()) {
    if (isStraightLine() && roi.getStrokeWidth()>1)
      ip.fillPolygon(roi.getPolygon());
    else
      roi.drawPixels();
  } else if (roi!=null && roi instanceof TextRoi)
    ((TextRoi)roi).clear(ip);
  else
     ip.fill(); // fill with background color
  ip.setColor(Toolbar.getForegroundColor());
}

代码示例来源:origin: imagej/ImageJA

public void clear(ImageProcessor ip) {
   ip.setColor(Toolbar.getBackgroundColor());
  if (isLineSelection()) {
    if (isStraightLine() && roi.getStrokeWidth()>1)
      ip.fillPolygon(roi.getPolygon());
    else
      roi.drawPixels();
  } else if (roi!=null && roi instanceof TextRoi)
    ((TextRoi)roi).clear(ip);
  else
     ip.fill(); // fill with background color
  ip.setColor(Toolbar.getForegroundColor());
}

代码示例来源:origin: net.imagej/ij

ImageProcessor ip = stack1.getProcessor(1);
ImageProcessor ip1, ip2, ip3;
Color background = Toolbar.getBackgroundColor();
 for (int i=1; i<=d3; i++) {
   IJ.showProgress((double)i/d3);

代码示例来源:origin: net.imagej/ij

public ImageStack expandStack(ImageStack stackOld, int wNew, int hNew, int xOff, int yOff) {
  int nFrames = stackOld.getSize();
  ImageProcessor ipOld = stackOld.getProcessor(1);
  java.awt.Color colorBack = Toolbar.getBackgroundColor();
  
  ImageStack stackNew = new ImageStack(wNew, hNew, stackOld.getColorModel());
  ImageProcessor ipNew;
  
  for (int i=1; i<=nFrames; i++) {
    IJ.showProgress((double)i/nFrames);
    ipNew = ipOld.createProcessor(wNew, hNew);
    if (zeroFill)
      ipNew.setValue(0.0);
    else 
      ipNew.setColor(colorBack);
    ipNew.fill();
    ipNew.insert(stackOld.getProcessor(i), xOff, yOff);
    stackNew.addSlice(stackOld.getSliceLabel(i), ipNew);
  }
  return stackNew;
}

代码示例来源:origin: imagej/ImageJA

public ImageStack expandStack(ImageStack stackOld, int wNew, int hNew, int xOff, int yOff) {
  int nFrames = stackOld.getSize();
  ImageProcessor ipOld = stackOld.getProcessor(1);
  java.awt.Color colorBack = Toolbar.getBackgroundColor();
  
  ImageStack stackNew = new ImageStack(wNew, hNew, stackOld.getColorModel());
  ImageProcessor ipNew;
  
  for (int i=1; i<=nFrames; i++) {
    IJ.showProgress((double)i/nFrames);
    ipNew = ipOld.createProcessor(wNew, hNew);
    if (zeroFill)
      ipNew.setValue(0.0);
    else 
      ipNew.setColor(colorBack);
    ipNew.fill();
    ipNew.insert(stackOld.getProcessor(i), xOff, yOff);
    stackNew.addSlice(stackOld.getSliceLabel(i), ipNew);
  }
  return stackNew;
}

代码示例来源:origin: net.imagej/ij

Color bgc = Toolbar.getBackgroundColor();
if (bitDepth==8)
  ip.setBackgroundValue(ip.getBestIndex(bgc));

代码示例来源:origin: sc.fiji/Stack_Manipulation

public void clearOutside(ImageProcessor ip,ImagePlus imp, Roi roi, Rectangle r) {
  if (isLineSelection(roi)) {
    return;
  }
  ImageProcessor mask = makeMask(ip, r, imp);
  ip.setColor(Toolbar.getBackgroundColor());
  ip.snapshot();
  ip.fill();
  ip.reset(mask);
  int width = ip.getWidth();
  int height = ip.getHeight();
  ip.setRoi(0, 0, r.x, height);
  ip.fill();
  ip.setRoi(r.x, 0, r.width, r.y);
  ip.fill();
  ip.setRoi(r.x, r.y+r.height, r.width, height-(r.y+r.height));
  ip.fill();
  ip.setRoi(r.x+r.width, 0, width-(r.x+r.width), height);
  ip.fill();
  ip.resetRoi();
}
boolean isLineSelection(Roi roi) {

代码示例来源:origin: sc.fiji/Stack_Manipulation

void insert(ImageProcessor ip1temp, ImagePlus imp1){
  IJ.run("Add Slice");
  imp.updateAndDraw();
  stack = imp.getStack();
  ImageProcessor ip = stack.getProcessor(slice+1);
  Roi roi = imp1.getRoi();
  ImageProcessor ip1 = convertType(ip1temp,ip,doScaling);
  ip.setColor(Toolbar.getBackgroundColor());
  ip.fill();
  ip1.setRoi(roi);
   Rectangle r = ip1.getRoi();
  clearOutside(ip1,imp1, roi, r);
  if((ip.getWidth()==ip1.getWidth())&&(ip.getHeight()==ip1.getHeight()))
    ip.copyBits(ip1,0,0,Blitter.COPY);
  else{
    int x1Cent = r.x + r.width/2;
    int y1Cent = r.y + r.height/2;
    int xCent = ip.getWidth()/2;
    int yCent = ip.getHeight()/2;
    ip.copyBits(ip1,xCent-x1Cent,yCent-y1Cent,Blitter.COPY);
  }
  ip.setColor(Toolbar.getForegroundColor());
  imp.setStack(null,stack);
  imp.setSlice(++slice);
  imp.updateAndDraw();
}
//Convert ip1 to be the same type as ip

相关文章