[Blindmath] Using Java Draw2D in an SWT GUI

Michael Whapples mwhapples at aim.com
Thu Feb 23 08:59:27 UTC 2012


Regarding your question on how good or bad is the JAB. Personally I like the 
concept of the JAB from a development view, one full accessibility API 
across all platforms, rather than one which maps to the native ones and so 
has to cope with the differences of different platforms.

However in practice as a user things seem to be simpler for SWT than Java 
swing and JAB. I had some trouble getting the JAB working on a windows 7 
64-bit system, not sure precisely what the issue was but the JAB only seemed 
to start working once I installed the 32-bit JVM, previously I only had the 
64-bit JVM installed. If the JAB does require the 32-bit JVM as well as the 
64-bit JVM then all I can say is this fact is not documented anywhere. Even 
once the JAB is working the quality of accessibility can differ between 
platforms, Linux I probably would give the best rating, on windows you can 
even notice some issues with relatively simple applications such as MathTrax 
and on the Mac there are definitely issues (eg. the file dialog for things 
like opening and saving files has issues on the Mac).

In comparison SWT applications and certainly more sizable ones such as 
eclipse tend to just work straight out of the box. This is not to say their 
always perfect but eclipse is mostly accessible and certainly most of its 
functionality can be used by a blind user.

Regarding your comment on reuse, may be accessibility is an example of what 
you say. By reusing the native OS controls SWT picks up the accessibility of 
those and the screen readers need not support another accessibility API as 
they do for swing.

I think though Richard's comments on reuse related more to do with non-UI 
parts of eclipse RCP/SWT and how they just don't work with normal standard 
JDK implementations. I think image objects were an example of this. May be 
there is advantages to the Eclipse project versions not found in the 
standard JDK classes.

Michael Whapples

-----Original Message----- 
From: Carolyn MacLeod
Sent: Thursday, February 23, 2012 5:04 AM
To: Blind Math list for those interested in mathematics
Subject: Re: [Blindmath] Using Java Draw2D in an SWT GUI

Hi again.

Sorry to take so long to reply.

JFrame is not an embeddable component, so SWT (or any other embeddor)
can't embed JFrames.
SWT_AWT.new_Frame() returns a subclass of EmbeddedFrame, which is a
sibling of JFrame but it does not have a root pane.
JApplet is embeddable and it has a root pane. Can you make do with a
JApplet instead of a JFrame?

I wrote another snippet for you (attached) that takes the root pane out of
a JFrame and sets it into a JApplet in an SWT GUI.
Hopefully you could do something similar with a JFrame from your
textbook's sample code.
But this won't solve the whole problem, because the Swing controls from
the JFrame still won't be accessible unless you have the JAB installed and
use an AT that works with it.
(Question for you: Are Swing controls really that inaccessible? Is the JAB
hard to install? Don't AT usually work once the JAB is installed? I don't
know because I don't use Swing.)

Regarding event integration, this article might be helpful:
http://www.eclipse.org/articles/Article-Swing-SWT-Integration/index.html
The rule of thumb is to use SwingUtilities.invokeLater() and
Display.asyncExec() to pass work from AWT/Swing to SWT and vice-versa.
This article also discusses the tab traversal "glitch" that I tripped over
in the snippet I sent you earlier, and they show how to fix it in their
example code.

> I really do believe in the OOP concept of "reuse, don't reinvent,"
So do we, which is why we reused the OS controls instead of drawing our
own.  :)
We did talk about this with Sun in the beginning, but unfortunately it
didn't work out.

Also, I happened to trip over these other two snippets that manipulate
BufferedImage and JAI TiledImage from within SWT.
I am including them here in case they are helpful:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=119363#c13
https://bugs.eclipse.org/bugs/show_bug.cgi?id=119363#c14

Hope this helps,
Carolyn







From:
Richard Baldwin <baldwin at dickbaldwin.com>
To:
Blind Math list for those interested in mathematics <blindmath at nfbnet.org>
Date:
01/31/2012 01:30 PM
Subject:
Re: [Blindmath] Using Java Draw2D in an SWT GUI
Sent by:
blindmath-bounces at nfbnet.org



Thanks for responding to my concerns. I will definitely take a look at
your
workabound and see how much it helps. Hopefully, I will be pleased with
the
results.

I suspect, however, that simply providing compatibility at the AWT Canvas
level won't help much with my main concern. I already knew of one way to
do
that. I also already knew how to embed AWT Frame objects in an SWT object.
Unfortunately, I don't know how to easily integrate events fired by those
AWT components into the SWT event handling system and I don't know how to
embed Swing JFrame objects and/or their events in SWT objects.

