[program-java] Re: Converting java.awt.Graphics2D graphics to an SWT Display format

  • From: Willem Venter <dwillemv@xxxxxxxxx>
  • To: program-java@xxxxxxxxxxxxx
  • Date: Fri, 6 Jan 2012 22:54:37 +0200

Ah sorry I see I've missread your message, I thought you said swt was
not accessible, not awt.

On 1/6/12, Willem Venter <dwillemv@xxxxxxxxx> wrote:
> Hello.
> As far as I know eclipse is written in swt and it is mostly
> accessible. Which parts of swt is inaccessible? As you can probably
> deduce I don't know much about swt, so excuse my ignorance.
>
> On 12/31/11, Richard Baldwin <baldwin@xxxxxxxxxxxxxxx> wrote:
>> Thousands of programs and several complete libraries have been published
>> that use Sun's java.awt.Graphics2D class for the creation of graphic
>> information. I am personally responsible for publishing a few hundred of
>> those programs myself.
>>
>> For reasons of accessibility, I am now programming using the SWT. I am
>> searching for a relatively painless way to convert programs that have
>> been
>> developed using Sun's java.awt.Graphics2D class to a display format that
>> can be used with SWT.
>>
>> ALTERNATIVE #1
>> On the Sun Java side, I can create an off-screen image of type
>> java.awt.Image and use any of the methods of the class named
>> java.awt.Graphics2D to draw or otherwise deposit pictures onto the Image
>> object. Normally then, I would call the drawImage method of the
>> Graphics2D
>> class in an overridden paint method to draw that image onto a
>> java.awt.Canvas object for display in a java.awt.Frame or
>> javax.swing.JFrame object.
>>
>> On the SWT Java side, apparently if I have an
>> org.eclipse.swt.graphics.Image object, I can call the drawImage method of
>> the GC class to display that image in a manner that is acceptable to SWT
>> with no requirement for a java.awt.Frame object or a javax.swing.JFrame
>> object.
>>
>> Question: How can I transfer the image from a java.awt.Image object to an
>> org.eclipse.swt.graphics.Image object? A single method that receives
>> references to one object of each type and makes the transfer would be
>> very
>> useful.
>>
>> OTHER ALTERNATIVES
>> Question: Other than using code such as the following, does anyone know
>> of
>> a relatively painless way to convert programs that have been developed
>> using Sun's Graphics2D class to a display format that can be used with
>> SWT.
>>
>>     Composite comp =  new Composite(drawingShell,SWT.EMBEDDED);
>>     java.awt.Frame frame = SWT_AWT.new_Frame(comp);
>>
>> In other words, how can I take advantage of Sun's Graphics2D API without
>> including a java.awt.Frame object in my SWT program?
>>
>> Thanks,
>> Dick Baldwin
>>
>> --
>> Richard G. Baldwin (Dick Baldwin)
>> Home of Baldwin's on-line Java Tutorials
>> http://www.DickBaldwin.com
>>
>> Professor of Computer Information Technology
>> Austin Community College
>> (512) 223-4758
>> mailto:Baldwin@xxxxxxxxxxxxxxx
>> http://www.austincc.edu/baldwin/
>>
>

Other related posts: