Beispiel #1
0
 private boolean deleteOverlayRoi(ImagePlus imp) {
   if (imp == null) return false;
   Overlay overlay = null;
   ImageCanvas ic = imp.getCanvas();
   if (ic != null) overlay = ic.getShowAllList();
   if (overlay == null) overlay = imp.getOverlay();
   if (overlay == null) return false;
   Roi roi = imp.getRoi();
   for (int i = 0; i < overlay.size(); i++) {
     Roi roi2 = overlay.get(i);
     if (roi2 == roi) {
       overlay.remove(i);
       imp.deleteRoi();
       ic = imp.getCanvas();
       if (ic != null) ic.roiManagerSelect(roi, true);
       return true;
     }
   }
   return false;
 }
Beispiel #2
0
  /**
   * This will overlay a document and write out the results.<br>
   * <br>
   * usage: java PDF.Overlay &lt;overlay.pdf&gt; &lt;document.pdf&gt; &lt;result.pdf&gt;
   *
   * @param args The command line arguments.
   * @throws IOException If there is an error reading/writing the document.
   * @throws COSVisitorException If there is an error writing the document.
   */
  public static void main(String[] args) throws IOException, COSVisitorException {
    if (args.length != 3) {
      usage();
      System.exit(1);
    } else {
      PDDocument overlay = null;
      PDDocument pdf = null;

      try {
        overlay = getDocument(args[0]);
        pdf = getDocument(args[1]);
        Overlay overlayer = new Overlay();
        overlayer.overlay(overlay, pdf);
        writeDocument(pdf, args[2]);
      } finally {
        if (overlay != null) {
          overlay.close();
        }
        if (pdf != null) {
          pdf.close();
        }
      }
    }
  }