示例#1
0
  private static void paintNodeRecursively(PLayer layer, Block node) {
    Rectangle r = node.getBounds();
    PPath rect = PPath.createRectangle(r.x, r.y, r.width, r.height);

    // Color randomColor = new Color(numGen.nextInt(256), numGen.nextInt(256), numGen.nextInt(256));
    // rect.setStrokePaint(randomColor);
    // if (node.isLeaf()){
    if (node.isText()) {
      rect.setStrokePaint(Color.red);
      rect.setPaint(null);
    } else if (node.isLeaf()) {
      rect.setStrokePaint(Color.green);
      // rect.setStrokePaint(Color.red);
      rect.setPaint(Color.green);
      rect.setTransparency(0.3f);
    } else {
      rect.setStrokePaint(Color.cyan);
      rect.setPaint(null);
    }

    layer.addChild(rect);

    for (Block child : node.getChildren()) {
      paintNodeRecursively(layer, child);
    }
  }
示例#2
0
 private static void paintLeafMaskRecursively(IplImage mask, Block node) {
   if (node.isLeaf()) {
     Rectangle r = node.getBounds();
     CvPoint p1 = cvPoint(r.x, r.y);
     CvPoint p2 = cvPoint(r.x + r.width, r.y + r.height);
     cvRectangle(mask, p1, p2, CvScalar.WHITE, CV_FILLED, 8, 0);
   }
   for (Block child : node.getChildren()) {
     paintLeafMaskRecursively(mask, child);
   }
 }
示例#3
0
  public static IplImage paint(IplImage canvas, Block node) {

    if (node == null) return canvas;

    Rectangle r = node.getBounds();
    CvPoint p1 = cvPoint(r.x, r.y);
    CvPoint p2 = cvPoint(r.x + r.width, r.y + r.height);
    cvRectangle(canvas, p1, p2, cvScalar(255, 255, 20, 20), 1, 8, 0);

    for (Block child : node.getChildren()) {
      paint(canvas, child);
    }
    return canvas;
  }