diff --git a/src/com/t_oster/liblasercut/dithering/DitheringAlgorithm.java b/src/com/t_oster/liblasercut/dithering/DitheringAlgorithm.java index c266f96a569e9919af28cea78b74bbe87bbb91e8..b46f0605b4f29e622f73e9fb0d6caa6b2e9295b0 100644 --- a/src/com/t_oster/liblasercut/dithering/DitheringAlgorithm.java +++ b/src/com/t_oster/liblasercut/dithering/DitheringAlgorithm.java @@ -22,6 +22,8 @@ import com.t_oster.liblasercut.BlackWhiteRaster; import com.t_oster.liblasercut.Customizable; import com.t_oster.liblasercut.GreyscaleRaster; import com.t_oster.liblasercut.TimeIntensiveOperation; +import com.t_oster.liblasercut.platform.Util; +import java.util.Arrays; /** * @@ -80,4 +82,39 @@ public abstract class DitheringAlgorithm extends TimeIntensiveOperation implemen @Override public abstract String toString(); + + @Override + public boolean equals(Object o) + { + if (o == null || !getClass().equals(o.getClass())) + { + return false; + } + final DitheringAlgorithm other = (DitheringAlgorithm) o; + String[] own = this.getPropertyKeys(); + String[] ot = other.getPropertyKeys(); + if (!Arrays.deepEquals(own, ot)) + { + return false; + } + for (int i = 0; i < own.length; i++) + { + String key = own[i]; + if (!Util.differ(getProperty(key),other.getProperty(key))) + { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + for (String key : this.getPropertyKeys()) + { + hash += this.getProperty(key).hashCode(); + } + return hash; + } } diff --git a/src/com/t_oster/liblasercut/platform/Util.java b/src/com/t_oster/liblasercut/platform/Util.java index 8ec3769d93f556c58d41f3d55b6c3b2171f301d6..3ef85d6bd4e2067b659c3ced66f56b3b582a9df0 100644 --- a/src/com/t_oster/liblasercut/platform/Util.java +++ b/src/com/t_oster/liblasercut/platform/Util.java @@ -2,17 +2,17 @@ * This file is part of VisiCut. * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany - * + * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ @@ -33,7 +33,12 @@ public class Util { //TODO: check return dpi / 25.4; } - + + public static double dpmm2dpi(double dpmm) + { + return dpmm * 25.4; + } + public static double inch2mm(double inch) { return inch * 25.4; } @@ -55,7 +60,7 @@ public class Util { * This method is used to avoid null checks * @param a * @param b - * @return + * @return */ public static boolean differ(Object a, Object b) { if (a == null ^ b == null) {