// See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graphics context; this object is used to paint shapes Graphics2D g2d = (Graphics2D)g; // Determine if antialiasing is enabled RenderingHints rhints = g2d.getRenderingHints(); boolean antialiasOn = rhints.containsValue(RenderingHints.VALUE_ANTIALIAS_ON); // Enable antialiasing for shapes g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Disable antialiasing for shapes g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); // Draw shapes...; see e586 Drawing Simple Shapes // Enable antialiasing for text g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // Draw text...; see e591 Drawing Simple Text // Disable antialiasing for text g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); }
Related Examples |
原文地址:https://www.cnblogs.com/borter/p/9575637.html
时间: 2024-10-12 01:32:43