--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+/*\r
+ * 10.10.2006\r
+ */\r
+package org.simantics.utils.ui.gfx;\r
+\r
+\r
+/**\r
+ * PhysicalDimension\r
+ * @author Toni Kalajainen\r
+ */\r
+public class PhysicalDimension {\r
+\r
+ /** Width in meters */\r
+ public final double width;\r
+\r
+ /** height in meters */\r
+ public final double height;\r
+ \r
+ private final int hash;\r
+\r
+ public PhysicalDimension(double width, double height) {\r
+ this.width = width;\r
+ this.height = height;\r
+ this.hash = makeHash(width, height);\r
+ }\r
+\r
+ public PhysicalDimension(PixelDimension d) {\r
+ this(d.width, d.height);\r
+ }\r
+ \r
+ public double getHeight() {\r
+ return height;\r
+ }\r
+\r
+ public double getWidth() {\r
+ return width;\r
+ }\r
+\r
+ public boolean equals(Object obj) {\r
+ if (!(obj instanceof PixelDimension))\r
+ return false;\r
+ PixelDimension d = (PixelDimension) obj;\r
+ return (width == d.width) && (height == d.height);\r
+ }\r
+\r
+ public int hashCode() { \r
+ return hash;\r
+ }\r
+\r
+ private static int makeHash(Double w, Double h) {\r
+ return w.hashCode() ^ (h.hashCode()*7);\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return "PhysicalDimension [w=" + width + ", h=" + height + "]";\r
+ }\r
+ \r
+ /**\r
+ * returns aspect ratio (width / height)\r
+ * @return returns aspect ratio (width / height)\r
+ */\r
+ public double getAspectRatio()\r
+ {\r
+ return width / height;\r
+ }\r
+ \r
+}\r