]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/preferences/DiagramPreferences.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / preferences / DiagramPreferences.java
index ac74e353d36f8306dd09b617ad9ca7722b06a38c..54fddebfca81061f1c86dd92d78c881679529571 100644 (file)
@@ -1,90 +1,90 @@
-/*******************************************************************************\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.modeling.ui.preferences;\r
-\r
-import java.util.Collections;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;\r
-import org.simantics.g2d.page.DiagramDesc;\r
-import org.simantics.utils.page.MarginUtils.Margin;\r
-import org.simantics.utils.page.MarginUtils.Margins;\r
-import org.simantics.utils.page.PageDesc;\r
-import org.simantics.utils.page.PageOrientation;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public final class DiagramPreferences {\r
-\r
-    public static final String             P_SNAP_GRID_SIZE           = "grid.size";\r
-    public static final String             P_DEFAULT_PAGE_SIZE        = "page.default.size";\r
-    public static final String             P_DISPLAY_PAGE_SIZE        = "page.display.size";\r
-    public static final String             P_DISPLAY_MARGINS          = "page.display.margins";\r
-    public static final String             P_DISPLAY_GRID             = "page.display.grid";\r
-    public static final String             P_DISPLAY_RULER            = "page.display.ruler";\r
-\r
-    public static final Margin             MARGIN_10MM                = new Margin(0, 0, 10);\r
-\r
-    public static final Double             DEFAULT_SNAP_GRID_SIZE     = 1.0;\r
-    public static final PageOrientation    DEFAULT_PAGE_ORIENTATION   = PageOrientation.Landscape;\r
-    public static final Margins            DEFAULT_PAGE_MARGINS       = new Margins(MARGIN_10MM, MARGIN_10MM, MARGIN_10MM, MARGIN_10MM);\r
-    public static final PageDesc           DEFAULT_PAGE_SIZE          = PageDesc.DEFAULT.withOrientation(DEFAULT_PAGE_ORIENTATION).withMargins(DEFAULT_PAGE_MARGINS);\r
-    public static final Boolean            DEFAULT_DISPLAY_PAGE_SIZE  = Boolean.TRUE;\r
-    public static final Boolean            DEFAULT_DISPLAY_MARGINS    = Boolean.TRUE;\r
-    public static final Boolean            DEFAULT_DISPLAY_GRID       = Boolean.FALSE;\r
-    public static final Boolean            DEFAULT_DISPLAY_RULER      = Boolean.FALSE;\r
-\r
-    public final IEclipsePreferences       preferences;\r
-\r
-    private final Map<String, Object>      map;\r
-\r
-    public DiagramPreferences(IEclipsePreferences preferences, Map<String, Object> map) {\r
-        this.preferences = preferences;\r
-        this.map = map;\r
-        if (map == null)\r
-            map = Collections.emptyMap();\r
-    }\r
-\r
-    public DiagramPreferences withValue(String preference, Object value) {\r
-        Map<String, Object> newMap = new HashMap<String, Object>(map);\r
-        newMap.put(preference, value);\r
-        return new DiagramPreferences(preferences, newMap);\r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    public <T> T get(String preference) {\r
-        T t = (T) map.get(preference);\r
-        if (t == null)\r
-            throw new IllegalStateException("no value for preference " + preference + " available");\r
-        return t;\r
-    }\r
-\r
-    public PageDesc getCompletePageDesc() {\r
-        PageDesc pd = get(P_DEFAULT_PAGE_SIZE);\r
-        return pd;\r
-//        PageOrientation po = get(P_DEFAULT_PAGE_ORIENTATION);\r
-//        Margins margins = get(P_DEFAULT_PAGE_MARGINS);\r
-//        return pd.withOrientation(po).withMargins(margins);\r
-    }\r
-\r
-    public DiagramDesc getDiagramDesc() {\r
-        double gridSize = get(DiagramPreferences.P_SNAP_GRID_SIZE);\r
-        boolean bordersVisible = get(DiagramPreferences.P_DISPLAY_PAGE_SIZE);\r
-        boolean marginsVisible = get(DiagramPreferences.P_DISPLAY_MARGINS);\r
-        boolean gridVisible = get(DiagramPreferences.P_DISPLAY_GRID);\r
-        boolean rulerVisible = get(DiagramPreferences.P_DISPLAY_RULER);\r
-        return new DiagramDesc(getCompletePageDesc(), gridSize, bordersVisible, marginsVisible, gridVisible, rulerVisible);\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
+ *******************************************************************************/
+package org.simantics.modeling.ui.preferences;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.simantics.g2d.page.DiagramDesc;
+import org.simantics.utils.page.MarginUtils.Margin;
+import org.simantics.utils.page.MarginUtils.Margins;
+import org.simantics.utils.page.PageDesc;
+import org.simantics.utils.page.PageOrientation;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public final class DiagramPreferences {
+
+    public static final String             P_SNAP_GRID_SIZE           = "grid.size";
+    public static final String             P_DEFAULT_PAGE_SIZE        = "page.default.size";
+    public static final String             P_DISPLAY_PAGE_SIZE        = "page.display.size";
+    public static final String             P_DISPLAY_MARGINS          = "page.display.margins";
+    public static final String             P_DISPLAY_GRID             = "page.display.grid";
+    public static final String             P_DISPLAY_RULER            = "page.display.ruler";
+
+    public static final Margin             MARGIN_10MM                = new Margin(0, 0, 10);
+
+    public static final Double             DEFAULT_SNAP_GRID_SIZE     = 1.0;
+    public static final PageOrientation    DEFAULT_PAGE_ORIENTATION   = PageOrientation.Landscape;
+    public static final Margins            DEFAULT_PAGE_MARGINS       = new Margins(MARGIN_10MM, MARGIN_10MM, MARGIN_10MM, MARGIN_10MM);
+    public static final PageDesc           DEFAULT_PAGE_SIZE          = PageDesc.DEFAULT.withOrientation(DEFAULT_PAGE_ORIENTATION).withMargins(DEFAULT_PAGE_MARGINS);
+    public static final Boolean            DEFAULT_DISPLAY_PAGE_SIZE  = Boolean.TRUE;
+    public static final Boolean            DEFAULT_DISPLAY_MARGINS    = Boolean.TRUE;
+    public static final Boolean            DEFAULT_DISPLAY_GRID       = Boolean.FALSE;
+    public static final Boolean            DEFAULT_DISPLAY_RULER      = Boolean.FALSE;
+
+    public final IEclipsePreferences       preferences;
+
+    private final Map<String, Object>      map;
+
+    public DiagramPreferences(IEclipsePreferences preferences, Map<String, Object> map) {
+        this.preferences = preferences;
+        this.map = map;
+        if (map == null)
+            map = Collections.emptyMap();
+    }
+
+    public DiagramPreferences withValue(String preference, Object value) {
+        Map<String, Object> newMap = new HashMap<String, Object>(map);
+        newMap.put(preference, value);
+        return new DiagramPreferences(preferences, newMap);
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> T get(String preference) {
+        T t = (T) map.get(preference);
+        if (t == null)
+            throw new IllegalStateException("no value for preference " + preference + " available");
+        return t;
+    }
+
+    public PageDesc getCompletePageDesc() {
+        PageDesc pd = get(P_DEFAULT_PAGE_SIZE);
+        return pd;
+//        PageOrientation po = get(P_DEFAULT_PAGE_ORIENTATION);
+//        Margins margins = get(P_DEFAULT_PAGE_MARGINS);
+//        return pd.withOrientation(po).withMargins(margins);
+    }
+
+    public DiagramDesc getDiagramDesc() {
+        double gridSize = get(DiagramPreferences.P_SNAP_GRID_SIZE);
+        boolean bordersVisible = get(DiagramPreferences.P_DISPLAY_PAGE_SIZE);
+        boolean marginsVisible = get(DiagramPreferences.P_DISPLAY_MARGINS);
+        boolean gridVisible = get(DiagramPreferences.P_DISPLAY_GRID);
+        boolean rulerVisible = get(DiagramPreferences.P_DISPLAY_RULER);
+        return new DiagramDesc(getCompletePageDesc(), gridSize, bordersVisible, marginsVisible, gridVisible, rulerVisible);
+    }
+
+}