|
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)
======================================================================
|