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

fillOval and drawOval seem to differ in shape

    XMLWordPrintable

Details

    • generic, x86
    • generic, windows_95

    Description

      The following program demonstrates the problem being seen with drawOval and fillOval. I have a file called comparison.gif that shows the problem (it is listed in the attachment). If you use drawOval and then use fillOval to fill the original oval the shape of the oval seems to distort. I looks as though pixels are either being added or dropped.


      //Main.java
      //This class is a test of the fillOval call.
      //
      //fillOval(int x, int y, int width, int height),
      //The AWT's fillOval method paints an oval area on this
      //graphics context. The oval area is defined to be the
      //largest oval that fits into the rectangle defined by
      //x, y, width, and height.

      import java.awt.*;

      class Main extends Frame {
      Main(){
      super("fillOval Example");
      this.setBackground( new Color(189, 189, 189) );
      setSize(200,400);
      show();
      }


      public void paint(Graphics g) {
      Insets insets = this.getInsets();
      int x = insets.left, y = insets.top;
      int startx;
      int starty;

      startx = x + 5;
      starty = y + 10;
      g.setColor(Color.black);
      g.setColor(Color.black);
      g.fillRect(startx, starty, 14, 14);
      g.setColor(Color.yellow);
      g.fillOval(startx, starty, 14, 14);
      startx = x + 25;
      g.setColor(Color.black);
      g.fillRect(startx, starty, 50, 50);
      g.setColor(Color.yellow);
      g.fillOval(startx, starty, 50, 50);
      startx = x + 85;
      g.setColor(Color.black);
      g.fillRect(startx, starty, 100, 100);
      g.setColor(Color.yellow);
      g.fillOval(startx, starty, 100, 100);

      startx = x + 5;
      starty = y + 10 + 110;
      g.setColor(Color.black);
      g.setColor(Color.black);
      g.fillRect(startx, starty, 14, 14);
      g.setColor(Color.yellow);
      g.drawOval(startx, starty, 14, 14);
      startx = x + 25;
      g.setColor(Color.black);
      g.fillRect(startx, starty, 50, 50);
      g.setColor(Color.yellow);
      g.drawOval(startx, starty, 50, 50);
      startx = x + 85;
      g.setColor(Color.black);
      g.fillRect(startx, starty, 100, 100);
      g.setColor(Color.yellow);
      g.drawOval(startx, starty, 100, 100);

      startx = x + 5;
      starty = y + 10 + 220;
      g.setColor(Color.black);
      g.setColor(Color.black);
      g.fillRect(startx, starty, 14, 14);
      g.setColor(Color.yellow);
      g.fillOval(startx, starty, 14, 14);
      g.drawOval(startx, starty, 14, 14);
      startx = x + 25;
      g.setColor(Color.black);
      g.fillRect(startx, starty, 50, 50);
      g.setColor(Color.yellow);
      g.fillOval(startx, starty, 50, 50);
      g.drawOval(startx, starty, 50, 50);
      startx = x + 85;
      g.setColor(Color.black);
      g.fillRect(startx, starty, 100, 100);
      g.setColor(Color.yellow);
      g.fillOval(startx, starty, 100, 100);
      g.drawOval(startx, starty, 100, 100);


      }

      static public void main(String[] args) {
      new Main();
      }


      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            csalemme Charles Salemme (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: