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= "https://pdfs.semanticscholar.org/647b/20bda458133ff2b883041746bc8cb75527fc.pdf">Comparison of the metrics between the CIELAB and the DIN99
022 *      uniform color spaces</a>
023 * @see <a href="https://www.researchgate.net/publication/229891006_Uniform_colour_spaces_based_on_the_DIN99_colour-difference_formula">DIN99b P.284:
024 *      Uniform_colour_spaces_based_on_the_DIN99_colour-difference_formula</a>
025 * @since 1.0-alpha3
026 */
027public final class ColorDin99Lab {
028
029    public final double l99;
030
031    public final double a99;
032
033    public final double b99;
034
035    public ColorDin99Lab(final double l99, final double a99, final double b99) {
036        this.l99 = l99;
037        this.a99 = a99;
038        this.b99 = b99;
039    }
040
041    @Override
042    public boolean equals(final Object o) {
043        if (this == o) {
044            return true;
045        }
046        if (o == null || getClass() != o.getClass()) {
047            return false;
048        }
049
050        final ColorDin99Lab that = (ColorDin99Lab) o;
051        if (Double.compare(that.l99, l99) != 0) {
052            return false;
053        }
054        if (Double.compare(that.a99, a99) != 0) {
055            return false;
056        }
057        if (Double.compare(that.b99, b99) != 0) {
058            return false;
059        }
060
061        return true;
062    }
063
064    @Override
065    public int hashCode() {
066        int result;
067        long temp;
068        temp = Double.doubleToLongBits(l99);
069        result = (int) (temp ^ temp >>> 32);
070        temp = Double.doubleToLongBits(a99);
071        result = 31 * result + (int) (temp ^ temp >>> 32);
072        temp = Double.doubleToLongBits(b99);
073        return 31 * result + (int) (temp ^ temp >>> 32);
074    }
075
076    @Override
077    public String toString() {
078        return "{l: " + l99 + ", a: " + a99 + ", b: " + b99 + "}";
079    }
080}