Skip to main content

Netbeans and ClearType (b39)

25 replies [Last post]
tlund_
Offline
Joined: 2005-04-21

Just tried the new build 39 with Netbeans 4.1. Finally we have sub-pixel antialiasing in Java, and it's looking very good. But, it doesn't seem to be working in all parts of the Netbeans IDE. The menu section (file/edit/view etc) is rendered with ClearType, but not the editor. The dropdownlist in "Navigator" is rendered with ClearType, but not the rest of the navigator window. etc..

Why is this? I should probably be asking the netbeans team instead, but I just wanted you to know.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rupakrathore
Offline
Joined: 2003-12-08

> > (I don't know if there is a way to know for a fact
> that one is on CRT, especially in a portable way,
> though)
>
> Unfortunately there's no way to find out if you're
> displaying to a CRT or LCD monitor (not even on
> windows), so we're relying on whatever user set in
> the desktop preference dialog.

Well, I'm nowhere close to understanding this discussion, but IMO, can't java use EDID info from monitor to determine (or guess) whether it is a CRT or LCD. Probably from the display type or otherwise guessing from screen size vs display size ratios or guessing from modelines.

tb
Offline
Joined: 2005-04-05

Is there some way to enable AA under linux? I'am currently using mandrake 10.2 + netbean 4.1 + mustang b39 ...

Thomas

selendic1
Offline
Joined: 2004-04-27

>Is there some way to enable AA under linux? I'am currently using mandrake 10.2 + netbean 4.1 + mustang b39 ...

Of course it is possible on Linux, however you are probably running KDE, and Sun decided to remove command line switch (unsupported) -Dswing.aatext=true, which was used to enable AA globally in Swing when launching apps from command prompt.

However, in Gnome, Java automagically picks Gnome default settings (and can even do it on the fly, if you are changing something while your Swing app is running) and when running Gnome on Linux (also on Windows XP), and if Gnome font settings are set properly, you get your antialiasing in its all subpixel glory just by starting a Swing app.

Another way to enable it, of course, is by using new API's (rendering hints) in your programs.

I hope Sun will give us back command line switch for experimenting in some later build.

selendic1
Offline
Joined: 2004-04-27

@ Trembovetski

Not a big fan of subpixel AA, heh? I surely don't need a magnifying glass to see if subpixel AA is on, probably because I use (rather cheap) big LCD monitors all the time. Fonts on LCD look much sharper (especially smaller size fonts, and rounded letters like O,C,g,b...) and with a just a little pieces of colour here and there if one looks very closely. Suns implementation works actually fast like hell, much faster than I expected, however, it does have a bit too much colour in it, which makes things a bit fuzzy, and makes me a bit dizzy. From what i've seen, Suns implementation doesn't take what Gnome calls rendering hints into account (none, slight, full from what I can recall) and it seems to me Swing always looks like Gnome on "none" rendering hints option (thus fuzzy). I might be wrong on that one. But I'm sure that when moving windows, Suns subpixel AA has a very noticeable shift to red (fonts appear redish), which also bring more fuzzyness and dizzyness.

@ gfx

I know that swing.aatext is unsupported, and I've looked at the source to understand how AA is enabled in b39, but I think that approach with simple command line switch was actually a great one, especially for experimenting, and plenty of people use KDE or some other-than-gnome Desktops/WM's, hell, it even looked cool on my mom's Win '98!

There is another bigger problem with automatic decision that Java makes about a type of Antialiasing. I think that Windows XP machine somehow knows that it is on CRT monitor, and it pushes plain monochrome AA even though ClearType is selected. Swing on the other hand detects ClearyType and goes with subpixel AA, which doesn't look that good on CRT monitors (subpixel rendered fonts look to light, with some parts kind of missing when displayed on CRT). It could be just my impression, but if I'm right, I hope that will be corrected before final release.

Oh, and yes, thank you guys, for listening and giving us this great feature (although I know Trembovetski is probably mad as hell because of time lost on this when something more usefull could be done with accellerated Java2D pipelines).

Btw. d3d is working almost perfectly on one of my crappy machines (Pentium 3, 800 Mhz) in this release, with just a few strange problems (strange slowness at the begining, and then suddenly it flyes, one crash, and one Nullpointer exception, will post proper Bug report when done with more testing), keep up a great work mr. Trembovetski!

trembovetski
Offline
Joined: 2003-12-31

@selendic1

Thanks for your detailed feedback! Please file those bugs on the D3D pipeline!

Note that using LCD-aa text with the D3D pipeline won't get you the best performance, as LCD-AA text is not accelerated (impossible with DirectX 7 api) with the D3D pipeline (same goes for OGL pipeline).

> I think that Windows XP machine somehow knows that it is on CRT monitor, and it pushes plain monochrome AA even though ClearType is selected

That's not the case. I'm currently running some benchmarks on WinXP connected to a CRT monitor (comparing AA / LCD AA performance) and WinXP does enable ClearType if requested, even on CRT.

I'll defer to Phil Race who implemented the subpixel rendering regarding the properties are used on Gnome, as well as your rendering quality observations.

