zoukankan      html  css  js  c++  java
  • e577. Enabling Antialiasing

    // 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
  • 相关阅读:
    p1373
    考试总结 2018-5-6
    p1044与p1898
    p1905
    p1904 p1903
    p1177
    p1273  日常打表
    p1142
    并查集与并查集模板
    p1265
  • 原文地址:https://www.cnblogs.com/borter/p/9575637.html
Copyright © 2011-2022 走看看