Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4825225
Votes 0
Synopsis setClip seems to be broken on Graphics2D object obtained from TiledImage
Category jai:implementation
Reported Against 1.1.1
Release Fixed
State 3-Accepted, bug
Priority: 4-Low
Related Bugs
Submit Date 27-FEB-2003
Description




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


FULL OPERATING SYSTEM VERSION : linux 2.4.20 home-brewed,
Based opn RH 7.3, J2SDK 1.4.1_01, Problem exists with 1.3.1
as well.


EXTRA RELEVANT SYSTEM CONFIGURATION :
JAI 1.1.1_01 and 1.2-beta,

A DESCRIPTION OF THE PROBLEM :
on the Graphics2D  customer  returned from
TiledImage.createGraphics the setClip methods do not set the
clip region.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the attached test case. Use paintJAI vs paintIt in the
paint() method to see the difference.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Text should be clipped when JAI gets used

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;             // AWT classes
import javax.swing.*;          // Swing components and classes
import javax.swing.border.*;   // Borders for Swing components
import java.awt.event.*;       // Basic event handling
import javax.media.jai.*;
import java.awt.image.renderable.ParameterBlock;
import java.awt.*;

import java.util.*;
import java.io.*;

class mycv extends Canvas {

    public mycv() {
	super();
	setSize(100,100);
    }

    public void paint(Graphics g) {
	paintJAI(g); // use paintIt to not use JAI, use paintJAI to use JAI
    }

    public void paintIt(Graphics g) {
	Graphics2D g2 = (Graphics2D) g;
	Shape oldclip = g2.getClip();
	g2.setPaint(Color.black);
	g2.drawLine(0,0,99,99);
	g2.setClip(40,20,30,10);
	Font font = new Font("SansSerif", 0, (int) 9);
	g2.setFont(font);
	g2.drawString("Too long a string to fit the Clip Region",
		      40,30);
	g2.setClip(oldclip);
    }

    public void paintJAI(Graphics g) {
        Byte[] bandValues = new Byte[3];
        bandValues[0] = new Byte((byte)255);
        bandValues[1] = new Byte((byte)255);
        bandValues[2] = new Byte((byte)255);

        ParameterBlock pb;

        pb = new ParameterBlock();
        pb.add(new Float(100));   // The width
        pb.add(new Float(100));  // The height
        pb.add(bandValues);                   // The band values

        PlanarImage img = JAI.create("constant", pb);
        TiledImage  customer  = new TiledImage(img, false);

        Graphics2D g2 =  customer .createGraphics();
        paintIt((Graphics) g2);

	((Graphics2D)g).drawRenderedImage( customer , new java.awt.geom.AffineTransform());
	g2.dispose();
	 customer .dispose();
	img.dispose();
    }
}


public class gui {
    public static void main(String[] args) throws Exception{
	JFrame win = new JFrame("Test");
	
	Canvas cv = new mycv();
	win.getContentPane().setLayout(new BorderLayout());
	win.getContentPane().add(cv, "Center");

	win.pack();
	win.show();
    }
}


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

CUSTOMER WORKAROUND :
Do not use JAI, clip by hand (nasty, error prone)
(Review ID: 181388) 
======================================================================
Work Around
N/A
Evaluation
N/A
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang