Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4833528

InternalException, "not yet implemented" thrown with CustomComposite

XMLWordPrintable

    • 2d
    • Fix Understood
    • x86
    • windows_nt, windows_xp

      Name: rmT116609 Date: 03/17/2003


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

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      ATI Rage Mobility 7200


      A DESCRIPTION OF THE PROBLEM :
      Exception dump:
      java.lang.InternalError: not implemented yet
         at sun.awt.windows.Win32OffScreenSurfaceData.getRaster
         at sun.java2d.pipe.GeneralCompositePipe.renderPathTile
         at sun.java2d.pipe.TextRenderer.drawGlyphList
         at sun.java2d.pipe.GlyphListPipe.drawGlyphVector
         at sun.java2d.SunGraphics2D.drawGlyphVector

      Our Code:


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the sample code as java -cp . Test

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The string should render without exception.
      An exception is thrown, see Error Messages

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception dump:
      java.lang.InternalError: not implemented yet
         at sun.awt.windows.Win32OffScreenSurfaceData.getRaster
         at sun.java2d.pipe.GeneralCompositePipe.renderPathTile
         at sun.java2d.pipe.TextRenderer.drawGlyphList
         at sun.java2d.pipe.GlyphListPipe.drawGlyphVector
         at sun.java2d.SunGraphics2D.drawGlyphVector


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.image.*;
      import java.awt.font.*;
      import java.awt.geom.*;
      import javax.swing.*;

      public class Test
      {
         public static void main(String[] args)
         {
            TestPanel panel = new TestPanel();
            JDialog dialog = new JDialog();
            dialog.getContentPane().add(panel);
            dialog.setSize(400,400);
            dialog.setVisible(true);
         }
      }

      class TestPanel extends JPanel
      {
         /** We override the paint method to handle all painting our selves */
         public void paint(Graphics p_graphics)
         {
            // Convert the passing graphics to the Graphics2D object that is must be
            Graphics2D g = (Graphics2D)p_graphics;
            
            // Get the size we are working with
            Dimension size = getSize();
            
            // Render the page
            g.setComposite(ORComposite.DEFAULT);

            String testString = "Testing String...";
            float x = 20;
            float advance = 0.10f;
            FontRenderContext frc = g.getFontRenderContext();
            Font font = g.getFont();
            char[] c = new char[1];
            for (int i = 0; i < testString.length(); i++)
            {
               c[0] = testString.charAt(i);
               GlyphVector gv = font.createGlyphVector(frc, c);
               g.drawGlyphVector(gv, x, 20);
               x += advance;
            }
         }
      }

      /** Returns the CompositeContext that will correctly
       * handle summing the source and destination pixels in a way that mirrors ink
       * being put down on a page. The standard composites could not support this
       * behavior since we are not working with semi-transparent color and using
       * the alpha channel was not going to work. */
      class ORComposite implements Composite
      {
         /** Only one of these is, so a static object is creatd. */
         public final static ORComposite DEFAULT = new ORComposite();
         
         /** Create the CompositeContext that will be used. It keeps no state, so
          * we really only need one of them. Since this class is a Singleton, there
          * will only be one instance of CompositContext created as only one
          * Composite is created */
         private final ORCompositeContext m_context = new ORCompositeContext();
         
         /** The class is a singleton, so the constuctor is hidden as a private. */
         private ORComposite()
         {
         }
        
         /** Return the composite the implements the ink paradigm */
         public CompositeContext createContext(ColorModel p_sCM, ColorModel p_dCM,
                                               RenderingHints p_hints)
         {
            return m_context;
         }

         /** Implements the idea of a composite that mirrors putting ink down on a
          * piece of paper. */
         class ORCompositeContext implements CompositeContext
         {
            /** There is state kept, so there is nothing to this function. */
            public void dispose()
            {
            }
        
            /** Do the work of composing the souce and the destination into the
             * output raster.
             * @see java.awt.CompositeContext#compose(Raster, Raster, WritableRaster)
             */
            public void compose(Raster p_srcIn, Raster p_dstIn,
                                WritableRaster p_dstOut)
            {
               // Walk the entire destination
               for (int x=0; x < p_dstOut.getWidth(); x++)
               {
                  for (int y = 0; y < p_dstOut.getHeight(); y++)
                  {
                     // Get the source pixels
                     int[] src = new int[4];
                     p_srcIn.getPixel(x, y, src);
                  
                     int[] dst = new int[4];
                     p_dstIn.getPixel(x, y, dst);
                   
                     // Create a logaction for the result
                     int[] result = new int[4];
                  
                     // OR the pixels together
                     // We need to do the ^ 0xFFFFFF to invert the colors since the
                     // screen sees 0xFFFFFF as white and 0x000000 as black, but we
                     // want to sum up the underlying greyscales and make them
                     // darker, as it would work with ink, so everything gets
                     // inverted.
                     result[0] = (src[0] ^ 0xFFFFFF) | (dst[0] ^ 0xFFFFFF);
                     result[0] = result[0] ^ 0xFFFFFF;
                     result[1] = (src[1] ^ 0xFFFFFF) | (dst[1] ^ 0xFFFFFF);
                     result[1] = result[1] ^ 0xFFFFFF;
                     result[2] = (src[2] ^ 0xFFFFFF) | (dst[2] ^ 0xFFFFFF);
                     result[2] = result[2] ^ 0xFFFFFF;

                     // Set the pixel with the values we have calulated
                     p_dstOut.setPixel(x, y, result);
                  }
               }
            }
         }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Passing in sun.java2d.noddraw=true flag will work, but this is completely
      unacceptabel as a work around since we cannot expect out client base to
      be using the Java Control Panel to set this value, and we cannot set the
      value from the Object tag used to load the applet.
      (Review ID: 182679)
      ======================================================================
      ###@###.### 10/21/04 14:52 GMT

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: