Hi,
I am trying to render a tiled OffScreen image onto a JPanel one tile at a time.  It works fine if I use the AWT Canvas or it even works if its a JPanel added into a AWT ScrollPane but doesn't work if its pure swing. In a swing component it waits for all the tiles to be loaded before it draws it onto the JPanel. Is it possibly because the computing thread hanging. I have attached my paint method for the JPanel below. It might give you some idea of what I want to do. I can't figure out what's wrong. Hope you can give some suggestions. Any help is appreciated.
 
Thanks,
Regards,
Praveen
******************************************************************************
public synchronized void paintComponent(Graphics g) {
   Graphics2D g2D  = (Graphics2D)g;
   Rectangle clipBounds = g.getClipBounds();
   txmin = XtoTileX(clipBounds.x);
   txmax = XtoTileX(clipBounds.x + clipBounds.width - 1);
   tymin = YtoTileY(clipBounds.y);
   tymax = YtoTileY(clipBounds.y + clipBounds.height - 1);
   AffineTransform transform = AffineTransform.getTranslateInstance(0 , 0 );
   offScrGraphics.drawRenderedImage(im.getSubImage(txmin, tymin, clipBounds.width, clipBounds.height), transform);
   shape i;
   int num_annotations = list.size();
   for(int i1 = 0; i1 < num_annotations; i1++) {
      i = (shape)list.get(i1);
      i.paint(offScrGraphics);
   }
   for (tj = tymin; tj <= tymax; tj++) {
      for (ti = txmin; ti <= txmax; ti++) {
         AffineTransform transform1 = AffineTransform.getTranslateInstance(0 , 0 );
         g2D.drawRenderedImage(offScrTile.getSubImage(ti*tileWidth , tj*tileHeight, tileWidth , tileHeight), transform1);
      }
   }
}


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Reply via email to