The Artima Developer Community
Sponsored Link

Java Buzz Forum
More Advanced Synth

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Delap

Posts: 1154
Nickname: scottdelap
Registered: Sep, 2004

Client / Server application developer.
More Advanced Synth Posted: Feb 3, 2005 8:31 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Scott Delap.
Original Post: More Advanced Synth
Feed Title: ClientJava.com
Feed URL: http://www.clientjava.com/archives/wireless_mobile.rdf
Feed Description: Client/Desktop Related Java Development
Latest Java Buzz Posts
Latest Java Buzz Posts by Scott Delap
Latest Posts From ClientJava.com

Advertisement

I'm going to repost two comments from yesterday's Advance Synth post so more people see them. First, the issue of Anti-Aliased fonts came up with Synth. Scott Violet of Sun was nice enough to provide the following solution:

    Good article. A handful of responses to various points:
    . I'm surprised we missed making AA a property on the font. None-the-less it's easy to add after the fact. You can create a subclass of SynthGraphcsUtils, override the paintText method to set the aa hint and call super. You can then bind to this in the xml file similar to the background painter. Here's the code:

    
    public class MySynthGraphicsUtils extends SynthGraphicsUtils {
        public void paintText(SynthContext ss, Graphics g, String text,
                              int x, int y, int mnemonicIndex) {
            Graphics2D g2 = (Graphics2D)g;
            Object oldAAValue = g2.getRenderingHint(
                                           RenderingHints.KEY_TEXT_ANTIALIASING);
            g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            super.paintText(ss, g, text, x, y, mnemonicIndex);
            g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                oldAAValue);
        }
    }
    
    And add the following to the default style:
        <object id="myGraphicsUtils" class="demo.synth.MySynthGraphicsUtils"/>
        <graphicsUtils idref="myGraphicsUtils"/>
    
    . Synth is hardly bug free, but it's certainly usable. As of this email there are ~10 open bugs against synth, a handful of which are documentation related. I will admit that 1.5 has more bugs as some have been fixed for 1.6.

Another comment dealt with dynamically sizing fonts:

    Thanks for the responses in relation to antialias! I recently ran into this with my own application and went with a quick and useful hack: wraplf (http://wraplf.l2fprod.com/). This may not be necessary anymore with the code you provide here. I also had to add functionality in my application similar to Firefox's increase/decrease font size and discovered that there is no official mechanism for scaling fonts application wide in Swing. I ended up manually walking all UI defaults and looking for keys with "FONT" embedded in them, building a new FontUIResource based on the one for the key, "put"ting it back in for the key, and then calling updateComponentTreeUI. Still not 100% perfect, but pretty close.

    Source
    Dynamically Scaling Fonts in Swing

Read: More Advanced Synth

Topic: OGNL and Spring Previous Topic   Next Topic Topic: Struts or Spring-MVC

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use