A big warning to everyone that will
be using gc.setAlphas() or draw2D.Graphics.setAlphas() or any of the new
gc functions that require the advanced graphics. You must be able to check
or handle advanced not being available. If you don't and just go ahead
and set alphas an exception will be thrown. It is not very graceful.
So if you are using swt.GC then you
need to do this before you do the setAlphas():
gc.setAdvanced(true);
if (gc.getAdvanced()) {
... it is good, go do you stuff
with the alphas...
} else {
... it is not good, you need
to do some alternative that doesn't have alphas ...
}
If you are using draw2D.Graphics, it
is harder because you don't have access to setAdvanced/getAdvanced:
try {
graphics.setAlpha();
...
} catch (SWTException e) {
... you don't have advanced
available, you need to do some alternative that doesn't have alphas ...
}
I know this is pain, but if not done
you get the SWTException thrown and this is normally not caught.
We do have two bugs open, one against
swt such that you can just do gc.getAdvanced() without doing the gc.setAdvanced(true)
first, and the other against GEF to add an API to Graphics to return whether
advanced is available or not.