ryanqq / macwidgets

Automatically exported from code.google.com/p/macwidgets
0 stars 0 forks source link

Enable AntiAlising when components are drawn unter Lin/Win #38

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The text on UnifiedToolbar & SourceList is smooth on Mac Os X (10.5.6/Java6u7)

But it's not antialised on Windows (XP/Vista, Java6u11) and Linux (Ubuntu
8.10/J6u10)

Apart that issue the components render pretty much the same. 

For Mac, Win we used the system default LaF, for Linux Nimbus (if
available, or gtk). The LaF does not seem to make any difference.

Is there a way to enable antialising on those controls?

Thanks,
Peter

Original issue reported on code.google.com by studp...@gmail.com on 30 Dec 2008 at 4:14

Attachments:

GoogleCodeExporter commented 9 years ago
Try this:

-Dawt.useSystemAAFontSettings=on

How did you turn on anti-aliasing for the table in your screen shots?

Original comment by kenneth....@gmail.com on 30 Dec 2008 at 6:27

GoogleCodeExporter commented 9 years ago
The Table is a JTreeTable from the swingx-project, antialising is obviously 
enabled
per default here.

I tried both:
        System.setProperty("awt.useSystemAAFontSettings","on");
        System.setProperty("swing.aatext", "true");

but the only effect is that it changes the default sub-pixel antialising to a 
more
blurry antialising (on the menu)

It does not affect the macwidgets components.

Original comment by studp...@gmail.com on 30 Dec 2008 at 7:03

GoogleCodeExporter commented 9 years ago

Original comment by kenneth....@gmail.com on 31 Dec 2008 at 6:12

GoogleCodeExporter commented 9 years ago
Are you using a custom renderer that is somehow turning on anti-aliasing? I've 
looked at the SwingX source 
code, emailed Josh Marinacci, and posted to the SwingX forum ( 
http://forums.java.net/jive/thread.jspa?
threadID=55447&tstart=0 ), but have yet to figure out how that anti-aliasing is 
happening on windows.

Original comment by kenneth....@gmail.com on 7 Jan 2009 at 12:45

GoogleCodeExporter commented 9 years ago
The renderers are customized, but only for icon setting and so on.

AntiAlising is respected perfectly with the swingx JTreeTable.
You can see on the screenshot the variant running without aa.

Original comment by studp...@gmail.com on 7 Jan 2009 at 4:07

Attachments:

GoogleCodeExporter commented 9 years ago
Ah, I missed the fact that anti-aliasing is turned on at a system level. I 
still don't know what's going on, but that 
might help!

Original comment by kenneth....@gmail.com on 7 Jan 2009 at 4:12

GoogleCodeExporter commented 9 years ago
If you use SwingUtilities2.drawStringUnderlineCharAt(...) instead of 
BasicGraphicsUtils.drawStringUnderlineCharAt(...), text will be antialiased 
(under 
Windows).

Original comment by joshe...@gmail.com on 19 Jan 2009 at 3:02

GoogleCodeExporter commented 9 years ago
Yeah... but isn't that non-published api? and we need support for al os'ses... 

Original comment by studp...@gmail.com on 20 Jan 2009 at 11:49

GoogleCodeExporter commented 9 years ago
Yes. BasicGraphicsUtils.drawStringUnderlineCharAt(...) just calls 
SwingUtilities2.draw... with null for JComponent.

Another solution in attachment.

Original comment by joshe...@gmail.com on 21 Jan 2009 at 9:47

Attachments:

GoogleCodeExporter commented 9 years ago
Does anyone know if this is the technique that SwingX uses?

Original comment by kenneth....@gmail.com on 21 Jan 2009 at 10:29

GoogleCodeExporter commented 9 years ago
How can you make the ToggleButton being Mac-like under Windows?
I cannot make it even I just use DUnifiedToolbar.java directly....

Original comment by nwoedf@gmail.com on 25 Jan 2009 at 3:11

GoogleCodeExporter commented 9 years ago
nwoedf,

