ここでAlloyLookand Feelを使用している人はいますか?アンチエイリアシングとJTextComponentsで奇妙なバグに直面しています。Alloyはデフォルトでアンチエイリアシングをまったく使用しないため、独自のUIクラスを作成して強制する必要があります。これはほとんどの場合正常に機能しますが、アンチエイリアシングに大混乱をもたらす特定の文字があります。
たとえば、Alloyがルックアンドフィールとして設定されていて、ヘブライ語のテキストをJTextComponentに挿入した場合、たとえば、שלום、מהשלומךשמיהואהאקזיד'の場合、JTextComponent全体が突然アンチエイリアスを失います。
奇妙なことに、AlloyTextPaneUIを拡張することすらしていませんが、アンチエイリアシングを行うためにBasicTextPaneUIを拡張しているため、Alloyが画像のどこに現れるのか戸惑っています(他のルックアンドフィールは問題なく機能しているようです)。
私はこのバグを追跡するのに非常に苦労しています...誰かが同じ問題に直面しましたか?
問題を示す短い例を次に示します。
import com.incors.plaf.alloy.AlloyLookAndFeel;
import com.incors.plaf.alloy.themes.glass.GlassTheme;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTextPaneUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.StyledDocument;
import java.awt.*;
public class Scrap {
static {
// NOTE: You need a license code for Alloy!
AlloyLookAndFeel.setProperty("alloy.licenseCode", "your license here");
UIManager.put("TextPaneUI", MyTextPaneUI.class.getName());
try {
UIManager.setLookAndFeel(new AlloyLookAndFeel(new GlassTheme()));
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
// With system Look and Feel everything works just fine...
// try {
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (UnsupportedLookAndFeelException e) {
// e.printStackTrace();
// }
}
public static void main(final String args[]) {
JTextPane text = new JTextPane();
text.setFont(new Font("Monospaced", Font.PLAIN, 14));
StyledDocument doc = text.getStyledDocument();
try {
doc.insertString(doc.getLength(), "Here's some regular text. Nice and smooth with anti-aliasing.\n\n", null);
doc.insertString(doc.getLength(), "Here's some more text Blaa Blaa Blaaa. Lorem ipsum... now try to uncomment the Hebrew text.\n\n", null);
// Try to uncomment this line and the anti-aliasing breaks for the whole JTextPane
// doc.insertString(doc.getLength(), "שלום, מה שלומך שמי הוא האקזידן\n\n", null);
// Here's another strange glyph that breaks the anti-aliasing
// doc.insertString(doc.getLength(), "ಠ", null);
} catch (BadLocationException e) {
e.printStackTrace();
}
JFrame frame = new JFrame();
JScrollPane scroll = new JScrollPane();
scroll.setViewportView(text);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
frame.add(scroll, BorderLayout.CENTER);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(600, 300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static class MyTextPaneUI extends BasicTextPaneUI {
@Override
protected void paintSafely(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
super.paintSafely(g);
}
public static ComponentUI createUI(JComponent c) {
return new MyTextPaneUI();
}
}
}