while (li.hasNext()) { if ((layer = (MapLayer)li.next()) != null) { float opacity = layer.getOpacity(); if (layer.isVisible() && opacity > 0.0f) { if (opacity < 1.0f) { g2d.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_ATOP, opacity)); } else { g2d.setComposite(AlphaComposite.SrcOver); }  if (layer instanceof TileLayer) { paintLayer(g2d, (TileLayer)layer, currentZoom); } else if (layer instanceof ObjectGroup) { paintLayer(g2d, (ObjectGroup)layer, currentZoom); } } } }
paintSubMap(myMap, g2d, 1.0f);
    public void paintComponent(Graphics g) {        Graphics2D g2d = (Graphics2D)g.create();        TiledConfiguration conf = TiledConfiguration.getInstance();        double currentZoom = zoom;        Iterator li = myMap.getLayers();        MapLayer layer;        Rectangle clip = g2d.getClipBounds();        g2d.setStroke(new BasicStroke(2.0f));        // Do an initial fill with the background color        try {            String colorString = conf.getValue("tiled.background.color");            g2d.setColor(Color.decode(colorString));        } catch (NumberFormatException e) {            g2d.setColor(new Color(64, 64, 64));        }        g2d.fillRect(clip.x, clip.y, clip.width, clip.height);        while (li.hasNext()) {            if ((layer = (MapLayer)li.next()) != null) {                float opacity = layer.getOpacity();                if (layer.isVisible() && opacity > 0.0f) {                    if (opacity < 1.0f) {                        g2d.setComposite(AlphaComposite.getInstance(                                    AlphaComposite.SRC_ATOP, opacity));                    } else {                        g2d.setComposite(AlphaComposite.SrcOver);                    }                    if (layer instanceof TileLayer) {                        paintLayer(g2d, (TileLayer)layer, currentZoom);                    } else if (layer instanceof ObjectGroup) {                        paintLayer(g2d, (ObjectGroup)layer, currentZoom);                    }                }            }        }        if (!getMode(PF_NOSPECIAL)) {            li = myMap.getLayersSpecial();            while (li.hasNext()) {                layer = (MapLayer) li.next();                if (layer.isVisible()) {                    if (layer instanceof SelectionLayer) {                        g2d.setComposite(AlphaComposite.getInstance(                                    AlphaComposite.SRC_ATOP, 0.3f));                        g2d.setColor(                                ((SelectionLayer)layer).getHighlightColor());                    }                    paintLayer(g2d, (TileLayer)layer, currentZoom);                }            }        }        // Grid color (also used for coordinates)        try {            String colorString = conf.getValue("tiled.grid.color");            g2d.setColor(Color.decode(colorString));        } catch (NumberFormatException e) {            g2d.setColor(Color.black);        }        if (getMode(PF_GRIDMODE)) {            // Grid opacity            int opacity = conf.getIntValue("tiled.grid.opacity", 255);            if (opacity < 255) {                g2d.setComposite(AlphaComposite.getInstance(                            AlphaComposite.SRC_ATOP, (float)opacity / 255.0f));            } else {                g2d.setComposite(AlphaComposite.SrcOver);            }            // Configure grid antialiasing            if (conf.keyHasValue("tiled.grid.antialias", 1)) {                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,                        RenderingHints.VALUE_ANTIALIAS_ON);            } else {                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,                        RenderingHints.VALUE_ANTIALIAS_OFF);            }            g2d.setStroke(new BasicStroke());            paintGrid(g2d, currentZoom);        }        if (getMode(PF_COORDINATES)) {            g2d.setComposite(AlphaComposite.SrcOver);            paintCoordinates(g2d, zoom);        }    }