Mac-like toggle buttons aren't offered by Mac Widgets right now. If you'd like 
to see that, please create a new 
issue.

-Ken

Original comment by kenneth....@gmail.com on 25 Jan 2009 at 6:29

GoogleCodeExporter commented 9 years ago
Pete,

Did you try setting the swing.aatext client property by passing in an argument 
to the JVM like this:

java -Dswing.aatext=true com.blah.MyApp

Let me know.
-Ken

Original comment by kenneth....@gmail.com on 28 Jan 2009 at 2:35

GoogleCodeExporter commented 9 years ago
I just verified that starting your app using -Dswing.aatext=true on Windows 
correctly causes text to be anti-
aliased. Thus, I'm closing this issue as I don't see a need to change the 
anti-aliasing on a per-component basis 
(not to mention that the infrastructure isn't there in Swing to do this).

Original comment by kenneth....@gmail.com on 28 Jan 2009 at 3:02

GoogleCodeExporter commented 9 years ago
Wish I could contribute instead of whining. 
-Dswing.aatext=true 
is not a standard option and it does not work with JDK 6
From a library stand point, this is not fixed. However, is macwidgets "as is"
supposed to be used outside mac os?

Original comment by sen...@gmail.com on 19 Jan 2010 at 9:46

GoogleCodeExporter commented 9 years ago
Yes, Mac Widgets for Java is designed to be used on all platforms. Feel free to 
create a patch for this issue and 
send it to me.

Original comment by kenneth....@gmail.com on 19 Jan 2010 at 10:16

GoogleCodeExporter commented 9 years ago
Hi, 

I think I have a possible fix for this issue without using SwingUtilities2. 
The problem has been solved by Jgoodies looks in the past, see issue 69:
https://looks.dev.java.net/issues/show_bug.cgi?id=69
The fixed code now resides in the JGoodies commons library.

I tested this by changing out both the calls to 
BasicGraphicsUtils.drawStringUnderlineCharAt in 
EmphasizedLabelUI.paintEnabledText 
with the calls used by Jgoodies:

RenderingUtils.drawStringUnderlineCharAt(label, g, s, -1, textX, textY);

This fixed the rendering on Windows,. Please see the attached picture. 

As I see it there are two ways of incorporating the fix:
1) Include JGoodies commons (very small file) as a dependency and use it's 
drawString 
method
2) Include the code directly, it is quite small.

If there is anything I can do to further help (like posting an entire fix 
somewhere), 
please let me know.

Original comment by erikaxel...@gmail.com on 8 Apr 2010 at 10:05

Attachments:

GoogleCodeExporter commented 9 years ago
It's been a while since the last post, but is this still going to be fixed?
On linux, I just find a way to enable anti aliasing at all. -Dswing.aatext=true 
does nothing, neither does -Dawt.useSystemAAFontSettings=on.
Sadly, even checking out the code and using the JGoodies RenderingUtils in 
EmphasizedLabelUI does not solve the issue.

Any ideas on how to proceed from here? The way it looks at the moment is just 
horrible... :(

Original comment by chea...@gmail.com on 16 Nov 2010 at 3:14

GoogleCodeExporter commented 9 years ago
I take that last comment back: using JGoodies DOES resolve the issue. :)
+1 to get this in the next version.

Please, please, pretty please? :D

Original comment by chea...@gmail.com on 16 Nov 2010 at 3:18

GoogleCodeExporter commented 9 years ago
Any chance you can provide a patch with the fix?

Original comment by kenneth....@gmail.com on 16 Nov 2010 at 3:49

GoogleCodeExporter commented 9 years ago
Errrr, no idea how to do that. Do you want me to check it in?

Original comment by chea...@gmail.com on 16 Nov 2010 at 4:11

GoogleCodeExporter commented 9 years ago
How about attaching the file? 
All you need is to include com.jgoodies:looks:2.2.2 in your pom...

Original comment by chea...@gmail.com on 16 Nov 2010 at 4:13

Attachments: