Anti-aliasing in JGoSWT

How to turn on Anti-aliasing in JGoSWT5.1? I am using SWT 3.1.

You need to add a few lines of code in JGoView.java and Graphics2D.java.
In JGoView.paintControl, add the statement:
evt.gc.setAdvanced(true);
just before the statement:
Graphics2D g2 = myGraphics;
And in the method JGoView.applyRenderingHints, add the statements:
g2.GC.setAntialias(SWT.ON);
g2.GC.setInterpolation(SWT.HIGH);
g2.GC.setTextAntialias(SWT.OFF);
Finally, in the Graphics2D constructor, call:
gc.setAdvanced(true);
The next release of JGo (5.2) will require SWT 3.1 and will include this code.

it worked well, thanks! but when i turn anti-alias on, it has huge impact on performance. The node seems to stick for seconds being dragging around.

Try using SWT 3.2, and see if the performance is better.
Actually, the beta for JGo 5.2 requires SWT 3.2. In 5.2 you’ll just need to override JGoView.applyRenderingHints if you want to change the drawing behavior.

I have v5.21 installed with SWT3.2 and notice that there is a slow down when moving a node around.

Is there anyway I can avoid this?

dWiGhT

Just comparing performance of the Demo1 sample in both JGoSWT 5.1 (with SWT 3.0) and JGoSWT 5.2 (with SWT 3.2), I find that they are about equally responsive. And that’s with anti-aliased lines in 5.2/3.2.

However, Demo1 doesn't draw anti-aliased text, so I suppose that could slow things down. But I wouldn't expect it to be significant. If you change your application to draw non-anti-aliased text, is it faster?

I’m getting a pretty significant hit when I have anti aliasing enabled.

How would I disable the text anti-aliasing???

dWiGhT

Override JGoView.applyRenderingHints. Just copy and adapt the code that is in JGoView.java.

I figured out what is causing the massive slowdown… I have a background image set on my JGoView:

// Set up the background image... wash it out
ImageData bgWaterMark = new ImageData(VPPCApp.class.getResourceAsStream("CSLogo.png"));
bgWaterMark.alpha = 96;
Image bgImage = new Image(myView.getDisplay(), bgWaterMark);
myView.setBackgroundImage(bgImage);

…comment out this code and I get a very speedy response from my app. With it in it is very slow.

Is there a way around this???

dWiGhT

I don’t know – JGoView.paintBackgroundDecoration is just drawing the image, which is implemented directly by a call to GC.drawImage.

How large is the image? Does setting the alpha to be translucent cause the slowdown? Does the PNG image itself contain translucent pixels?

Think I found the issue.

bgWaterMark.alpha = 96;

commenting this out returns the app to it’s speedy self again…

dWiGhT