// Determine which columns and rows to not draw
TreeSet<Integer> colsToSkip = new TreeSet<Integer>();
TreeSet<Integer> rowsToSkip = new TreeSet<Integer>();
for(Tile[] tileRow : device.getTiles()){
for(Tile tile : tileRow){
TileType type = tile.getType();
if(tileColumnTypesToHide.contains(type)){
colsToSkip.add(tile.getColumn());
}
if(tileRowTypesToHide.contains(type)){
rowsToSkip.add(tile.getRow());
}
}
}
// Create new tile layout without hidden tiles
int i=0,j=0;
drawnTiles = new Tile[rows-rowsToSkip.size()][cols-colsToSkip.size()];
tileXMap = new HashMap<Tile, Integer>();
tileYMap = new HashMap<Tile, Integer>();
for(int row = 0; row < rows; row++) {
if(rowsToSkip.contains(row)) continue;
for (int col = 0; col < cols; col++) {
if(colsToSkip.contains(col)) continue;
Tile tile = device.getTile(row, col);
drawnTiles[i][j] = tile;
tileXMap.put(tile, j);
tileYMap.put(tile, i);
j++;
}
i++;
j=0;
}
rows = rows-rowsToSkip.size();
cols = cols-colsToSkip.size();
//Draw dashed lines where rows/columns have been removed
QPen missingTileLinePen = new QPen(QColor.lightGray, 2, PenStyle.DashLine);
painter.setPen(missingTileLinePen);
i = 0;
for(int col : colsToSkip){
int realCol = col - i;
painter.drawLine(tileSize*realCol-1, 0, tileSize*realCol-1, rows*tileSize-3);
i++;
}
i=0;
for(int row : rowsToSkip){
int realRow = row - i;
painter.drawLine(0,tileSize*realRow-1, cols*tileSize-3,tileSize*realRow-1);
i++;
}
// Draw the tile layout
int offset = (int) Math.ceil((lineWidth / 2.0));
for(int y = 0; y < rows; y++){
for(int x = 0; x < cols; x++){
Tile tile = drawnTiles[y][x];
TileType tileType = tile.getType();
// Set pen color based on current tile
QColor color = TileColors.getSuggestedTileColor(tile);
painter.setPen(color);