I know how to write new code that will play reasonably well with SWT. That
isn't my main concern. I really do believe in the OOP concept of "reuse,
don't reinvent," and my main concern is the lack of compatibility of SWT
with existing unmodified graphics libraries, which typically produce
graphic outputs in Swing JFrame objects. Until we can successfully embed
JFrame objects in SWT objects, and until we can easily integrate the event
handling mechanisms of the two systems, the use of those libraries without
modification of the libraries will probably be very difficult at best and
off limits at worst.

Hopefully someone will prove me wrong on this.

Dick Baldwin

On Tue, Jan 31, 2012 at 11:03 AM, Carolyn MacLeod <
Carolyn_MacLeod at ca.ibm.com> wrote:

> Thank-you, Michael!
> Carolyn
>
>
>
> From:
> "Michael Whapples" <mwhapples at aim.com>
> To:
> "Blind Math list for those interested in mathematics"
> <blindmath at nfbnet.org>
> Date:
> 31/01/2012 11:30 AM
> Subject:
> Re: [Blindmath] Using Java Draw2D in an SWT GUI
> Sent by:
> blindmath-bounces at nfbnet.org
>
>
>
> Hello,
> Thanks for taking the time to do this. I know you have asked questions
on
> the orca-list about improving accessibility in SWT and eclipse and its
> certainly appreciated. In my oppinion SWT is one of the few, if not the
> best, GUI toolkits for making accessible applications which are also
> cross-platform.
>
> Regards
>
> Michael whapples
>
> -----Original Message-----
> From: Carolyn MacLeod
> Sent: Tuesday, January 31, 2012 4:09 PM
> To: blindmath at nfbnet.org
> Subject: [Blindmath] Using Java Draw2D in an SWT GUI
>
> Hello, list.
>
> My name is Carolyn and I am on the Eclipse SWT Team.
> I am the developer responsible for SWT Accessibility.
>
> Ken Perry of Blinksoft asked me if I could help with an issue brought up
> by Richard Baldwin regarding SWT being accessible but largely
incompatible
> with Swing/AWT.
> I read several posts similar to this one:
>
>
http://host.nfbnet.org/pipermail/blindmath_nfbnet.org/2012-January/004693.html

>
>
> I wrote an SWT Snippet that I hope you will find useful:
>
>
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet361.java

>
> It shows how to host an AWT Canvas inside an SWT GUI, and use the GUI to
> initiate Java2D operations within the Canvas.
> I randomly chose rotation and translation of the image, but you should
be
> able to modify the snippet to do whatever Java2D operations you are
> teaching.
> The "Print Image" button uses SWT to take a screen snapshot of the
Canvas
> and print it to a printer.
> I had not heard of a printer that embosses images before, and I think
that
> is really cool!
>
> I tried this snippet on Windows (XP) with JAWS (13) and on Mac OSX
> (Leopard) with VoiceOver, and on Linux (Ubuntu 10.04) with Orca and it
> worked on all 3 platforms.
> It should work with other platform versions and screen readers as well.
> The only glitch I encountered was on Windows, if the user tabs into the
> Canvas, they can't tab back out.
> They need to use the button mnemonics to traverse out of the Canvas:
alt+o
> for Open, alt+x and alt+y for translating X and Y, alt+r for Rotate, and
> alt+p for Print.
> This was not an issue on Mac or Linux.
>
> I cannot solve the deeper issues, like making SWT and AWT graphics
> interchangeable without performance penalties (there are technical
> issues),
> or improving SWT's graphics support to the level of Java2D or more (we
are
> a very small and very busy team, and we simply do not have the
manpower).
> Hopefully this snippet will give you a work-around that is both
accessible
> and teaches the math you want to teach.
>
> Carolyn
> _______________________________________________
> Blindmath mailing list
> Blindmath at nfbnet.org
> http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
> To unsubscribe, change your list options or get your account info for
> Blindmath:
>
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/mwhapples%40aim.com
>
>
>
> _______________________________________________
> Blindmath mailing list
> Blindmath at nfbnet.org
> http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
> To unsubscribe, change your list options or get your account info for
> Blindmath:
>
>
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/carolyn_macleod%40ca.ibm.com

>
>
>
>
> _______________________________________________
> Blindmath mailing list
> Blindmath at nfbnet.org
> http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
> To unsubscribe, change your list options or get your account info for
> Blindmath:
>
>
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/baldwin%40dickbaldwin.com

>



-- 
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 at DickBaldwin.com
http://www.austincc.edu/baldwin/
_______________________________________________
Blindmath mailing list
Blindmath at nfbnet.org
http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
To unsubscribe, change your list options or get your account info for
Blindmath:
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/carolyn_macleod%40ca.ibm.com










_______________________________________________
Blindmath mailing list
Blindmath at nfbnet.org
http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
To unsubscribe, change your list options or get your account info for 
Blindmath:
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/mwhapples%40aim.com 





More information about the BlindMath mailing list