]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/svg/SVGUnits.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / svg / SVGUnits.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.svg;
13
14 import java.util.HashSet;
15 import java.util.Set;
16
17 /**
18  * @author Tuukka Lehtonen
19  */
20 public final class SVGUnits {
21
22     /**
23      * inches, 1in = 2.54cm
24      */
25     public static final String UNIT_IN = "in";
26     
27     /**
28      * centimeters, 1cm = 10mm
29      */
30     public static final String UNIT_CM = "cm";
31     
32     /**
33      * millimeters
34      */
35     public static final String UNIT_MM = "mm";
36     
37     /**
38      * points, 1pt = 1/72in
39      */
40     public static final String UNIT_PT = "pt";
41     
42     /**
43      * picas, 1pc = 12pt
44      */
45     public static final String UNIT_PC = "pc";
46     
47     /**
48      * px (pixels, relative to the canvas resolution)
49      */
50     public static final String UNIT_PX = "px";
51     
52     /**
53      * User units, equal to px, i.e. pixel units.
54      */
55     public static final String UNIT_USER = UNIT_PX;
56     
57
58     private static final Set<String> validUnitSet;
59     
60     private static final String[] validUnits = {
61         UNIT_IN,
62         UNIT_CM,
63         UNIT_MM,
64         UNIT_PT,
65         UNIT_PC,
66         UNIT_PX,        
67     };
68     
69     static {
70         validUnitSet = new HashSet<String>();
71         for (String unit : validUnits) {
72             validUnitSet.add(unit);
73         }
74     }
75
76     
77     public static final boolean isValidUnit(String unit) {
78         return validUnitSet.contains(unit);
79     }
80
81 }