]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fix for ColorPicker, this is only to clear errors, not to restore the desired functio...
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 3 Apr 2013 08:52:30 +0000 (08:52 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 3 Apr 2013 08:52:30 +0000 (08:52 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27236 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/ColorPicker.java

index 2901c2700a9b9096a95d1171180d00712dcfd2ef..c51a8feb6aed0a8659fcd511ccbc11e49b50918b 100644 (file)
@@ -13,12 +13,10 @@ package org.simantics.jfreechart.chart.properties;
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.graphics.Device;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
 import org.eclipse.swt.graphics.Point;\r
 import org.eclipse.swt.graphics.RGB;\r
 import org.eclipse.swt.widgets.ColorDialog;\r
@@ -44,6 +42,7 @@ import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.utils.RunnableWithObject;\r
 import org.simantics.utils.datastructures.Triple;\r
+import org.simantics.utils.ui.gfx.ColorImageDescriptor;\r
 \r
 /**\r
  * Composite for selecting a color for a chart component\r
@@ -165,12 +164,12 @@ public class ColorPicker extends Composite implements Widget {
      * @param blue Blue 0-255\r
      * @return\r
      */\r
-    private Image getColorPickerImage(Device device, int red, int green, int blue) {\r
-        Image image = new Image(device, 20, 20);\r
-        GC gc = new GC (image);\r
-        gc.setBackground (new Color(device, red, green, blue));\r
-        gc.fillRectangle (image.getBounds ());\r
-        gc.dispose ();\r
+    private ImageDescriptor getColorPickerImage(Device device, int red, int green, int blue) {\r
+        ImageDescriptor image = new ColorImageDescriptor(red, green, blue, 20, 20, true);\r
+        //GC gc = new GC (image);\r
+        //gc.setBackground (new Color(device, red, green, blue));\r
+        //gc.fillRectangle (image.getBounds ());\r
+        //gc.dispose ();\r
         return image;\r
     }\r
 \r
@@ -179,7 +178,7 @@ public class ColorPicker extends Composite implements Widget {
      * @author Teemu Lempinen\r
      *\r
      */\r
-    private class ColorImageFactoryFactory extends ReadFactoryImpl<Resource, Image> {\r
+    private class ColorImageFactoryFactory extends ReadFactoryImpl<Resource, ImageDescriptor> {\r
         \r
         Button button;\r
         \r
@@ -188,12 +187,13 @@ public class ColorPicker extends Composite implements Widget {
             this.button = button;\r
         }\r
         \r
+        @Override\r
         public Object getIdentity(Object inputContents) {\r
             return new Triple<Object, Class<?>, Button>(inputContents, getClass(), button);\r
         }\r
 \r
         @Override\r
-        public Image perform(ReadGraph graph, Resource input) throws DatabaseException {\r
+        public ImageDescriptor perform(ReadGraph graph, Resource input) throws DatabaseException {\r
             if(button.getWidget().isDisposed())\r
                 return null;\r
             Display device = button.getWidget().getDisplay();\r
@@ -263,6 +263,7 @@ public class ColorPicker extends Composite implements Widget {
             final RGB oldRGB = getColor(graph, resource);\r
             \r
             display.asyncExec(new RunnableWithObject(oldRGB) {\r
+                @Override\r
                 public void run() {\r
                     // Use color dialog to select a color\r
                     Shell shell = new Shell(display);\r
@@ -280,7 +281,7 @@ public class ColorPicker extends Composite implements Widget {
                         @Override\r
                         public void perform(WriteGraph graph) throws DatabaseException {\r
                             G2DResource g2d = G2DResource.getInstance(graph);\r
-                            float[] components = new float[] {(float)rgb.red / 255.0f,  (float)rgb.green / 255.0f, (float)rgb.blue / 255.0f, 1.0f};\r
+                            float[] components = new float[] {rgb.red / 255.0f,  rgb.green / 255.0f, rgb.blue / 255.0f, 1.0f};\r
                             graph.claimLiteral(resource, getColorRelation(graph), g2d.Color, components);                            \r
                         }\r
                     });\r
@@ -301,7 +302,7 @@ public class ColorPicker extends Composite implements Widget {
      */\r
     private class DefaultColorSelectionFactory extends ReadFactoryImpl<Resource, Boolean> {\r
 \r
-        private Boolean isCustom;\r
+        private final Boolean isCustom;\r
 \r
         /**\r
          * \r