JDK-4754076 : REGRESSION: View clipping of scaled GeneralPath object broken
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2002-09-26
  • Updated: 2002-11-08
  • Resolved: 2002-11-08
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 09/26/2002


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

also:

java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)



FULL OPERATING SYSTEM VERSION : glibc version 2.2.4, kernel
2.4.18, Mandrake 8.2 distribution

Redhat 7.1

On Windows ME, Windows 2000, Solaris does not exhibit this error.

A DESCRIPTION OF THE PROBLEM :
When scaling a GeneralPath to large values using an Affine Transform, Linux version incorrectly clips lines.  For example, in the example program below, if you set a scale to 24000, the visible portion of the box will not display
properly.  The boxes lines are displayed exiting the top and left sides of the frame, instead of the bottom and right sides.

REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the source code below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
If the bottom right corner of the box is outside the view,
the visible lines should always go off to the right and bottom.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Example program below:

There are Two classes: GeneralPathPanel and ClippingTest

*****Start GeneralPathPanel.java**********
import javax.swing.JPanel;
import java.awt.geom.*;
import java.awt.*;

public class GeneralPathPanel extends JPanel
{
  double zoom = 1;
  GeneralPath square;

  public GeneralPathPanel()
  {
    square = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4);

    // Draw square (0,0) - (30,30)
    square.moveTo(0, 0);
    square.lineTo(0,30);
    square.lineTo(30,30);
    square.lineTo(30,0);
    square.closePath();
  }

  public void paintComponent(Graphics g)
  {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D)g;

    AffineTransform transform = new AffineTransform();
    transform.setToTranslation(50, 50);
    transform.scale(zoom, zoom);
    g2d.draw(square.createTransformedShape(transform));

    Double z = new Double(zoom);
    g.drawString(z.toString(), 10, 10);
  }

  public void setZoom(double zoom)
  {
    this.zoom = zoom;
    this.repaint();
  }
}
*****End GeneralPathPanel.java************

*****Start ClippingTest.java**************
package clipping_article;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

import javax.swing.*;
import java.awt.*;

public class ClippingTest extends JFrame
{

  public ClippingTest()
  {
  }

  public static void main(String[] args)
  {
    ClippingTest frame = new ClippingTest();

    // Create Frame
    frame.setSize(800,800);

    // Construct and display squares
    GeneralPathPanel panel = new GeneralPathPanel();

    frame.getContentPane().add(panel);
    frame.setVisible(true);

    // Zoom
    double zoom = 1;
    double factor = 1 / .97;

    while (true)
    {
      panel.setZoom(zoom);
      if (zoom > 10000000) factor = .97;
      else if (zoom < 1) factor = 1 / .97;
      zoom *= factor;
      try { Thread.sleep(5); } catch (Exception e) {}
    }
   }
}
*****End ClippingTest.java****************

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
1. Doing Graphics::drawLine (however, in the "Real"
application, this results in clipping problems as well)

2. Implement own clipping algorithm.

Release Regression From : 1.3.1_04
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 159533) 
======================================================================

Comments
EVALUATION Targetted for tiger. I can reproduce this on lab-14. ###@###.### 2002-09-30 This is a duplicate of 4768686, which has been fixed in mantis. ###@###.### 2002-11-08
30-09-2002