drawSliceBackground();
}
private void drawSliceBackground() {
setBackgroundBrush(new QBrush(QColor.black));
//Create transparent QPixmap that accepts hovers
// so that moveMouseEvent is triggered
QPixmap qpm = new QPixmap(new QSize((numCols + 1) * (tileSize + 1),
(numRows + 1) * (tileSize + 1)));
qpm.fill(new QColor(255, 255,255, 0));
QGraphicsPixmapItem background = addPixmap(qpm);
background.setAcceptsHoverEvents(true);
background.setZValue(-1);
// Draw colored tiles onto QImage
qImage = new QImage(new QSize((numCols + 1) * (tileSize + 1),
(numRows + 1) * (tileSize + 1)), Format.Format_RGB16);
QPainter painter = new QPainter(qImage);
painter.setPen(new QPen(QColor.black, lineWidth));
// Draw lines between tiles
for (int i = 0; i <= numCols; i++) {
painter.drawLine((i) * tileSize, tileSize, (i) * tileSize,
(numRows) * tileSize);
}
for (int j = 0; j <= numRows; j++) {
painter.drawLine(tileSize, (j) * tileSize, (numCols) * tileSize,
(j) * tileSize);
}
for (int i = 0; i < numRows; i++) {
for (int j = 0; j < numCols; j++) {
Tile tile = device.getTile(i, j);
String name = tile.getName();
int hash = name.hashCode();
int idx = name.indexOf("_");
if (idx != -1) {
hash = name.substring(0, idx).hashCode();
}
QColor color = QColor.fromRgb(hash);
if (name.startsWith("DSP")) {
// color = QColor.fromRgb(145, 145, 145);
color = QColor.darkCyan;
} else if (name.startsWith("BRAM")) {
// color = QColor.fromRgb(165, 165, 165);
color = QColor.darkMagenta;
} else if (name.startsWith("INT")) {
// color = QColor.fromRgb(125, 125, 125);
color = QColor.darkYellow;
} else if (name.startsWith("CLB")) {
color = QColor.blue;
// color = QColor.fromRgb(185, 185, 185);
} else if (name.startsWith("DCM")) {
// color = QColor.fromRgb(205, 205, 205);
} else if (name.startsWith("EMPTY")) {
// color = QColor.white;
} else {
// color = QColor.black;
}
painter.fillRect(j * tileSize, i * tileSize, tileSize - 2, tileSize - 2, new QBrush(color));
}
}
painter.end();