Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Draw2D Transparency
Draw2D Transparency [message #233493] Wed, 25 April 2007 21:53 Go to next message
Eclipse UserFriend
Originally posted by: asanh.ll.mit.edu

Hello,

I am implementing an RCP application. In an implementation of the RCP
ViewPart, I create a Canvas. I then draw an image on the Canvas (JPEG
loaded from an external file.). I would like to use a Draw2D Ellipse to
highlight a part of the image. So I tried to do the following after the
image is drawn in createPartControl():

LightweightSystem lws = new LightweightSystem(imageCanvas);
IFigure panel = new Figure();
lws.setContents(panel);

Shape ellipse = new Ellipse();
ellipse.setSize(20, 40);

panel.add(ellipse);
panel.setOpaque(false);

When I test the code, I get an area of grey with an ellipse, but I cannot
see my image. When I scroll the window, however, I can see my image
flickering beneath the area of grey with the ellipse. So the pieces are
all there. The Draw2D piece is just not transparent so that the image can
also be seen.

As I am new to RCP and SWT, I would appreciate some guidance as to what I
am doing incorrectly and what I should be doing instead.

Many thanks for your help.
Ai-Hoa Sanh
Re: Draw2D Transparency [message #233511 is a reply to message #233493] Wed, 25 April 2007 22:45 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

Would you like to have a draw2d figure to be transparent? Is that what
you're asking?
In this case you need to set the alpha for the graphics object when you
draw the figure. So, override IFigure#paint(Graphics graphics) and use
setAlpha(int) to set the alpha.
Hope this helps.

Cheers,
Alex

P.S. On Linux this setAlpha and any other advanced graphics stuff wouldn't
work
Re: Draw2D Transparency [message #233726 is a reply to message #233511] Tue, 01 May 2007 14:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: asanh.ll.mit.edu.

Sorry. I should provide more details.

I created the imageCanvas with SWT.NOBACKGROUND. I then rendered an image
on the canvas using GC.drawImage().

I now would like to overlay an ellipse on the image on the same canvas.

The behaviour I see is as if another canvas is created with my ellipse and
laid on top of the canvas with my image. I see my ellipse on a background
of gray. The image is not showing through. Only when I use the scroll bar
do I see the image repainting underneath the gray background. But when I
stop scrolling, the gray remains, and my image is no longer seen.

Thanks.
Ai-Hoa
Re: Draw2D Transparency [message #233734 is a reply to message #233726] Tue, 01 May 2007 15:44 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

The root figure created by the lightweight system is drawn in the canvas
control client area (visible area), hence it's drawn on top of the image
you draw on the canvas (this is my opinion anyway... didn't really used
draw2d outside of gef).
Try to do the following:
1) create an image figure which will be displaying your image =
BackgraoundFigure
2) set the contents of the lightweight system to be BackgroundFigure.
3) Add your Ellipse figure to the BackgroundFigure.
Hope this helps.

Cheers,
Alex
Re: Draw2D Transparency [message #233742 is a reply to message #233734] Tue, 01 May 2007 19:08 Go to previous message
Eclipse UserFriend
Originally posted by: asanh.ll.mit.edu.

Thank you so much! This did remove the "extra" canvas.

Ai-Hoa
Previous Topic:label figure
Next Topic:How to layout and repaint all EditParts?
Goto Forum:
  


Current Time: Fri Apr 26 12:56:56 GMT 2024

Powered by FUDForum. Page generated in 0.04769 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top