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;
17 import java.awt.Dimension;
23 * @author Toni Kalajainen
25 public class PixelDimension {
27 public final int width;
29 public final int height;
31 public PixelDimension(int width, int height) {
36 public PixelDimension(PixelDimension d) {
37 this(d.width, d.height);
40 public PixelDimension(Dimension d) {
41 this(d.width, d.height);
44 public int getHeight() {
48 public int getWidth() {
52 public boolean equals(Object obj) {
53 if (!(obj instanceof PixelDimension))
55 PixelDimension d = (PixelDimension) obj;
56 return (width == d.width) && (height == d.height);
59 public int hashCode() {
60 int sum = width+height;
61 return sum*(sum+1)/2 + width;
65 public String toString() {
66 return "PixelDimension [w=" + width + ", h=" + height + "]";
70 * returns aspect ratio (width / height)
71 * @return returns aspect ratio (width / height)
73 public double getAspectRatio()
75 return (double)width / (double)height;