Thanks,
Dmitri
Java2D Team

P.S. I have nothing agains LCD-aa, but it just doesn't always look good in my opinion. For example, on my Inspiron 700m the fonts are so small because of high dpi screen that using ClearType makes them look very fuzzy. So I'm using Regular AA there.

selendic1
Offline
Joined: 2004-04-27

> That's not the case. I'm currently running some benchmarks on WinXP connected to a CRT monitor (comparing AA / LCD AA performance) and WinXP does enable ClearType if requested, even on CRT.

Yes, I've read some MS FAQ about ClearType, they are pushing it even on CRT monitors, I was wrong, but there is a noticeable difference between their and Java2D subpixel algorithm on CRT (Java looks fuzzier). Maybe Java could do plain AA when on CRT? (I don't know if there is a way to know for a fact that one is on CRT, especially in a portable way, though)

> Note that using LCD-aa text with the D3D pipeline won't get you the best performance, as LCD-AA text is not accelerated (impossible with DirectX 7 api) with the D3D pipeline (same goes for OGL pipeline).

I was aware of that from reading your bug reports. However, funny and strange part is that on that machine I mentioned, after working really slow for about a half a minute, SwingSet2 ("excerpts from micrographia" or "table example") started with d3d=true, suddenly and without a visible cause, speeds up noticeably, and is then much faster than SwigSet2 started without the switch (which always works with the same speed when started without d3d the switch). Really puzzled me.

trembovetski
Offline
Joined: 2003-12-31

@selendic1

> (I don't know if there is a way to know for a fact that one is on CRT, especially in a portable way, though)

Unfortunately there's no way to find out if you're displaying to a CRT or LCD monitor (not even on windows), so we're relying on whatever user set in the desktop preference dialog.

BTW, as I mentioned on another board, WinXP by default sets the text smoothing property to Standard, even on LCD screens.

Interesting results on the D3D pipeline. Could you run SwingSet2 with -Dsun.java2d.trace=log (it'll start logging of the primitives java2d is using) and see what kind of primitives are being used when the app is slow vs when it's fast.

Also, what video board you're using?

Thanks,
Dmitri
Java2D Team

selendic1
Offline
Joined: 2004-04-27

OK, I think I got it. My bad. The board is an ATI 3D RAGE PRO AGP 2X, with 8 Mb RAM (he he, I'm really pushin your pipeline). From a java2d.trace log I can see that Java is using D3D primitives for drawing. There are actually numerous artifacts, pictures only half loading then dissapering, garbled output when row height set to maximum on table demo while scroling it etc, which is kinda of expected given the low video RAM. Then I managed to provoke this error:

Direct3D pipeline enabled
Exception occurred during event dispatching:
java.lang.NullPointerException
at javax.swing.BufferStrategyPaintManager$BufferInfo.windowClosed(Buffer
StrategyPaintManager.java:860)
at java.awt.AWTEventMulticaster.windowClosed(AWTEventMulticaster.java:30
2)
at java.awt.Window.processWindowEvent(Window.java:1403)
at javax.swing.JDialog.processWindowEvent(JDialog.java:413)
at java.awt.Window.processEvent(Window.java:1358)
at java.awt.Component.dispatchEventImpl(Component.java:4360)
at java.awt.Container.dispatchEventImpl(Container.java:2025)
at java.awt.Window.dispatchEventImpl(Window.java:2012)
at java.awt.Component.dispatchEvent(Component.java:4194)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:592)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:270)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:198)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:171)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:166)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:119)

and it starts working fast. Unfortunatelly, it also stops using D3D acceleration (trace is full of sun.java2d.loops.Blit, Fillrect, DrawRect primitives). Another way to provoke that behaviour is to maximise SwingSet2, it immidatelly fails back to regular Java2d pipeline and starts working faster. After some more time, it decides it is time to stop using fancy Suns true Swing doublebufferering strategy (gray rect fix), and then it starts working fast as hell (which led me to beleive that d3d pipeline gets faster after some time, and faster than plain old Java2D pipeline). Unfortunatelly it also started producing great number of strangest artifacts after some time working this way, flashing and combining screens like mad. I guess that this machine with this video board is a bit too much of a strech for new fancy accelereated stuff. Hope I was of some help, guys.

trembovetski
Offline
Joined: 2003-12-31

> ATI 3D RAGE PRO AGP 2X, with 8 Mb RAM

