Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4193338

drawArc() to offscreen produces unsmooth arc

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs
    • 2d
    • generic
    • generic



      Name: gsC80088 Date: 11/28/98


      // drawArc() incorrect in 1.2RC2 when
      // drawn onto off-screen Image
      //

      import java.applet.*;
      import java.awt.*;

      public class ArcBug extends Applet {

      public static void main(String args[]) {

      ArcBug arcBug = new ArcBug();
      Frame frame = new Frame("Arc bug");

      frame.add("Center", arcBug);
      frame.setSize(200, 120);
      frame.show();
      }

      public void paint(Graphics g) {

      int width = getSize().width,
      height = getSize().height;
      Graphics offscreenGraphics;
      Image offscreenImage;

      // Create the off-screen drawable
      //
      offscreenImage = createImage(width, height);
      offscreenGraphics = offscreenImage.getGraphics();

      // Draw the arc off-screen (incorrectly drawn)
      //
      offscreenGraphics.setColor(Color.white);
      offscreenGraphics.fillRect(0, 0, width, height);
      offscreenGraphics.setColor(Color.blue);
      offscreenGraphics.drawString("Incorrect arc", 10, 30);
      offscreenGraphics.drawArc(35, 50, 20, 20, 0, 180);

      // And copy it onto the screen
      //
      g.drawImage(offscreenImage, 0, 0, this);

      // Now, draw the arc on-screen (correctly drawn)
      //
      g.setColor(Color.black);
      g.drawString("Correct arc", 110, 30);
      g.drawArc(125, 50, 20, 20, 0, 180);
      }
      }
      (Review ID: 43406)
      ======================================================================

            flar Jim Graham
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: