for(int k=clip.y;k<=clip.height;k+=10,alt++) { for(int l=clip.x;l<=clip.width;l+=10, alt++) {
for(int k=clip.y-clip.y%side;k<=Math.max(10, (clip.y+clip.height/10)*10);k+=side,alt++) { for(int l=1;l<=Math.max(10, (getWidth()/10)*10)+10;l+=side, alt++) {
    public void paint(Graphics g) {        Rectangle clip = g.getClipBounds();        // Draw checkerboard background        int alt=1;        for(int k=clip.y;k<=clip.height;k+=10,alt++) {            for(int l=clip.x;l<=clip.width;l+=10, alt++) {                if(alt%2 == 1) g.setColor(Color.LIGHT_GRAY);                else g.setColor(Color.WHITE);                g.fillRect(l,k,10,10);            }            if(clip.width%2!=0) alt++;        }        if (tilesets.size() <= 0) {            return;        }        // TODO: In its current form this code doesn't take into account gabs        // in the tileset (tile ids without associated tiles), causing it to        // draw the gabs and leave out tiles at the end.        for (int i = 0; i < tilesets.size(); i++) {            TileSet tileset = (TileSet)tilesets.get(i);            if (tileset != null) {					                // Draw the tiles                int twidth = tileset.getStandardWidth() + 1;                int maxHeight = tileset.getTileHeightMax() + 1;                int tilesPerRow = Math.max(1, (getWidth() - 1) / twidth);                int startY = clip.y / maxHeight;                int endY = ((clip.y + clip.height) / maxHeight) + 1;                int tileAt = tilesPerRow * startY;                for (int y = startY, gy = startY * maxHeight; y < endY; y++) {                    for (int x = 0, gx = 1; x < tilesPerRow; x++) {                        Tile tile = tileset.getTile(tileAt);                        if (tile != null) {                            tile.drawRaw(g,                                    gx,                                    gy + (maxHeight - tile.getHeight()), 1.0);                        }                        gx += twidth;                        tileAt++;                    }                    gy += maxHeight;                }            }        }    }