001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.imaging.color; 018 019public final class ColorCieLch { 020 021 /** 022 * A constant for color black. Color components are: 023 * <pre> 024 * L: 0 025 * c: 0 026 * h: 0 027 * </pre> 028 */ 029 public static final ColorCieLch BLACK = new ColorCieLch(0, 0, 0); 030 031 /** 032 * A constant for color white. Color components are: 033 * <pre> 034 * L: 100 035 * c: 0 036 * h: 297 037 * </pre> 038 */ 039 public static final ColorCieLch WHITE = new ColorCieLch(100, 0, 297); 040 041 /** 042 * A constant for color red. Color components are: 043 * <pre> 044 * L: 53 045 * c: 80 046 * h: 67 047 * </pre> 048 */ 049 public static final ColorCieLch RED = new ColorCieLch(53, 80, 67); 050 051 /** 052 * A constant for color green. Color components are: 053 * <pre> 054 * L: 88 055 * c: -86 056 * h: 83 057 * </pre> 058 */ 059 public static final ColorCieLch GREEN = new ColorCieLch(88, -86, 83); 060 061 /** 062 * A constant for color blue. Color components are: 063 * <pre> 064 * L: 32 065 * c: 79 066 * h: -108 067 * </pre> 068 */ 069 public static final ColorCieLch BLUE = new ColorCieLch(32, 79, -108); 070 071 public final double L; 072 public final double C; 073 public final double H; 074 075 public ColorCieLch(final double L, final double C, final double H) { 076 this.L = L; 077 this.C = C; 078 this.H = H; 079 } 080 081 @Override 082 public String toString() { 083 return "{L: " + L + ", C: " + C + ", H: " + H + "}"; 084 } 085 086 @Override 087 public boolean equals(final Object o) { 088 if (this == o) { 089 return true; 090 } 091 if (o == null || getClass() != o.getClass()) { 092 return false; 093 } 094 095 final ColorCieLch that = (ColorCieLch) o; 096 if (Double.compare(that.C, C) != 0) { 097 return false; 098 } 099 if (Double.compare(that.H, H) != 0) { 100 return false; 101 } 102 if (Double.compare(that.L, L) != 0) { 103 return false; 104 } 105 106 return true; 107 } 108 109 @Override 110 public int hashCode() { 111 int result; 112 long temp; 113 temp = Double.doubleToLongBits(L); 114 result = (int) (temp ^ (temp >>> 32)); 115 temp = Double.doubleToLongBits(C); 116 result = 31 * result + (int) (temp ^ (temp >>> 32)); 117 temp = Double.doubleToLongBits(H); 118 result = 31 * result + (int) (temp ^ (temp >>> 32)); 119 return result; 120 } 121}