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 ColorCieLuv { 020 021 /** 022 * A constant for color black. Color components are: 023 * <pre> 024 * L: 0.000 025 * u: 0.000 026 * v: 0.000 027 * </pre> 028 */ 029 public static final ColorCieLuv BLACK = new ColorCieLuv(0, 0, 0); 030 031 /** 032 * A constant for color white. Color components are: 033 * <pre> 034 * L: 100.000 035 * u: 0.000 036 * v: -0.017 037 * </pre> 038 */ 039 public static final ColorCieLuv WHITE = new ColorCieLuv(100, 0, -0.017); 040 041 /** 042 * A constant for color red. Color components are: 043 * <pre> 044 * L: 53.233 045 * u: 175.053 046 * v: 37.751 047 * </pre> 048 */ 049 public static final ColorCieLuv RED = new ColorCieLuv(53.233, 175.053, 37.751); 050 051 /** 052 * A constant for color green. Color components are: 053 * <pre> 054 * L: 87.737 055 * u: -83.080 056 * v: 107.401 057 * </pre> 058 */ 059 public static final ColorCieLuv GREEN = new ColorCieLuv(87.737, -83.080, 107.401); 060 061 /** 062 * A constant for color blue. Color components are: 063 * <pre> 064 * L: 32.303 065 * u: -9.400 066 * v: -130.358 067 * </pre> 068 */ 069 public static final ColorCieLuv BLUE = new ColorCieLuv(32.303, -9.400, -130.358); 070 071 public final double L; 072 public final double u; 073 public final double v; 074 075 public ColorCieLuv(final double L, final double u, final double v) { 076 this.L = L; 077 this.u = u; 078 this.v = v; 079 } 080 081 @Override 082 public String toString() { 083 return "{L: " + L + ", u: " + u + ", v: " + v + "}"; 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 ColorCieLuv that = (ColorCieLuv) o; 096 if (Double.compare(that.L, L) != 0) { 097 return false; 098 } 099 if (Double.compare(that.u, u) != 0) { 100 return false; 101 } 102 if (Double.compare(that.v, v) != 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(u); 116 result = 31 * result + (int) (temp ^ (temp >>> 32)); 117 temp = Double.doubleToLongBits(v); 118 result = 31 * result + (int) (temp ^ (temp >>> 32)); 119 return result; 120 } 121}