8`()

Yeah, the pipeline on this board doesn't look so good. I have it here, and just yesterday ran some benchmarks on it, this is one of the boards on which our software rendering is much faster than their "hardware" rendering =)

Thanks for the stack trace, this seems to be a Swing problem (they're using BufferStrategy as part of the 'Gray Rect fix on windows), I'll forward it to swign folks.

Thanks,
Dmitri
Java2D Team

gmatter
Offline
Joined: 2007-04-21

For those who're looking for 'how to set the swing.aatext' parameter, check that option:
-Dawt.useSystemAAFontSettings=, it can be found in the documentation.

gfx
Offline
Joined: 2003-06-14

[quote]Guys, what the hell happened with -Dswing.aatext=true switch?[/quote]

As Sun said since this switch was discovered, this is an unsupported feature that is not guaranteed to remain. The fact is it does not exist anymore in Mustang.

trembovetski
Offline
Joined: 2003-12-31

Here's a rough way to tell if a text is rendered using subpixel antialiasing: magnify the text, if you see that the semi-translucent pixels are of different colors, then it's LCD-AA. Otherwise it's rendered using monochrome antialiasing, aka "regular".

But, I'm wondering, if you can't tell the difference w/o the magnifier, does it matter how the text was rendered? =)

Also, there's no such thing as "cleartype font", ClearType is a Microsoft trademarked name of the implementation of the technique of increasing the horizontal resolution on lcd displays. Any font can be rendered using this technique.

Although Microsoft recently announced that in Longhorn there will be a font family specifically designed to look good with subpixel anitaliasing.

Thanks,
Dmitri
Java2D Team

gfx
Offline
Joined: 2003-06-14

It is not the only reason. In my own source code editor, Jext, the anti-aliasing does not work, yet I don't set the rendering hints. The same goes for JGoodies Plastic LaF menus. This must be due to some drawString() call or something like that rather than just rendering hints setting.

trembovetski
Offline
Joined: 2003-12-31

2gfx:

Basicically, currently any custom component would not pickup the LCD (or even regular) AA.

All Swing components have some custom code to set the right hints before rendering, and if you override a component's paintComponent method, then those hints won't be set, and your component won't be rendered using AA/LCD aa.

As you said, if you peek at how exactly swing does that, you can set those hints yourself and it'd work. But I think we (2D+Swing) need to make sure it's easier to do.

Thanks,
Dmitri
Java2D Team

davelopez
Offline
Joined: 2005-04-28

Obviously Sun has to do gtk
Qt is a non-starter
it's gpl, so we can' deal with it

davelopez
Offline
Joined: 2005-04-28

I grabbed a daily build of Netbeans 4.2 and it's hard to tell if the editor is using subpixel or not. I think it is, but it doesn't look all the great. And then panels fonts (like Navigator) are so small and I have no idea how to change them. The menu fonts look pretty good though. Definitely not of cleartype quality, but not bad.

Another thing I've noticed is that Swing still defaults to Metal. That should be changed. I shouldn't have to " UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); "
The system look-n-feel should be the default. I don't know if its technically feasible, but swing should also know about the system font and try to use that (even if Swing is really doing its own thing with the fonts).

Not bad for a first pass though. The fonts aren't cleartype, but at least they look pretty decent on LCDs

furbotto
Offline
Joined: 2005-02-08

>The system look-n-feel should be the default

YES! There is a problem with all those java apps using Metal by default. And they even don't give you the option of changing it!
I've alreadt posted about this, but it seems that Sun isn't doing this change. See the post:
http://forums.java.net/jive/thread.jspa?threadID=653&tstart=30
Sun please listen!

trembovetski
Offline
Joined: 2003-12-31

Yes, unfortunately the editor in netbeans explicitly sets the "regular" antialiasing hint, thus overriding the desktop setting, which would've used LCD AA if the desktop's "text smoothing" property is set to "Clear Type".

That's why you can see the regular swing components (menus, etc) rendered with subpixel AA, unlike the editor.

We're working with Netbeans and swing folks on fixinig this..

Thanks,
Dmitri
Java2D Team

selendic1
Offline
Joined: 2004-04-27

Guys, what the hell happened with -Dswing.aatext=true switch? I'm using KDE, and with b39 I can't get even plain old AA to work with Swing. Are there any other switches introduced in this build, or KDE users will be left without any AA?

davelopez
Offline
Joined: 2005-04-28

I can only guess since I've only tried b39 on windows, but it could be b39 using gtk libraries

selendic1
Offline
Joined: 2004-04-27

They are probably getting some desktop info (probably through XSETTINGS spec) related with GTK to adjust fonts and AA settings of Swing apps while in Gnome desktop. However, there was a veeery nice swing.aatext switch to enable AA over all Swing components regardless of Desktop one is using (KDE, Windowmaker etc.) Now, that switch is gone. Is there any new way to make Swing programs utilize AA or subpixel AA?

gfx
Offline
Joined: 2003-06-14

If you take a look at the source code you can see how this AA is enabled. It looks at native desktop properties. I guess we can easily fix these properties either with the command line, either with a bootstrap class.

davelopez
Offline
Joined: 2005-04-28

Where did you get B39 at? All I see is the May 26 snapshot still.

tlund_
Offline
Joined: 2005-04-21

It's there, but the page isn't updated yet.

Windows Offline Installation, Multi-language:
http://www.java.net/download/jdk6/binaries/jdk-6_0-ea-bin-b39-windows-i5...
And the docs:
http://www.java.net/download/jdk6/jdk-6_0-ea-bin-b39-apidocs-04_jun_2005...

I just couldn't wait till monday ;)

davelopez
Offline
Joined: 2005-04-28

Heh, thanks. I tried that trick, but didn't get the URL right.