1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
15 package org.simantics.utils.ui.gfx;
20 * @author Toni Kalajainen
22 public class PhysicalDimension {
24 /** Width in meters */
25 public final double width;
27 /** height in meters */
28 public final double height;
30 private final int hash;
32 public PhysicalDimension(double width, double height) {
35 this.hash = makeHash(width, height);
38 public PhysicalDimension(PixelDimension d) {
39 this(d.width, d.height);
42 public double getHeight() {
46 public double getWidth() {
50 public boolean equals(Object obj) {
51 if (!(obj instanceof PixelDimension))
53 PixelDimension d = (PixelDimension) obj;
54 return (width == d.width) && (height == d.height);
57 public int hashCode() {
61 private static int makeHash(Double w, Double h) {
62 return w.hashCode() ^ (h.hashCode()*7);
66 public String toString() {
67 return "PhysicalDimension [w=" + width + ", h=" + height + "]";
71 * returns aspect ratio (width / height)
72 * @return returns aspect ratio (width / height)
74 public double getAspectRatio()
76 return width / height;