t.draw(g, gx, gy, zoom); if (showGrid) {
if(layer.getClass() == SelectionLayer.class) { g.fillPolygon(gridPoly); paintEdge(layer,gx,gy,g); } else { t.draw(g, gx, gy, zoom);
    protected void paint(Graphics g, MapLayer layer, double zoom) {        // TODO: Do this right so there is no overdraw.        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,                                         RenderingHints.VALUE_ANTIALIAS_ON);        boolean showGrid = ((modeFlags & PF_GRIDMODE) != 0);        // Determine tile size and offset        Dimension tileSize = getTileSize(zoom);        int tsize_width_delta = tileSize.width / 2;        int tsize_height_delta = tileSize.height / 2;        // Determine area to draw from clipping rectangle        Rectangle clipRect = g.getClipBounds();        clipRect.height += myMap.getTileHeightMax()*zoom - tileSize.height;        int logical_row_max=(clipRect.y+clipRect.height)/(tsize_height_delta)+1;        int originx = (myMap.getHeight() - 1) * (tileSize.width / 2);        // Draw this map layer        for(int logical_row = Math.max(clipRect.y/tsize_height_delta-1,0); logical_row<logical_row_max;logical_row++) {            int x = Math.max(logical_row-(myMap.getHeight()-1),0);            int y = Math.min(logical_row,myMap.getHeight()-1);            int gx = Math.abs(originx - logical_row * tsize_width_delta);            int gy = (logical_row * tsize_height_delta) /*- clipRect.y*/;            Polygon gridPoly = createGridPolygon(gx, gy, 1);            while (x <= Math.min(logical_row, myMap.getWidth() - 1) &&                    y >= Math.max(logical_row-(myMap.getWidth() - 1), 0)) {                Tile t = layer.getTileAt(x, y);                if (t != null && t != myMap.getNullTile()) {                    t.draw(g, gx, gy, zoom);                    if (showGrid) {                        //TODO: create a system that the user can use to highlight tiles with certain properties (search)                        /*if ((t.getFlags() & Tile.T_IMPASSABLE) != 0) {                          g.setColor(Color.red);                          g.drawPolygon(gridPoly);                          }*/                    }                }                x++;                y--;                gx += tileSize.width;                gridPoly.translate(tileSize.width, 0);                    }        }    }