]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.ui/src/org/simantics/ui/fonts/Fonts.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / fonts / Fonts.java
index c0276f5747ad967c98847a543bf98682cc7b8527..db5c85f90dec23a7e89a67b443e73062869568f3 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 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.ui.fonts;\r
-\r
-import java.awt.Font;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Device;\r
-import org.eclipse.swt.graphics.FontData;\r
-\r
-/**\r
- * @author Antti Villberg\r
- */\r
-public class Fonts {\r
-\r
-    public static java.awt.Font awt(FontDescriptor descriptor) {\r
-        return new Font(descriptor.getFamily(), descriptor.getStyle(), descriptor.getSize());\r
-    }\r
-    \r
-    public static org.simantics.datatypes.literal.Font fromAWT(Font f) {\r
-       return new org.simantics.datatypes.literal.Font(f.getFamily(), f.getSize(), fromAwtStyle(f.getStyle()));\r
-    }\r
-\r
-    private static boolean hasMask(int test, int mask) {\r
-        return (test & mask) == mask;\r
-    }\r
-\r
-    public static String fromSwtStyle(int swtStyle) {\r
-        if(hasMask(swtStyle, SWT.BOLD|SWT.ITALIC)) return "BoldItalic";\r
-        else if (hasMask(swtStyle, SWT.BOLD)) return "Bold";\r
-        else if (hasMask(swtStyle, SWT.ITALIC)) return "Italic";\r
-        return "Normal";\r
-    }\r
-\r
-    public static String fromAwtStyle(int awtStyle) {\r
-        if(hasMask(awtStyle, Font.BOLD|Font.ITALIC)) return "BoldItalic";\r
-        else if (hasMask(awtStyle, Font.BOLD)) return "Bold";\r
-        else if (hasMask(awtStyle, Font.ITALIC)) return "Italic";\r
-        return "Normal";\r
-    }\r
-\r
-    public static int swtStyle(String text) {\r
-       if("Normal".equals(text)) return SWT.NORMAL;\r
-       else if ("Bold".equals(text)) return SWT.BOLD;\r
-       else if ("Italic".equals(text)) return SWT.ITALIC;\r
-       else if ("BoldItalic".equals(text)) return SWT.BOLD|SWT.ITALIC;\r
-       else throw new RuntimeException("Illegal style '" + text + "'");\r
-    }\r
-    \r
-    public static int awtStyle(String text) {\r
-       if("Normal".equals(text)) return 0;\r
-       else if ("Bold".equals(text)) return Font.BOLD;\r
-       else if ("Italic".equals(text)) return Font.ITALIC;\r
-       else if ("BoldItalic".equals(text)) return Font.BOLD|Font.ITALIC;\r
-       else throw new RuntimeException("Illegal style '" + text + "'");\r
-    }\r
-\r
-    /**\r
-     * Returns SWT Font instance. Be aware that this is a native resource and\r
-     * must be disposed of properly.\r
-     * \r
-     * @param device\r
-     * @param font\r
-     * @return\r
-     * @see #swt(org.simantics.datatypes.literal.Font)\r
-     */\r
-    public static org.eclipse.swt.graphics.Font swt(Device device, org.simantics.datatypes.literal.Font font) {\r
-        return new org.eclipse.swt.graphics.Font(device, font.family, font.height, swtStyle(font.style));\r
-    }\r
-\r
-    /**\r
-     * Returns JFace FontDescriptor instance.\r
-     * \r
-     * @param font\r
-     * @return FontDescriptor for specified font\r
-     */\r
-    public static org.eclipse.jface.resource.FontDescriptor swt(org.simantics.datatypes.literal.Font font) {\r
-        return org.eclipse.jface.resource.FontDescriptor.createFrom(font.family, font.height, swtStyle(font.style));\r
-    }\r
-\r
-    /**\r
-     * Returns SWT FontData instance.\r
-     * \r
-     * @param font\r
-     * @return FontData for specified font\r
-     */\r
-    public static FontData swtFontData(org.simantics.datatypes.literal.Font font) {\r
-        return new FontData(font.family, font.height, swtStyle(font.style));\r
-    }\r
-\r
-    public static java.awt.Font awt(org.simantics.datatypes.literal.Font font) {\r
-        return new java.awt.Font(font.family, awtStyle(font.style), font.height);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/
+package org.simantics.ui.fonts;
+
+import java.awt.Font;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.FontData;
+
+/**
+ * @author Antti Villberg
+ */
+public class Fonts {
+
+    public static java.awt.Font awt(FontDescriptor descriptor) {
+        return new Font(descriptor.getFamily(), descriptor.getStyle(), descriptor.getSize());
+    }
+    
+    public static org.simantics.datatypes.literal.Font fromAWT(Font f) {
+       return new org.simantics.datatypes.literal.Font(f.getFamily(), f.getSize(), fromAwtStyle(f.getStyle()));
+    }
+
+    private static boolean hasMask(int test, int mask) {
+        return (test & mask) == mask;
+    }
+
+    public static String fromSwtStyle(int swtStyle) {
+        if(hasMask(swtStyle, SWT.BOLD|SWT.ITALIC)) return "BoldItalic";
+        else if (hasMask(swtStyle, SWT.BOLD)) return "Bold";
+        else if (hasMask(swtStyle, SWT.ITALIC)) return "Italic";
+        return "Normal";
+    }
+
+    public static String fromAwtStyle(int awtStyle) {
+        if(hasMask(awtStyle, Font.BOLD|Font.ITALIC)) return "BoldItalic";
+        else if (hasMask(awtStyle, Font.BOLD)) return "Bold";
+        else if (hasMask(awtStyle, Font.ITALIC)) return "Italic";
+        return "Normal";
+    }
+
+    public static int swtStyle(String text) {
+       if("Normal".equals(text)) return SWT.NORMAL;
+       else if ("Bold".equals(text)) return SWT.BOLD;
+       else if ("Italic".equals(text)) return SWT.ITALIC;
+       else if ("BoldItalic".equals(text)) return SWT.BOLD|SWT.ITALIC;
+       else throw new RuntimeException("Illegal style '" + text + "'");
+    }
+    
+    public static int awtStyle(String text) {
+       if("Normal".equals(text)) return 0;
+       else if ("Bold".equals(text)) return Font.BOLD;
+       else if ("Italic".equals(text)) return Font.ITALIC;
+       else if ("BoldItalic".equals(text)) return Font.BOLD|Font.ITALIC;
+       else throw new RuntimeException("Illegal style '" + text + "'");
+    }
+
+    /**
+     * Returns SWT Font instance. Be aware that this is a native resource and
+     * must be disposed of properly.
+     * 
+     * @param device
+     * @param font
+     * @return
+     * @see #swt(org.simantics.datatypes.literal.Font)
+     */
+    public static org.eclipse.swt.graphics.Font swt(Device device, org.simantics.datatypes.literal.Font font) {
+        return new org.eclipse.swt.graphics.Font(device, font.family, font.height, swtStyle(font.style));
+    }
+
+    /**
+     * Returns JFace FontDescriptor instance.
+     * 
+     * @param font
+     * @return FontDescriptor for specified font
+     */
+    public static org.eclipse.jface.resource.FontDescriptor swt(org.simantics.datatypes.literal.Font font) {
+        return org.eclipse.jface.resource.FontDescriptor.createFrom(font.family, font.height, swtStyle(font.style));
+    }
+
+    /**
+     * Returns SWT FontData instance.
+     * 
+     * @param font
+     * @return FontData for specified font
+     */
+    public static FontData swtFontData(org.simantics.datatypes.literal.Font font) {
+        return new FontData(font.family, font.height, swtStyle(font.style));
+    }
+
+    public static java.awt.Font awt(org.simantics.datatypes.literal.Font font) {
+        return new java.awt.Font(font.family, awtStyle(font.style), font.height);
+    }
+
+}