Examples of QPainter


Examples of com.trolltech.qt.gui.QPainter

    background.setAcceptsHoverEvents(true);
    background.setZValue(-1);
   
    // Draw colored tiles onto QPixMap
    qImage = new QImage(sceneSize, Format.Format_RGB16);
    QPainter painter = new QPainter(qImage);

    // 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);
       
        int rectX = x * tileSize;
        int rectY = y * tileSize;
        int rectSide = tileSize - 2 * offset;

        if(drawPrimitives){
          if(Utils.isCLB(tileType)){
            drawCLB(painter, rectX, rectY, rectSide);
          }else if(Utils.isSwitchBox(tileType)){
            drawSwitchBox(painter, rectX, rectY, rectSide);
          }else if(Utils.isBRAM(tileType)){
            drawBRAM(painter, rectX, rectY, rectSide, offset, color);
          }else if(Utils.isDSP(tileType)){
            drawDSP(painter, rectX, rectY, rectSide, offset, color);
          }else{ // Just fill the tile in with a color
            colorTile(painter, x, y, offset, color);
          }         
        }
        else{
          colorTile(painter, x, y, offset, color);
        }
      }
    }

    painter.end();
  }
View Full Code Here

Examples of com.trolltech.qt.gui.QPainter

    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();
   
  }
View Full Code Here

Examples of com.trolltech.qt.gui.QPainter

    String xml = recoData.toString();
   
    // Get a painter for the image.  This is the background (the initial image).
      QPixmap pix = new QPixmap(f.fileName());
      QPixmap hilightedPix = new QPixmap(pix.size());
      QPainter p = new QPainter(hilightedPix);
      p.drawPixmap(0,0, pix);

      // Create a transparent pixmap.  The only non-transparent
      // piece is the hilight that will be overlayed to hilight text no the background
      QPixmap overlayPix = new QPixmap(pix.size());
      overlayPix.fill(QColor.transparent);
      QPainter p2 = new QPainter(overlayPix);
      p2.setBackgroundMode(BGMode.TransparentMode);
      p2.setRenderHint(RenderHint.Antialiasing, true);
    QColor yellow = QColor.yellow;
//    yellow.setAlphaF(0.4);
      p2.setBrush(yellow);
 
    // Get the recognition data from the note
      QDomDocument doc = new QDomDocument();
      doc.setContent(xml);
     
      // Go through all "item" nodes
    QDomNodeList anchors = doc.elementsByTagName("item");
    for (int i=0; i<anchors.length(); i++) {
      QDomElement element = anchors.at(i).toElement();
      int x = new Integer(element.attribute("x"));   // x coordinate
      int y = new Integer(element.attribute("y"));   // y coordinate
      int w = new Integer(element.attribute("w"));   // width
      int h = new Integer(element.attribute("h"));   // height
      QDomNodeList children = element.childNodes()// all children ("t" nodes).
     
      // Go through the children ("t" nodes)
      for (int j=0; j<children.length(); j++) {
          QDomElement child = children.at(j).toElement();
          if (child.nodeName().equalsIgnoreCase("t")) {
            String text = child.text();   // recognition text
            int weight = new Integer(child.attribute("w"))// recognition weight
            if (weight >= Global.getRecognitionWeight()) {   // Are we above the maximum?
             
              // Check to see if this word matches something we were searching for.
              for (int k=0; k<enSearch.hilightWords.size(); k++) {
                String searchWord = enSearch.hilightWords.get(k).toLowerCase();
                if (searchWord.startsWith("*"))
                  searchWord = searchWord.substring(1);
                if (searchWord.endsWith("*"))
                  searchWord = searchWord.substring(0,searchWord.length()-1);
                if (text.toLowerCase().contains(searchWord)) {
                  p2.drawRect(x,y,w,h);     
                }
              }
            }
          }
      }
    }
      p2.end();
     
      // Paint the hilight onto the background.
      p.setOpacity(0.4);
      p.drawPixmap(0,0, overlayPix);
      p.end();
View Full Code Here

Examples of com.trolltech.qt.gui.QPainter

      return null;
    }
//    page.setViewportSize(page.mainFrame().contentsSize());
//    image = new QImage(size, Format.Format_ARGB32);
    logger.log(logger.EXTREME, "Creating painter");
    painter = new QPainter();
    logger.log(logger.EXTREME, "Beginning painter");
        painter.begin(image);
        page.mainFrame().setZoomFactor(new Double(zoom));
      if (painter.paintEngine() == null) {
        logger.log(logger.EXTREME, "Bad paint engine.  Aborting");
View Full Code Here

Examples of com.trolltech.qt.gui.QPainter

        synchronizeIconAngle = 0;
          QPixmap pix = new QPixmap(iconPath+"synchronize.png");
        syncIcons.add(pix);
        for (int i=0; i<=360; i++) {
          QPixmap rotatedPix = new QPixmap(pix.size());
          QPainter p = new QPainter(rotatedPix);
            rotatedPix.fill(toolBar.palette().color(ColorRole.Button));
            QSize size = pix.size();
            p.translate(size.width()/2, size.height()/2);
            angle = angle+1.0;
            p.rotate(angle);
            p.setBackgroundMode(BGMode.OpaqueMode);
            p.translate(-size.width()/2, -size.height()/2);
            p.drawPixmap(0,0, pix);
            p.end();
            syncIcons.add(rotatedPix);
        }
      }

      synchronizeIconAngle++;
View Full Code Here

Examples of com.trolltech.qt.gui.QPainter

    int screen = desktop.screenNumber();
    this.setMaximumSize(desktop.size());
    this.setMinimumSize(desktop.size());
    resize(desktop.size());
   
    QPainter painter = new QPainter(this);
   
    painter.fillRect(desktop.screenGeometry(screen), QColor.black);

    QRect availGeo = desktop.availableGeometry(screen);
   
    int x1 = (availGeo.width()/2)-(image.size().width()/2);
    int y1 = (availGeo.height()/2)-(image.size().height()/2);
   
    painter.drawImage(new QPoint(x1,y1), image);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.