package org.apache.pojo.beaneditor;

import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.font.FontRenderContext;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.undo.UndoManager;

import org.apache.pojo.beaneditor.model.PBEBeanParser;
import org.apache.pojo.beaneditor.model.PBEDocument;

public class PojoBeanEditor extends JTextArea {
    private final UndoManager undoManager = new UndoManager();
    private Map<?, ?> aaHints;

    public PojoBeanEditor(PojoBeanCreator creator, BeanValueTransformer bvt, Class<?> objType) {
        this(creator, bvt, creator.createPojoBean(objType));
    }

    public PojoBeanEditor(PojoBeanCreator creator, BeanValueTransformer bvt, Object obj) {
        super(new PBEDocument(bvt, PBEBeanParser.parseBean(creator, obj)));
        init();
    }

    protected void init() {
        getCaret().setBlinkRate(0);
        getDocument().addUndoableEditListener(undoManager);
        calculateRenderingHints();
    }

    public void updateUI() {
        setUI(new PojoBeanEditorUI(this));
        invalidate();
    }

    private final Graphics2D getGraphics2D(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;

        if (aaHints != null) {
            g2d.addRenderingHints(aaHints);
        }

        return g2d;
    }

    private final void calculateRenderingHints() {
        aaHints = (Map<?, ?>) Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints");
        if (aaHints == null) {
            Map<RenderingHints.Key, Object> temp = new HashMap<RenderingHints.Key, Object>();
            JLabel label = new JLabel();
            FontMetrics fm = label.getFontMetrics(label.getFont());
            Object hint = null;
            try {
                Method m = FontMetrics.class.getMethod("getFontRenderContext");
                FontRenderContext frc = (FontRenderContext) m.invoke(fm);
                m = FontRenderContext.class.getMethod("getAntiAliasingHint");
                hint = m.invoke(frc);
            } catch (RuntimeException re) {
                throw re;
            } catch (Exception e) {
            }

            if (hint == null) {
                String os = System.getProperty("os.name").toLowerCase();
                if (os.contains("windows")) {
                    hint = RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
                } else {
                    hint = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
                }
            }
            temp.put(RenderingHints.KEY_TEXT_ANTIALIASING, hint);

            aaHints = temp;

        }
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(getGraphics2D(g));
    }

    public UndoManager getUndoManager() {
        return undoManager;
    }
}

@@ -34,37 +34,8 @@
 r;%0A%0A
-import java.awt.FontMetrics;%0A
 impo
@@ -56,16 +56,16 @@
 aphics;%0A
+
 import j
@@ -145,81 +145,8 @@
 it;%0A
-import java.awt.font.FontRenderContext;%0Aimport java.lang.reflect.Method;%0A
 impo
@@ -194,35 +194,8 @@
 p;%0A%0A
-import javax.swing.JLabel;%0A
 impo
@@ -1639,724 +1639,17 @@
     
-JLabel label = new JLabel();%0A            FontMetrics fm = label.getFontMetrics(label.getFont());%0A            Object hint = null;%0A            try %7B%0A                Method m = FontMetrics.class.getMethod(%22getFontRenderContext%22);%0A                FontRenderContext frc = (FontRenderContext) m.invoke(fm);%0A                m = FontRenderContext.class.getMethod(%22getAntiAliasingHint%22);%0A                hint = m.invoke(frc);%0A            %7D catch (RuntimeException re) %7B%0A                throw re;%0A            %7D catch (Exception e) %7B%0A            %7D%0A%0A            if (hint == null) %7B%0A                String os = System.getProperty(%22os.name%22).toLowerCase();%0A                if (os.contains(%22windows%22)) %7B%0A                    hint = 
+temp.put(
 Rend
@@ -1651,37 +1651,35 @@
 (RenderingHints.
-VALUE
+KEY
 _TEXT_ANTIALIAS_
@@ -1681,141 +1681,59 @@
 LIAS
-_ON;%0A                %7D else %7B%0A                    hint = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;%0A                %7D%0A            %7D
+ING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
 %0A   
@@ -1778,30 +1778,28 @@
 EXT_
-ANTIALIASING, hint
+LCD_CONTRAST, 120
 );%0A
-%0A
     

change antialiasing