]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemImageRule.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / ui / ChartItemImageRule.java
index 2b790f5bcaa2449bee4d067bd8aa518b38bb37ae..eb5a8d0703eeafbbe5ba7f5bddb52a6ab879a68f 100644 (file)
@@ -1,67 +1,67 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.charts.ui;\r
-\r
-import java.awt.Color;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.browsing.ui.model.images.ImageRule;\r
-import org.simantics.charts.ontology.ChartResource;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.stubs.G2DResource;\r
-import org.simantics.trend.impl.JarisPaints;\r
-import org.simantics.utils.datastructures.ArrayMap;\r
-\r
-public enum ChartItemImageRule implements ImageRule {\r
-\r
-    INSTANCE;\r
-    public static ChartItemImageRule get() { return INSTANCE; }\r
-\r
-    public static final String COLUMN_KEY         = "single";\r
-    public static final String[] COLUMN_KEYS      = { COLUMN_KEY };\r
-\r
-    ChartItemIcon chartIcons = new ChartItemIcon();\r
-\r
-    @Override\r
-    public boolean isCompatible(Class<?> contentType) {\r
-        return contentType.equals(Resource.class);\r
-    }\r
-\r
-    @Override\r
-    public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {\r
-        Resource item = (Resource) content;\r
-        ChartResource CHART = ChartResource.getInstance(graph);\r
-        G2DResource G2D = G2DResource.getInstance(graph);\r
-\r
-        Color color = null;\r
-        float[] customColor = graph.getPossibleRelatedValue(item, G2D.HasColor, Bindings.FLOAT_ARRAY);\r
-        if (customColor != null && customColor.length >= 3)\r
-            color = new Color(customColor[0], customColor[1], customColor[2]);\r
-        if (color == null) {\r
-            Integer index = graph.getPossibleRelatedValue(item, CHART.Chart_Item_Index);\r
-            if ( index == null ) index = 1;\r
-            color = JarisPaints.getColor( index );\r
-        }\r
-\r
-        Resource rend = graph.getPossibleObject(item, CHART.Chart_Item_Renderer);\r
-        boolean binary = CHART.Renderer_Binary.equals(rend); \r
-\r
-        ImageDescriptor icon = chartIcons.createIcon(!binary, color, false);\r
-\r
-        return ArrayMap.make(COLUMN_KEYS, new ImageDescriptor[] { icon });\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.charts.ui;
+
+import java.awt.Color;
+import java.util.Map;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.simantics.browsing.ui.model.images.ImageRule;
+import org.simantics.charts.ontology.ChartResource;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.stubs.G2DResource;
+import org.simantics.trend.impl.JarisPaints;
+import org.simantics.utils.datastructures.ArrayMap;
+
+public enum ChartItemImageRule implements ImageRule {
+
+    INSTANCE;
+    public static ChartItemImageRule get() { return INSTANCE; }
+
+    public static final String COLUMN_KEY         = "single";
+    public static final String[] COLUMN_KEYS      = { COLUMN_KEY };
+
+    ChartItemIcon chartIcons = new ChartItemIcon();
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return contentType.equals(Resource.class);
+    }
+
+    @Override
+    public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
+        Resource item = (Resource) content;
+        ChartResource CHART = ChartResource.getInstance(graph);
+        G2DResource G2D = G2DResource.getInstance(graph);
+
+        Color color = null;
+        float[] customColor = graph.getPossibleRelatedValue(item, G2D.HasColor, Bindings.FLOAT_ARRAY);
+        if (customColor != null && customColor.length >= 3)
+            color = new Color(customColor[0], customColor[1], customColor[2]);
+        if (color == null) {
+            Integer index = graph.getPossibleRelatedValue(item, CHART.Chart_Item_Index);
+            if ( index == null ) index = 1;
+            color = JarisPaints.getColor( index );
+        }
+
+        Resource rend = graph.getPossibleObject(item, CHART.Chart_Item_Renderer);
+        boolean binary = CHART.Renderer_Binary.equals(rend); 
+
+        ImageDescriptor icon = chartIcons.createIcon(!binary, color, false);
+
+        return ArrayMap.make(COLUMN_KEYS, new ImageDescriptor[] { icon });
+    }
+
+}