2 Replies Latest reply: Jul 14, 2010 4:19 PM by 843802 RSS

    Composite class creation : not implemented yet Exception

      Hi everyone !

      I'm trying to create my own Composite and a CompositeContext inside class.
      These classes will provide methods to blend colors for graphic drawing.

      Unfortunately when I compile my code an Exception is thrown :
      Exception in thread "AWT-EventQueue-0" java.lang.InternalError: not implemented yet
           at sun.java2d.windows.GDIWindowSurfaceData.getRaster(Unknown Source)
           at sun.java2d.pipe.GeneralCompositePipe.renderPathTile(Unknown Source)
           at sun.java2d.pipe.SpanShapeRenderer$Composite.renderBox(Unknown Source)
           at sun.java2d.pipe.SpanShapeRenderer.renderRect(Unknown Source)
           at sun.java2d.pipe.SpanShapeRenderer.fill(Unknown Source)
           at sun.java2d.pipe.PixelToShapeConverter.fillRect(Unknown Source)
           at sun.java2d.pipe.ValidatePipe.fillRect(Unknown Source)
           at sun.java2d.SunGraphics2D.fillRect(Unknown Source)
           at Main.paint(Main.java:47)
           at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
           at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
           at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
           at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
           at java.awt.event.InvocationEvent.dispatch(Unknown Source)
           at java.awt.EventQueue.dispatchEvent(Unknown Source)
           at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
           at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
           at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
           at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
           at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
           at java.awt.EventDispatchThread.run(Unknown Source)
      Here is my Main :
      import java.awt.Color;
      import java.awt.Composite;
      import java.awt.Dimension;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.Toolkit;
      import javax.swing.JFrame;
      public class Main extends JFrame
           public static final int WIDTH = 640;
           public static final int HEIGHT= 480;     
           public Main()
                super("Composite ex.");          
           private void centerAndSize()
                Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                int x = (screen.width - WIDTH) / 2;
                int y = (screen.height- HEIGHT)/ 2;
                setBounds(x, y, WIDTH, HEIGHT);
           public void paint(Graphics g)
                Graphics2D graphics = (Graphics2D)g;
                graphics.setColor( Color.ORANGE );
                graphics.fillRect(0, 0, 250, 250);
                Composite c = graphics.getComposite();
                graphics.setComposite( new BlendComposite() );
                graphics.setColor( Color.BLUE );
                graphics.fillRect(50, 50, 250, 250);
            * @param args
           public static void main(String[] args)
                new Main();
      Here is my own Composite class :
      import java.awt.Composite;
      import java.awt.CompositeContext;
      import java.awt.RenderingHints;
      import java.awt.image.ColorModel;
      import java.awt.image.Raster;
      import java.awt.image.WritableRaster;
      public class BlendComposite implements Composite
           private static CompositeContext CONTEXT;
           public CompositeContext createContext(ColorModel srcColorModel,
                     ColorModel dstColorModel, RenderingHints hints)
                if(CONTEXT == null)
                     CONTEXT = new BlendContext();
                return CONTEXT;
           private class BlendContext implements CompositeContext
                private static final int BUFFER_SIZE = 64;
                public BlendContext()
                public void compose(Raster src, Raster dstIn, WritableRaster dstOut)
                     for(int y = dstOut.getMinY(); y < dstOut.getHeight(); y++)
                          for(int x = dstOut.getMinY(); x < dstOut.getWidth(); x++)
                               int pixsrc[] = new int[BUFFER_SIZE];
                               int pixin[]  = new int[BUFFER_SIZE];
                               src.getPixel(x, y, pixsrc);
                               dstIn.getPixel(x, y, pixin);
                               int res[] = new int [BUFFER_SIZE];
                               for(int i = 0; i < BUFFER_SIZE; i++)
                                    res[i] = (pixsrc[i] + pixin) / 2;
                               dstOut.setPixel(x, y, res);

                public void dispose()

      I searched everywhere I could to find a solution but I found nothing.
      I heard that it was a Java bug, is that true ?
      How can I solve this problem otherwise ?
      +NB : I use the Eclipse IDE+