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