Beispiel #1
0
 private Color[] getBgColors(final JRadioButton radioButton) {
   if (radioButton.isEnabled()) {
     final float progress = getProgress();
     if (progress < 1f) {
       return new Color[] {
         ColorUtils.getIntermediateColor(topBgColor, topSelectedBgColor, progress),
         ColorUtils.getIntermediateColor(bottomBgColor, bottomSelectedBgColor, progress)
       };
     } else {
       return new Color[] {topSelectedBgColor, bottomSelectedBgColor};
     }
   } else {
     return new Color[] {topBgColor, bottomBgColor};
   }
 }
  private void updateColorFromField() {
    final String current = getText();
    if (!current.equals(last)) {
      try {
        final boolean hex = fieldType.equals(ColorChooserFieldType.hex);
        Color newColor =
            hex ? ColorUtils.parseHexColor(current) : ColorUtils.parseRgbColor(current);
        if (newColor != null) {
          // todo Ignoring alpha for now
          newColor = ColorUtils.removeAlpha(newColor);

          // Apply new value
          setColor(newColor);
        } else {
          // Restore old value
          updateViewFromColor();
        }
      } catch (final Throwable e) {
        // Restore old value
        updateViewFromColor();
      }
    }
  }
 private String getColorText(final Color color) {
   final boolean hex = fieldType.equals(ColorChooserFieldType.hex);
   return hex
       ? ColorUtils.getHexColor(color)
       : color.getRed() + "," + color.getGreen() + "," + color.getBlue();
 }