コード例 #1
0
 /**
  * Test is a color is lighter than {@code this}
  *
  * @param other A color
  * @return {@code true} if {@code other} is lighter than {@code this}, else {@code false}
  */
 public boolean isLighter(int other) {
   return getLuminance() > ColorUtils.calculateLuminance(other);
 }
コード例 #2
0
 /**
  * Convert this color into a Hue, Saturation, Value human readable string
  *
  * @return A string
  */
 public String toHSVString() {
   return ColorUtils.toHsvString(mColor);
 }
コード例 #3
0
 /**
  * Test is a color is darker than {@code this}
  *
  * @param other A color
  * @return {@code true} if {@code other} is darker than {@code this}, else {@code false}
  */
 public boolean isDarker(int other) {
   return getLuminance() < ColorUtils.calculateLuminance(other);
 }
コード例 #4
0
 @Override
 public String toString() {
   return ColorUtils.toARGBString(mColor);
 }
コード例 #5
0
 @Override
 public double getLuminance() {
   return ColorUtils.calculateLuminance(mColor);
 }
コード例 #6
0
 /**
  * @param brightBackground {@code true} if the background is bright, else {@code false}
  * @return A foreground text color to fit the background
  */
 public static int getDisabledTextColor(boolean brightBackground) {
   int color = brightBackground ? Color.BLACK : Color.WHITE;
   int alpha = brightBackground ? TEXT_ALPHA_DISABLED_DARK : TEXT_ALPHA_DISABLED_LIGHT;
   return ColorUtils.setAlphaComponent(color, alpha);
 }
コード例 #7
0
 /**
  * @param brightBackground {@code true} if the background is bright, else {@code false}
  * @return A foreground text color to fit the background
  */
 public static int getSecondaryTextColor(boolean brightBackground) {
   int color = brightBackground ? Color.BLACK : Color.WHITE;
   int alpha = brightBackground ? TEXT_ALPHA_SECONDARY_DARK : TEXT_ALPHA_SECONDARY_LIGHT;
   return ColorUtils.setAlphaComponent(color, alpha);
 }