Esempio n. 1
0
 public void run(String arg) {
   ImagePlus imp = WindowManager.getImage(id);
   if (imp != null && imp.getWindow() != null) {
     imp.getWindow().toFront();
     return;
   }
   int colorWidth = 22;
   int colorHeight = 16;
   int columns = 5;
   int rows = 20;
   int width = columns * colorWidth;
   int height = rows * colorHeight;
   ColorGenerator cg = new ColorGenerator(width, height, new int[width * height], this);
   cg.drawColors(colorWidth, colorHeight, columns, rows);
   setProcessor("CP", cg);
   id = getID();
   show();
   IJ.register(ColorPicker.class);
 }
Esempio n. 2
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();
      }
    }
  }
 @NotNull
 @Override
 public JBColor getColorOfBranch(int headCommit) {
   Collection<VcsRef> refs = myRefsModel.refsToCommit(headCommit);
   if (isEmptyRefs(refs, headCommit)) {
     return DEFAULT_COLOR;
   }
   VcsRef firstRef = getRefManager(refs).sort(refs).get(0);
   Color color = ColorGenerator.getColor(firstRef.getName().hashCode());
   // TODO dark variant
   return new JBColor(color, color);
 }
  @NotNull
  private static Color[] generateColorSequence(@NotNull TextAttributesScheme colorsScheme) {
    String colorDump =
        ApplicationManager.getApplication().isUnitTestMode()
            ? UNIT_TEST_COLORS
            : Registry.get("rainbow.highlighter.colors").asString();

    final List<String> registryColors = StringUtil.split(colorDump, ",");
    if (!registryColors.isEmpty()) {
      return registryColors.stream().map(s -> ColorUtil.fromHex(s.trim())).toArray(Color[]::new);
    }

    List<Color> stopColors =
        ContainerUtil.map(
            RAINBOW_COLOR_KEYS, key -> colorsScheme.getAttributes(key).getForegroundColor());
    List<Color> colors =
        ColorGenerator.generateLinearColorSequence(stopColors, RAINBOW_COLORS_BETWEEN);
    return colors.toArray(new Color[colors.size()]);
  }
 @NotNull
 @Override
 public JBColor getColorOfFragment(int headCommit, int magicIndex) {
   Color color = ColorGenerator.getColor(magicIndex);
   return new JBColor(color, color);
 }
Esempio n. 6
0
 public void refreshColors() {
   ImageProcessor ip = imp.getProcessor();
   ((ColorGenerator) ip).refreshBackground();
   ((ColorGenerator) ip).refreshForeground();
 }
 @Override
 public Color getColor(int colorId) {
   return ColorGenerator.getColor(colorId);
 }