public synchronized void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; int w = getWidth(); int h = getHeight(); ... // Draw Background. g2.setBackground(getBackground()); g2.clearRect(0, 0, w, h); g2.setTransform(_worldToView.getTransform()); // Draw Map. switchFromWorldScaleToMapScale(g2); g2.drawImage(backgroundImg, 0, 0, null); switchFromMapScaleToWorldScale(g2); synchronized (_depthOrdering) { for (Iterator it = _depthOrdering.iterator(); it.hasNext();) { MapObject mo = (MapObject)it.next(); mo.paint(g2); } } ... }