Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318900

Summary: [GC] Image class doesn't implement Drawable
Product: [RT] RAP Reporter: Mirko Solazzi <mirkosol>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: bugs.eclipse.org, eclipse, marco, mirkosol, mknauer, ruediger.herrmann, steeg, steffen.kriese
Version: 1.3   
Target Milestone: 3.14 M1   
Hardware: PC   
OS: All   
See Also: https://git.eclipse.org/r/c/rap/org.eclipse.rap/+/165695
https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=a8f4ce1c2f4fb282ac90bc3d81026298ff4a34bf
Whiteboard:
Bug Depends on: 334637    
Bug Blocks:    

Description Mirko Solazzi CLA 2010-07-05 10:35:20 EDT
Build Identifier: 

Cannot create new image in memory with RWT because the GC requires a Drawable widget and the Image class doens't implement the org.eclipse.swt.graphics.Drawable class.  

Moreover the constructor:
  Image(org.eclipse.swt.graphics.Device device, int width, int height)

should be public in the Image class like in SWT.



Reproducible: Always
Comment 1 Mirko Solazzi CLA 2010-09-05 09:31:32 EDT
I think it is very important adding the Image creation feature on RAP.   
For example if I need to create a captcha image for user registration, or if I need to create a graphic (static image) without drawing on the canvas.      
It is sufficient to make the Image class "Drawable" and extend GC class method:   the behaviour remains the same for instances of "Control" type while for "Image" instances you should implement the graphical operations on server memory, modifying the ImageData pixels [before saving it into a resource file] or using the native SO graphical operations inside the additional server display (X-Window) like the standard SWT does.
I do it in my web applications, by importing the original SWT package (I take the native libraries, depending on the server SO where the application server runs) and by creating images with a servlet.  I cannot do the same with RAP because it overrides the SWT Image/GC classes.


The missed constructor:
 Image(Device device, int width, int height)

can be implemented as:

  public Image(org.eclipse.swt.graphics.Device device, int width, int height) {
  	 super( checkDevice( device ) );
  	 Color white = device.getSystemColor(SWT.COLOR_WHITE);
  	 PaletteData palette = new PaletteData(0xFF0000, 0x00FF00, 0x0000FF);	
  	 ImageData imageData = new ImageData( width, height, 24 , palette );
  	    for (int i = 0; i < width; i++) { 
  	      for (int j = 0; j < height; j++) { 
  	      	imageData.setPixel(i,j,white.getRGB().hashCode());
  	      }
  	    }
  	 imageData.type=SWT.IMAGE_PNG;
      init( imageData );
  }
Comment 2 Ralf Sternberg CLA 2011-01-22 11:10:36 EST
*** Bug 334627 has been marked as a duplicate of this bug. ***
Comment 3 Michael Fritscher CLA 2015-12-16 03:55:55 EST
Are there any news? :-)

I try to port nebula.xygraph, which depends on it. Or is there any other way to get around this problem?
Comment 4 Marco Descher CLA 2020-04-15 03:00:48 EDT
Please see https://github.com/col-panic/eclipse-rap-nebula/tree/master
Comment 5 Michael Fritscher CLA 2020-04-15 03:40:35 EDT
What is the difference between your draw2d and the version in https://git.eclipse.org/c/rap/incubator/org.eclipse.rap.incubator.gef.git/about/ ?

Btw, it would be very nice to get a draw2d version in upstream RAP :-)
Comment 6 Marco Descher CLA 2020-04-15 03:47:07 EDT
(In reply to Michael Fritscher from comment #5)
> What is the difference between your draw2d and the version in
> https://git.eclipse.org/c/rap/incubator/org.eclipse.rap.incubator.gef.git/
> about/ ?
> 
> Btw, it would be very nice to get a draw2d version in upstream RAP :-)

?! If this question is addressed to my project - please open an issue for discussion on github - as not to distort this bugs discussion! :)
Comment 7 Michael Fritscher CLA 2020-04-15 03:57:19 EDT
Yes, it was addressed to your project - but it seems that you ripped off most things.

It would be nice if you could upstream one or another improvement ;-)
Comment 8 Marco Descher CLA 2020-04-15 08:16:30 EDT
Yep - ripped of most things - as I want to have this as an isolated development case. Fixing it might pave the way for some bigger ports of Nebula.

What is the specific reason that Image does not implement Drawable? This seems to simply be a marker interface?!
Comment 9 Eclipse Genie CLA 2020-07-01 10:02:40 EDT
New Gerrit change created: https://git.eclipse.org/r/c/rap/org.eclipse.rap/+/165695
Comment 11 Markus Knauer CLA 2020-07-01 10:24:18 EDT
(In reply to Marco Descher from comment #8)
> What is the specific reason that Image does not implement Drawable? This
> seems to simply be a marker interface?!

Yeah, I wasn't able to find a good reason why it shouldn't implement Drawable, and added the marker interface just now.