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/08/15 17:19:31 UTC

[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

     [ 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.