Ejemplo n.º 1
0
 public void saveRecentColors() {
   myRecentColorsComponent.saveColors();
 }
Ejemplo n.º 2
0
  private ColorPicker(
      Disposable parent,
      @Nullable Color color,
      boolean restoreColors,
      boolean enableOpacity,
      List<ColorPickerListener> listeners,
      boolean opacityInPercent) {
    myUpdateQueue = new Alarm(Alarm.ThreadToUse.SWING_THREAD, parent);
    myRed = createColorField(false);
    myGreen = createColorField(false);
    myBlue = createColorField(false);
    myHex = createColorField(true);
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    myColorWheelPanel = new ColorWheelPanel(this, enableOpacity, opacityInPercent);

    myExternalListeners = listeners;
    myFormat.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            PropertiesComponent.getInstance()
                .setValue(HSB_PROPERTY, String.valueOf(!isRGBMode()), Boolean.FALSE.toString());
            myR.setText(isRGBMode() ? "R:" : "H:");
            myG.setText(isRGBMode() ? "G:" : "S:");
            myR_after.setText(isRGBMode() ? "" : "\u00B0");
            myG.setText(isRGBMode() ? "G:" : "S:");
            myG_after.setText(isRGBMode() ? "" : "%");
            myB_after.setText(isRGBMode() ? "" : "%");
            applyColor(myColor);
          }
        });

    myPicker =
        createPipette(
            new ColorListener() {
              @Override
              public void colorChanged(Color color, Object source) {
                setColor(color, source);
              }
            },
            parent);
    try {
      add(buildTopPanel(true), BorderLayout.NORTH);
      add(myColorWheelPanel, BorderLayout.CENTER);

      myRecentColorsComponent =
          new RecentColorsComponent(
              new ColorListener() {
                @Override
                public void colorChanged(Color color, Object source) {
                  setColor(color, source);
                }
              },
              restoreColors);

      add(myRecentColorsComponent, BorderLayout.SOUTH);
    } catch (ParseException ignore) {
    }

    //noinspection UseJBColor
    Color c =
        ObjectUtils.notNull(
            color == null ? myRecentColorsComponent.getMostRecentColor() : color, Color.WHITE);
    setColor(c, this);

    setSize(300, 350);

    final boolean hsb = PropertiesComponent.getInstance().getBoolean(HSB_PROPERTY);
    if (hsb) {
      myFormat.setSelectedIndex(1);
    }
  }
Ejemplo n.º 3
0
 public void appendRecentColor() {
   myRecentColorsComponent.appendColor(myColor);
 }