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 * http://www.apache.org/licenses/LICENSE-2.0
009 * Unless required by applicable law or agreed to in writing, software
010 * distributed under the License is distributed on an "AS IS" BASIS,
011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 * See the License for the specific language governing permissions and
013 * limitations under the License.
014 */
015package org.apache.commons.imaging.color;
016
017/**
018 * Represents a color in the DIN99 color space, a derivation of the CIE LAB color space.
019 *
020 * @see <a href="de.wikipedia.org/wiki/DIN99-Farbraum">de.wikipedia.org/wiki/DIN99-Farbraum</a>
021 * @see <a href=
022 *      "https://pdfs.semanticscholar.org/647b/20bda458133ff2b883041746bc8cb75527fc.pdf">Comparison of the metrics between the CIELAB and the DIN99 uniform
023 *      color spaces</a>
024 * @see <a href="https://www.researchgate.net/publication/229891006_Uniform_colour_spaces_based_on_the_DIN99_colour-difference_formula">DIN99b P.284:
025 *      Uniform_colour_spaces_based_on_the_DIN99_colour-difference_formula</a>
026 * @since 1.0-alpha3
027 */
028public final class ColorDin99Lab {
029
030    public final double L99;
031
032    public final double a99;
033
034    public final double b99;
035
036    public ColorDin99Lab(final double L99, final double a99, final double b99) {
037        this.L99 = L99;
038        this.a99 = a99;
039        this.b99 = b99;
040    }
041
042    @Override
043    public String toString() {
044        return "{L: " + L99 + ", a: " + a99 + ", b: " + b99 + "}";
045    }
046
047    @Override
048    public boolean equals(final Object o) {
049        if (this == o) {
050            return true;
051        }
052        if (o == null || getClass() != o.getClass()) {
053            return false;
054        }
055
056        final ColorDin99Lab that = (ColorDin99Lab) o;
057        if (Double.compare(that.L99, L99) != 0) {
058            return false;
059        }
060        if (Double.compare(that.a99, a99) != 0) {
061            return false;
062        }
063        if (Double.compare(that.b99, b99) != 0) {
064            return false;
065        }
066
067        return true;
068    }
069
070    @Override
071    public int hashCode() {
072        int result;
073        long temp;
074        temp = Double.doubleToLongBits(L99);
075        result = (int) (temp ^ temp >>> 32);
076        temp = Double.doubleToLongBits(a99);
077        result = 31 * result + (int) (temp ^ temp >>> 32);
078        temp = Double.doubleToLongBits(b99);
079        result = 31 * result + (int) (temp ^ temp >>> 32);
080        return result;
081    }
082}