예제 #1
0
  public void mousePressed(MouseEvent e) {
    // super.mousePressed(e);
    ImageProcessor ip = imp.getProcessor();
    ip.setLineWidth(1);
    if (Toolbar.getToolId() == Toolbar.DROPPER) IJ.setTool(Toolbar.RECTANGLE);

    Rectangle flipperRect = new Rectangle(86, 268, 18, 18);
    Rectangle resetRect = new Rectangle(86, 294, 18, 18);
    Rectangle foreground1Rect = new Rectangle(9, 266, 45, 10);
    Rectangle foreground2Rect = new Rectangle(9, 276, 23, 25);
    Rectangle background1Rect = new Rectangle(33, 302, 45, 10);
    Rectangle background2Rect = new Rectangle(56, 277, 23, 25);
    int x = offScreenX(e.getX());
    int y = offScreenY(e.getY());
    long difference = System.currentTimeMillis() - mouseDownTime;
    boolean doubleClick = (difference <= 250);
    mouseDownTime = System.currentTimeMillis();
    if (flipperRect.contains(x, y)) {
      Color c = Toolbar.getBackgroundColor();
      Toolbar.setBackgroundColor(Toolbar.getForegroundColor());
      Toolbar.setForegroundColor(c);
    } else if (resetRect.contains(x, y)) {
      Toolbar.setForegroundColor(new Color(0x000000));
      Toolbar.setBackgroundColor(new Color(0xffffff));
    } else if ((background1Rect.contains(x, y)) || (background2Rect.contains(x, y))) {
      background = true;
      if (doubleClick) editColor();
      ((ColorGenerator) ip).refreshForeground();
      ((ColorGenerator) ip).refreshBackground();
    } else if ((foreground1Rect.contains(x, y)) || (foreground2Rect.contains(x, y))) {
      background = false;
      if (doubleClick) editColor();
      ((ColorGenerator) ip).refreshBackground();
      ((ColorGenerator) ip).refreshForeground();
    } else {
      // IJ.log(" " + difference + " " + doubleClick);
      if (doubleClick) editColor();
      else {
        setDrawingColor(offScreenX(e.getX()), offScreenY(e.getY()), background);
      }
    }
    if (ip instanceof ColorGenerator) {
      if (background) {
        ((ColorGenerator) ip).refreshForeground();
        ((ColorGenerator) ip).refreshBackground();
      } else {
        ((ColorGenerator) ip).refreshBackground();
        ((ColorGenerator) ip).refreshForeground();
      }
    }
  }
예제 #2
0
  void drawColors(int colorWidth, int colorHeight, int columns, int rows) {
    w = colorWidth;
    h = colorHeight;
    setColor(0xffffff);
    setRoi(0, 0, 110, 320);
    fill();
    drawRamp();
    resetBW();
    flipper();
    drawLine(0, 256, 110, 256);

    int x = 1;
    int y = 0;
    refreshBackground();
    refreshForeground();

    Color c;
    float hue, saturation = 1f, brightness = 1f;
    double w = colorWidth, h = colorHeight;
    for (x = 2; x < 10; x++) {
      for (y = 0; y < 32; y++) {
        hue = (float) (y / (2 * h) - .15);
        if (x < 6) {
          saturation = 1f;
          brightness = (float) (x * 4 / w);
        } else {
          saturation = 1f - ((float) ((5 - x) * -4 / w));
          brightness = 1f;
        }
        c = Color.getHSBColor(hue, saturation, brightness);
        setRoi(x * (int) (w / 2), y * (int) (h / 2), (int) w / 2, (int) h / 2);
        setColor(c);
        fill();
      }
    }
    drawSpectrum(h);
    resetRoi();
  }
예제 #3
0
 public void refreshColors() {
   ImageProcessor ip = imp.getProcessor();
   ((ColorGenerator) ip).refreshBackground();
   ((ColorGenerator) ip).refreshForeground();
 }