Esempio n. 1
0
 public void drawTileNumC(int tileNum, int x, int y, Color c, Graphics g) {
   BufferedImage coloredTile = tiles[tileNum];
   for (int i = 0; i < this.tW; i++) {
     for (int j = 0; j < this.tH; j++) {
       Color originalColor = new Color(coloredTile.getRGB(i, j), true);
       Color nc = new Color(c.getRed(), c.getGreen(), c.getBlue(), originalColor.getAlpha());
       coloredTile.setRGB(i, j, nc.getRGB());
     }
   }
   g.drawImage(tiles[tileNum], x, y, null);
 }
Esempio n. 2
0
 /**
  * Set a fixed blurring color. If the blurColor has no alpha transparency factor (see {@link
  * JBusyPanel#DEFAULT_ALPHA_NO_TRANSPARENCY_FACTOR DEFAULT_ALPHA_NO_TRANSPARENCY_FACTOR} ) the
  * {@link JBusyPanel#DEFAULT_ALPHA_TRANSPARENCY_FACTOR DEFAULT_ALPHA_TRANSPARENCY_FACTOR} is
  * applied.
  *
  * <p>If the blurColor is NULL the {@link JBusyPanel#DEFAULT_ALPHA_TRANSPARENCY_FACTOR
  * DEFAULT_ALPHA_TRANSPARENCY_FACTOR} is applied to the window's background color in {@link
  * JBusyPanel#BLUR_STYLE_ALPHA_CHANNEL BLUR_STYLE_ALPHA_CHANNEL} mode.
  *
  * @param blurColor Color New blurring color.
  */
 public static synchronized void setBlurColor(Color blurColor) {
   if ((blurColor == null)
       || (blurColor.getAlpha() != JBusyPanel.DEFAULT_ALPHA_NO_TRANSPARENCY_FACTOR)) {
     getInstance().blurColor = blurColor;
   } else {
     getInstance().blurColor =
         new Color(
             blurColor.getRed(),
             blurColor.getGreen(),
             blurColor.getBlue(),
             JBusyPanel.DEFAULT_ALPHA_TRANSPARENCY_FACTOR);
   }
 }
    private void setColor(Color color, Object source) {
      float[] hsb = new float[3];
      Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
      myColor = color;
      myHue = hsb[0];
      mySaturation = hsb[1];
      myBrightness = hsb[2];
      myOpacity = color.getAlpha();

      fireColorChanged(source);

      repaint();
    }
    @Override
    public String getToolTipText(MouseEvent event) {
      Color color = getColor(event);
      if (color != null) {
        return String.format(
            "R: %d G: %d B: %d A: %s",
            color.getRed(),
            color.getGreen(),
            color.getBlue(),
            String.format("%.2f", (float) (color.getAlpha() / 255.0)));
      }

      return super.getToolTipText(event);
    }
    public void setColor(Color color, Object source) {
      float[] hsb = new float[3];
      Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);

      myBrightnessComponent.setValue(255 - (int) (hsb[2] * 255));
      myBrightnessComponent.repaint();

      myColorWheel.dropImage();
      if (myOpacityComponent != null && source instanceof ColorPicker) {
        myOpacityComponent.setValue(color.getAlpha());
        myOpacityComponent.repaint();
      }

      myColorWheel.setColor(color, source);
    }
    public void saveColors() {
      final List<String> values = new ArrayList<>();
      for (Color recentColor : myRecentColors) {
        if (recentColor == null) break;
        values.add(
            String.format(
                "%d-%d-%d-%d",
                recentColor.getRed(),
                recentColor.getGreen(),
                recentColor.getBlue(),
                recentColor.getAlpha()));
      }

      PropertiesComponent.getInstance()
          .setValue(
              COLOR_CHOOSER_COLORS_KEY,
              values.isEmpty() ? null : StringUtil.join(values, ",,,"),
              null);
    }