]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/Dimensions.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / gfx / Dimensions.java
index 82f6ae5eccd6ddd8783aeb0ca0968303225e6298..fc2f50d68acd504fb673d73e9ff8f8a5cb9ab72f 100644 (file)
-/*******************************************************************************\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
-import org.simantics.utils.ObjectUtils;\r
-\r
-\r
-/**\r
- * Dimensions\r
- * @author Toni Kalajainen\r
- */\r
-public final class Dimensions {\r
-\r
-    public final static Double INCH = 25.4;\r
-    \r
-    /** Pixel size, may be null if unknown */\r
-    public final PixelDimension pixelDimension;\r
-    \r
-    /** Physical size, may be null if unknown */\r
-    public final PhysicalDimension physicaldimension;\r
-    \r
-    public Dimensions(PixelDimension pixelDimension, PhysicalDimension physicalDimension)\r
-    {\r
-        this.physicaldimension = physicalDimension;\r
-        this.pixelDimension = pixelDimension;\r
-    }\r
-    \r
-    @Override\r
-    public int hashCode() {\r
-        int code = 0;\r
-        if (pixelDimension!=null) code^= pixelDimension.hashCode();\r
-        if (physicaldimension!=null) code^= physicaldimension.hashCode();\r
-        return code;\r
-    }\r
-    \r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (!(obj instanceof Dimensions)) return false;\r
-        Dimensions other = (Dimensions) obj;\r
-        return ObjectUtils.objectEquals(other.physicaldimension, physicaldimension) &&\r
-               ObjectUtils.objectEquals(other.pixelDimension, pixelDimension);\r
-    }\r
-    \r
-    \r
-    \r
-    public PhysicalDimension getPhysicaldimension() {\r
-        return physicaldimension;\r
-    }\r
-\r
-    public PixelDimension getPixelDimension() {\r
-        return pixelDimension;\r
-    }\r
-\r
-    /**\r
-     * Calculate horizontal Dots per inch.\r
-     * @return horizontal DPI or null if value is not available\r
-     */\r
-    public Double getHorizontalDPI()\r
-    {\r
-        if (pixelDimension==null || physicaldimension==null) return null;\r
-        if (physicaldimension.width==0) return null;\r
-        return (((double) pixelDimension.width)/physicaldimension.width)*INCH;\r
-    }\r
-    \r
-    /**\r
-     * Calculate vertical Dots per inch.\r
-     * @return Vertical DPI or null if value is not available\r
-     */\r
-    public Double getVerticalDPI()    \r
-    {\r
-        if (pixelDimension==null || physicaldimension==null) return null;\r
-        if (physicaldimension.height==0) return null;\r
-        return (((double) pixelDimension.height)/physicaldimension.height)*INCH;\r
-    }\r
-    \r
-    @Override\r
-    public String toString() {\r
-        return "Dimensions [" + physicaldimension + ", " + pixelDimension + "]";\r
-    }\r
-    \r
-    /**\r
-     * returns aspect ratio (width / height)\r
-     * @return returns aspect ratio (width / height)\r
-     */\r
-    public double getAspectRatio()\r
-    {\r
-        if (physicaldimension!=null)\r
-            return physicaldimension.getAspectRatio();\r
-        if (pixelDimension!=null)\r
-            return pixelDimension.getAspectRatio();\r
-        return 1;\r
-    }\r
-    \r
-    \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+/*
+ * 10.10.2006
+ */
+package org.simantics.utils.ui.gfx;
+
+import org.simantics.utils.ObjectUtils;
+
+
+/**
+ * Dimensions
+ * @author Toni Kalajainen
+ */
+public final class Dimensions {
+
+    public final static Double INCH = 25.4;
+    
+    /** Pixel size, may be null if unknown */
+    public final PixelDimension pixelDimension;
+    
+    /** Physical size, may be null if unknown */
+    public final PhysicalDimension physicaldimension;
+    
+    public Dimensions(PixelDimension pixelDimension, PhysicalDimension physicalDimension)
+    {
+        this.physicaldimension = physicalDimension;
+        this.pixelDimension = pixelDimension;
+    }
+    
+    @Override
+    public int hashCode() {
+        int code = 0;
+        if (pixelDimension!=null) code^= pixelDimension.hashCode();
+        if (physicaldimension!=null) code^= physicaldimension.hashCode();
+        return code;
+    }
+    
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Dimensions)) return false;
+        Dimensions other = (Dimensions) obj;
+        return ObjectUtils.objectEquals(other.physicaldimension, physicaldimension) &&
+               ObjectUtils.objectEquals(other.pixelDimension, pixelDimension);
+    }
+    
+    
+    
+    public PhysicalDimension getPhysicaldimension() {
+        return physicaldimension;
+    }
+
+    public PixelDimension getPixelDimension() {
+        return pixelDimension;
+    }
+
+    /**
+     * Calculate horizontal Dots per inch.
+     * @return horizontal DPI or null if value is not available
+     */
+    public Double getHorizontalDPI()
+    {
+        if (pixelDimension==null || physicaldimension==null) return null;
+        if (physicaldimension.width==0) return null;
+        return (((double) pixelDimension.width)/physicaldimension.width)*INCH;
+    }
+    
+    /**
+     * Calculate vertical Dots per inch.
+     * @return Vertical DPI or null if value is not available
+     */
+    public Double getVerticalDPI()    
+    {
+        if (pixelDimension==null || physicaldimension==null) return null;
+        if (physicaldimension.height==0) return null;
+        return (((double) pixelDimension.height)/physicaldimension.height)*INCH;
+    }
+    
+    @Override
+    public String toString() {
+        return "Dimensions [" + physicaldimension + ", " + pixelDimension + "]";
+    }
+    
+    /**
+     * returns aspect ratio (width / height)
+     * @return returns aspect ratio (width / height)
+     */
+    public double getAspectRatio()
+    {
+        if (physicaldimension!=null)
+            return physicaldimension.getAspectRatio();
+        if (pixelDimension!=null)
+            return pixelDimension.getAspectRatio();
+        return 1;
+    }
+    
+    
+}