You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Nellya Udovichenko (JIRA)" <ji...@apache.org> on 2007/07/10 15:00:52 UTC

[jira] Created: (HARMONY-4410) [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one

[classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one
-----------------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-4410
                 URL: https://issues.apache.org/jira/browse/HARMONY-4410
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Nellya Udovichenko


There are two polygonal figures: Figure 1 and Figure 2. Figure 2 lies inside Figure 1 and intersects with Figure 1 in two boundary points. At subtraction of Figure 2 from Figure 1 we get no correct result - Figure 1.

Test:

import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Area;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class PolygonTest extends JPanel {

    protected void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
 
        Rectangle2D rect1 = new Rectangle2D.Double(300, 300, 200, 150);
        Rectangle2D rect2 = new Rectangle2D.Double(350, 200, 300, 150);

        Area area1 = new Area(rect1);
        g2.setColor(Color.green);
        g2.draw(area1);
	
        Area area2 = new Area(rect2);
        g2.setColor(Color.red);
        g2.draw(area2);

	Area a = (Area) area1.clone();
	a.intersect(area2);
	area1.add(area2);
	area1.subtract(a);
        g2.setColor(Color.cyan);
        g2.draw(area1);
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(new PolygonTest());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(800, 600);
        frame.setVisible(true);
    }
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-4410) [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one

Posted by "Nellya Udovichenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nellya Udovichenko closed HARMONY-4410.
---------------------------------------


Verified. Thank you, Alexey!

> [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4410
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4410
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Nellya Udovichenko
>            Assignee: Alexey Petrenko
>         Attachments: H-4410-test.patch, H-4410.patch
>
>
> There are two polygonal figures: Figure 1 and Figure 2. Figure 2 lies inside Figure 1 and intersects with Figure 1 in two boundary points. At subtraction of Figure 2 from Figure 1 we get no correct result - Figure 1.
> Test:
> import java.awt.*;
> import java.awt.geom.Rectangle2D;
> import java.awt.geom.Area;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> public class PolygonTest extends JPanel {
>     protected void paintComponent(Graphics g) {
>         Graphics2D g2 = (Graphics2D) g;
>  
>         Rectangle2D rect1 = new Rectangle2D.Double(300, 300, 200, 150);
>         Rectangle2D rect2 = new Rectangle2D.Double(350, 200, 300, 150);
>         Area area1 = new Area(rect1);
>         g2.setColor(Color.green);
>         g2.draw(area1);
> 	
>         Area area2 = new Area(rect2);
>         g2.setColor(Color.red);
>         g2.draw(area2);
> 	Area a = (Area) area1.clone();
> 	a.intersect(area2);
> 	area1.add(area2);
> 	area1.subtract(a);
>         g2.setColor(Color.cyan);
>         g2.draw(area1);
>     }
>     public static void main(String[] args) {
>         JFrame frame = new JFrame();
>         frame.getContentPane().setLayout(new BorderLayout());
>         frame.getContentPane().add(new PolygonTest());
>         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         frame.setSize(800, 600);
>         frame.setVisible(true);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4410) [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one

Posted by "Nellya Udovichenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12511423 ] 

Nellya Udovichenko commented on HARMONY-4410:
---------------------------------------------

I think the problem in the wrong condition of the loop termination at the round of the figures. I'm working on the patch for this issue.

> [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4410
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4410
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Nellya Udovichenko
>
> There are two polygonal figures: Figure 1 and Figure 2. Figure 2 lies inside Figure 1 and intersects with Figure 1 in two boundary points. At subtraction of Figure 2 from Figure 1 we get no correct result - Figure 1.
> Test:
> import java.awt.*;
> import java.awt.geom.Rectangle2D;
> import java.awt.geom.Area;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> public class PolygonTest extends JPanel {
>     protected void paintComponent(Graphics g) {
>         Graphics2D g2 = (Graphics2D) g;
>  
>         Rectangle2D rect1 = new Rectangle2D.Double(300, 300, 200, 150);
>         Rectangle2D rect2 = new Rectangle2D.Double(350, 200, 300, 150);
>         Area area1 = new Area(rect1);
>         g2.setColor(Color.green);
>         g2.draw(area1);
> 	
>         Area area2 = new Area(rect2);
>         g2.setColor(Color.red);
>         g2.draw(area2);
> 	Area a = (Area) area1.clone();
> 	a.intersect(area2);
> 	area1.add(area2);
> 	area1.subtract(a);
>         g2.setColor(Color.cyan);
>         g2.draw(area1);
>     }
>     public static void main(String[] args) {
>         JFrame frame = new JFrame();
>         frame.getContentPane().setLayout(new BorderLayout());
>         frame.getContentPane().add(new PolygonTest());
>         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         frame.setSize(800, 600);
>         frame.setVisible(true);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4410) [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one

Posted by "Nellya Udovichenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nellya Udovichenko updated HARMONY-4410:
----------------------------------------

    Attachment: H-4410.patch

The problem is in the wrong work of the round loop when the intersection points of the figures have to be passed the few times. One of sub-bug is HARMONY-4612: the method org.apache.harmony.awt.gl.Crossing.crossLine() returns no correct result if the parameter point is the upper rhomb vertex.

In the attached patch the new conditions of the round loop termination are defined in the method java.awt.geom.Area.subtract(). Else in the method org.apache.harmony.awt.gl.Crossing.crossLine() the changes after the patch of HARMONY-4612 are deleted because of regression: the method doesn't work correctly for all points lied on the line crossed two rhomb vertices. The new condition is added for HARMONY-4612 bug fix in method org.apache.harmony.awt.gl.Crossing.crossPath().


> [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4410
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4410
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Nellya Udovichenko
>         Attachments: H-4410.patch
>
>
> There are two polygonal figures: Figure 1 and Figure 2. Figure 2 lies inside Figure 1 and intersects with Figure 1 in two boundary points. At subtraction of Figure 2 from Figure 1 we get no correct result - Figure 1.
> Test:
> import java.awt.*;
> import java.awt.geom.Rectangle2D;
> import java.awt.geom.Area;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> public class PolygonTest extends JPanel {
>     protected void paintComponent(Graphics g) {
>         Graphics2D g2 = (Graphics2D) g;
>  
>         Rectangle2D rect1 = new Rectangle2D.Double(300, 300, 200, 150);
>         Rectangle2D rect2 = new Rectangle2D.Double(350, 200, 300, 150);
>         Area area1 = new Area(rect1);
>         g2.setColor(Color.green);
>         g2.draw(area1);
> 	
>         Area area2 = new Area(rect2);
>         g2.setColor(Color.red);
>         g2.draw(area2);
> 	Area a = (Area) area1.clone();
> 	a.intersect(area2);
> 	area1.add(area2);
> 	area1.subtract(a);
>         g2.setColor(Color.cyan);
>         g2.draw(area1);
>     }
>     public static void main(String[] args) {
>         JFrame frame = new JFrame();
>         frame.getContentPane().setLayout(new BorderLayout());
>         frame.getContentPane().add(new PolygonTest());
>         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         frame.setSize(800, 600);
>         frame.setVisible(true);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4410) [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko reassigned HARMONY-4410:
----------------------------------------

    Assignee: Alexey Petrenko

> [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4410
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4410
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Nellya Udovichenko
>            Assignee: Alexey Petrenko
>         Attachments: H-4410.patch
>
>
> There are two polygonal figures: Figure 1 and Figure 2. Figure 2 lies inside Figure 1 and intersects with Figure 1 in two boundary points. At subtraction of Figure 2 from Figure 1 we get no correct result - Figure 1.
> Test:
> import java.awt.*;
> import java.awt.geom.Rectangle2D;
> import java.awt.geom.Area;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> public class PolygonTest extends JPanel {
>     protected void paintComponent(Graphics g) {
>         Graphics2D g2 = (Graphics2D) g;
>  
>         Rectangle2D rect1 = new Rectangle2D.Double(300, 300, 200, 150);
>         Rectangle2D rect2 = new Rectangle2D.Double(350, 200, 300, 150);
>         Area area1 = new Area(rect1);
>         g2.setColor(Color.green);
>         g2.draw(area1);
> 	
>         Area area2 = new Area(rect2);
>         g2.setColor(Color.red);
>         g2.draw(area2);
> 	Area a = (Area) area1.clone();
> 	a.intersect(area2);
> 	area1.add(area2);
> 	area1.subtract(a);
>         g2.setColor(Color.cyan);
>         g2.draw(area1);
>     }
>     public static void main(String[] args) {
>         JFrame frame = new JFrame();
>         frame.getContentPane().setLayout(new BorderLayout());
>         frame.getContentPane().add(new PolygonTest());
>         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         frame.setSize(800, 600);
>         frame.setVisible(true);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-4410) [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko resolved HARMONY-4410.
--------------------------------------

    Resolution: Fixed

The patch has been applied.
Please verify.

> [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4410
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4410
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Nellya Udovichenko
>            Assignee: Alexey Petrenko
>         Attachments: H-4410-test.patch, H-4410.patch
>
>
> There are two polygonal figures: Figure 1 and Figure 2. Figure 2 lies inside Figure 1 and intersects with Figure 1 in two boundary points. At subtraction of Figure 2 from Figure 1 we get no correct result - Figure 1.
> Test:
> import java.awt.*;
> import java.awt.geom.Rectangle2D;
> import java.awt.geom.Area;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> public class PolygonTest extends JPanel {
>     protected void paintComponent(Graphics g) {
>         Graphics2D g2 = (Graphics2D) g;
>  
>         Rectangle2D rect1 = new Rectangle2D.Double(300, 300, 200, 150);
>         Rectangle2D rect2 = new Rectangle2D.Double(350, 200, 300, 150);
>         Area area1 = new Area(rect1);
>         g2.setColor(Color.green);
>         g2.draw(area1);
> 	
>         Area area2 = new Area(rect2);
>         g2.setColor(Color.red);
>         g2.draw(area2);
> 	Area a = (Area) area1.clone();
> 	a.intersect(area2);
> 	area1.add(area2);
> 	area1.subtract(a);
>         g2.setColor(Color.cyan);
>         g2.draw(area1);
>     }
>     public static void main(String[] args) {
>         JFrame frame = new JFrame();
>         frame.getContentPane().setLayout(new BorderLayout());
>         frame.getContentPane().add(new PolygonTest());
>         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         frame.setSize(800, 600);
>         frame.setVisible(true);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4410) [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one

Posted by "Nellya Udovichenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nellya Udovichenko updated HARMONY-4410:
----------------------------------------

    Attachment: H-4410-test.patch

the regression test patch.

> [classlib][awt] The method java.awt.geom.Area.subtract() returns no correct result when the first figure lies inside the second one
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4410
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4410
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Nellya Udovichenko
>            Assignee: Alexey Petrenko
>         Attachments: H-4410-test.patch, H-4410.patch
>
>
> There are two polygonal figures: Figure 1 and Figure 2. Figure 2 lies inside Figure 1 and intersects with Figure 1 in two boundary points. At subtraction of Figure 2 from Figure 1 we get no correct result - Figure 1.
> Test:
> import java.awt.*;
> import java.awt.geom.Rectangle2D;
> import java.awt.geom.Area;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> public class PolygonTest extends JPanel {
>     protected void paintComponent(Graphics g) {
>         Graphics2D g2 = (Graphics2D) g;
>  
>         Rectangle2D rect1 = new Rectangle2D.Double(300, 300, 200, 150);
>         Rectangle2D rect2 = new Rectangle2D.Double(350, 200, 300, 150);
>         Area area1 = new Area(rect1);
>         g2.setColor(Color.green);
>         g2.draw(area1);
> 	
>         Area area2 = new Area(rect2);
>         g2.setColor(Color.red);
>         g2.draw(area2);
> 	Area a = (Area) area1.clone();
> 	a.intersect(area2);
> 	area1.add(area2);
> 	area1.subtract(a);
>         g2.setColor(Color.cyan);
>         g2.draw(area1);
>     }
>     public static void main(String[] args) {
>         JFrame frame = new JFrame();
>         frame.getContentPane().setLayout(new BorderLayout());
>         frame.getContentPane().add(new PolygonTest());
>         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         frame.setSize(800, 600);
>         frame.setVisible(true);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.