| SWT equivalent of AWT's getGraphics()? [message #375357] |
Sun, 12 October 2003 09:50  |
Eclipse User |
|
|
|
Hello all,
I am currently converting a routine written in AWT to SWT.
Here is the AWT snippet... (m_buffer is an Image)
public void paint(Graphics graphics)
{
Graphics myGraphics = m_buffer.getGraphics();
super.paint(myGraphics);
doWork(myGraphics);
graphics.drawImage(m_buffer, 0, 0, null);
}
I want to do the same thing in SWT (using draw2D)...
But, how do I get a "org.eclise.draw2d.Graphics" object from an
"org.eclipse.swt.graphics.Image" object?
I am not sure how to translate the "m_buffer.getGraphics()" portion...
Is there an SWT equivalent of AWT's getGraphics()?
Thx.
-M
|
|
|
|
|
| Re: SWT equivalent of AWT's getGraphics()? [message #375363 is a reply to message #375362] |
Sun, 12 October 2003 15:41   |
Eclipse User |
|
|
|
Murali wrote:
> I still am in the dark about getting a draw2d Graphics object for an SWT
> GC object.
I assume you have a draw2d project in your workspace.
Type Ctrl+Shift+T (or pick Navigate|Open Type... from the menu) and
"Gra*" and choose org.eclipse.draw2d.Graphics from the list. An editor
with the Graphics.java source will open. Oops, it's an abstract class,
we need to find the leafs of the inheritance tree. So press F4 on the
word Graphics. In the Hierachy Viewer to the left, some more classes
are displayed, "SWTGraphics" looks promissing. Double click it. Another
editor for SWTGraphics.java opens. In the Outline viewer to the right,
look for public constructors, that is entries marked with a green dot
and a tiny C attached. There's only one:
public SWTGraphics(GC gc) ...
Might work... let's verify whether this method is used somewhere in the
Draw2D/GEF code that looks similiar to what you want to achieve. Type
Ctrl+Shift+G (or pick Search|References|Workspace from the menu)... I
get three hits, the one in "org.eclipse.draw2d.BufferedGraphicsSource -
getGraphics(Rectangle)" seems to be the best.
Oh, see, it's the code you're looking for...
bye
--
Stefan Matthias Aust // "Ist es normal, nur weil alle es tun?" -F4
|
|
|
|
Powered by
FUDForum. Page generated in 0.05089 seconds