cjolif      01/07/03 02:41:14

  Modified:    sources/org/apache/batik/ext/awt/g2d GraphicContext.java
  Log:
  workaround a JDK bug. That bug is:
  
  RenderingHints rh = new RenderingHints(null);
  Object obj = rh.get(RENDER...);
  rh.put(RENDER..., obj);
  
  throws an NPE!!!
  
  Revision  Changes    Path
  1.3       +15 -16    
xml-batik/sources/org/apache/batik/ext/awt/g2d/GraphicContext.java
  
  Index: GraphicContext.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/g2d/GraphicContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GraphicContext.java       2001/03/15 10:39:02     1.2
  +++ GraphicContext.java       2001/07/03 09:41:09     1.3
  @@ -23,8 +23,9 @@
    * + RenderingHints <br>
    * + AffineTransform <br>
    *
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Christophe Jolif</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Hardy</a>
  - * @version $Id: GraphicContext.java,v 1.2 2001/03/15 10:39:02 cjolif Exp $
  + * @version $Id: GraphicContext.java,v 1.3 2001/07/03 09:41:09 cjolif Exp $
    */
   public class GraphicContext implements Cloneable{
       /**
  @@ -99,17 +100,20 @@
       /**
        * Default constructor
        */
  -    public GraphicContext(){
  +    public GraphicContext() {
  +        // to workaround a JDK bug
  +        hints.put(RenderingHints.KEY_RENDERING, 
RenderingHints.VALUE_RENDER_DEFAULT);
       }
   
       /**
        * @param defaultDeviceTransform Default affine transform applied to map the 
user space to the
        *                               user space.
        */
  -    public GraphicContext(AffineTransform defaultDeviceTransform){
  -        this.defaultTransform = new AffineTransform(defaultDeviceTransform);
  -        this.transform = new AffineTransform(defaultTransform);
  -        if(!defaultTransform.isIdentity())
  +    public GraphicContext(AffineTransform defaultDeviceTransform) {
  +        this();
  +        defaultTransform = new AffineTransform(defaultDeviceTransform);
  +        transform = new AffineTransform(defaultTransform);
  +        if (!defaultTransform.isIdentity())
               
transformStack.addElement(TransformStackElement.createGeneralTransformElement(defaultTransform));
       }
   
  @@ -262,9 +266,6 @@
        * @see #setClip(Shape)
        */
       public void clipRect(int x, int y, int width, int height){
  -        // System.out.println("clipRect(" + x + "," + y + "," + width + "," + 
height + ")");
  -        // Exception e = new Exception("");
  -        // e.printStackTrace();
           clip(new Rectangle(x, y, width, height));
       }
   
  @@ -284,7 +285,6 @@
        * @since       JDK1.1
        */
       public void setClip(int x, int y, int width, int height){
  -        System.out.println("setClip(" + x + "," + y + "," + width + "," + height + 
")");
           setClip(new Rectangle(x, y, width, height));
       }
   
  @@ -330,8 +330,8 @@
        * @see         java.awt.Graphics#setClip(int, int, int, int)
        * @since       JDK1.1
        */
  -    public void setClip(Shape clip){
  -        if(clip != null)
  +    public void setClip(Shape clip) {
  +        if (clip != null)
               this.clip = transform.createTransformedShape(clip);
           else
               this.clip = null;
  @@ -795,15 +795,14 @@
        *          this method clears the current <code>Clip</code>.
        */
       public void clip(Shape s){
  -        if(s != null)
  +        if (s != null)
               s = transform.createTransformedShape(s);
   
  -        if(clip != null){
  +        if (clip != null) {
               Area newClip = new Area(clip);
               newClip.intersect(new Area(s));
               clip = new GeneralPath(newClip);
  -        }
  -        else{
  +        } else {
               clip = s;
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to