\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
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
* @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
* @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
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
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
@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
*/\r
private class DefaultColorSelectionFactory extends ReadFactoryImpl<Resource, Boolean> {\r
\r
- private Boolean isCustom;\r
+ private final Boolean isCustom;\r
\r
/**\r
* \r