Search code examples
eclipse-plugineclipse-rcpeclipse-gefdraw2d

How to set background color of an image using draw2d?


I have drawn one rectangle by using RectangleFigure in draw2d. And I am able to color the rectangle figure by calling rectangleFigure.setBackgroundColor. Now the same way I want to color the Image also. For that I used ImageFigure in draw2d and I gave the background color by calling ImageFigure.setBackgroundColor(). But it does not give any color for me. So How can I give the background color to the image figure in draw2d?


Solution

  • RectangleFigure extends Shape which draws it's own background by default. ImageFigure directly extends Figure which will only draw the background if you set it as Opaque:

    imageFigure.setOpaque(true);