]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/svg/SVGUnits.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / svg / SVGUnits.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/svg/SVGUnits.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/svg/SVGUnits.java
new file mode 100644 (file)
index 0000000..ac9fea7
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************\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
+package org.simantics.g2d.svg;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public final class SVGUnits {\r
+\r
+    /**\r
+     * inches, 1in = 2.54cm\r
+     */\r
+    public static final String UNIT_IN = "in";\r
+    \r
+    /**\r
+     * centimeters, 1cm = 10mm\r
+     */\r
+    public static final String UNIT_CM = "cm";\r
+    \r
+    /**\r
+     * millimeters\r
+     */\r
+    public static final String UNIT_MM = "mm";\r
+    \r
+    /**\r
+     * points, 1pt = 1/72in\r
+     */\r
+    public static final String UNIT_PT = "pt";\r
+    \r
+    /**\r
+     * picas, 1pc = 12pt\r
+     */\r
+    public static final String UNIT_PC = "pc";\r
+    \r
+    /**\r
+     * px (pixels, relative to the canvas resolution)\r
+     */\r
+    public static final String UNIT_PX = "px";\r
+    \r
+    /**\r
+     * User units, equal to px, i.e. pixel units.\r
+     */\r
+    public static final String UNIT_USER = UNIT_PX;\r
+    \r
+\r
+    private static final Set<String> validUnitSet;\r
+    \r
+    private static final String[] validUnits = {\r
+        UNIT_IN,\r
+        UNIT_CM,\r
+        UNIT_MM,\r
+        UNIT_PT,\r
+        UNIT_PC,\r
+        UNIT_PX,        \r
+    };\r
+    \r
+    static {\r
+        validUnitSet = new HashSet<String>();\r
+        for (String unit : validUnits) {\r
+            validUnitSet.add(unit);\r
+        }\r
+    }\r
+\r
+    \r
+    public static final boolean isValidUnit(String unit) {\r
+        return validUnitSet.contains(unit);\r
+    }\r
+\r
+}\r