Package com.lowagie.toolbox.swing

Examples of com.lowagie.toolbox.swing.EventDispatchingThread


    total_number_of_pictures = 0;
    try {
      if (getValue("srcfile") == null)
        throw new InstantiationException(
            "You need to choose a sourcefile");
      EventDispatchingThread task = new EventDispatchingThread() {
        public Object construct() {
          try {
            PdfReader reader = new PdfReader(
                ((File) getValue("srcfile")).getAbsolutePath());
            for (int i = 0; i < reader.getXrefSize(); i++) {
              PdfObject pdfobj = reader.getPdfObject(i);
              if (pdfobj != null) {
                if (pdfobj.isStream()) {
                  PdfStream pdfdict = (PdfStream) pdfobj;
                  PdfObject pdfsubtype = pdfdict
                      .get(PdfName.SUBTYPE);
                  if (pdfsubtype == null) {
                    continue;
                  }
                  if (!pdfsubtype.toString().equals(
                      PdfName.IMAGE.toString())) {
                    continue;
                  }
                  System.out.println("total_number_of_pictures: "
                      + total_number_of_pictures);
                  System.out.println("height:"
                      + pdfdict.get(PdfName.HEIGHT));
                  System.out.println("width:"
                      + pdfdict.get(PdfName.WIDTH));
                  System.out.println("bitspercomponent:"
                      + pdfdict.get(PdfName.BITSPERCOMPONENT));
                  byte[] barr = PdfReader
                      .getStreamBytesRaw((PRStream) pdfdict);
                  java.awt.Image im = Toolkit
                      .getDefaultToolkit().createImage(barr);
                  javax.swing.ImageIcon ii = new javax.swing.ImageIcon(im);

                  JLabel label = new JLabel();
                  label.setIcon(ii);
                  image_panel.add(label, String.valueOf(total_number_of_pictures++));
                }
              }
            }
          } catch (InstantiationException ex) {
          } catch (IOException ex) {
          }
          internalFrame.setCursor(Cursor.getDefaultCursor());
          return null;
        }
      };
      internalFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      task.start();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(internalFrame, e.getMessage(), e
          .getClass().getName(), JOptionPane.ERROR_MESSAGE);
      System.err.println(e.getMessage());
    }
View Full Code Here


    total_number_of_pictures = 0;
    try {
      if (getValue("srcfile") == null)
        throw new InstantiationException(
            "You need to choose a sourcefile");
      EventDispatchingThread task = new EventDispatchingThread() {
        public Object construct() {
          try {
            PdfReader reader = new PdfReader(
                ((File) getValue("srcfile")).getAbsolutePath());
            for (int i = 0; i < reader.getXrefSize(); i++) {
              PdfObject pdfobj = reader.getPdfObject(i);
              if (pdfobj != null) {
                if (pdfobj.isStream()) {
                  PdfStream pdfdict = (PdfStream) pdfobj;
                  PdfObject pdfsubtype = pdfdict
                      .get(PdfName.SUBTYPE);
                  if (pdfsubtype == null) {
                    continue;
                  }
                  if (!pdfsubtype.toString().equals(
                      PdfName.IMAGE.toString())) {
                    continue;
                  }
                  System.out.println("total_number_of_pictures: "
                      + total_number_of_pictures);
                  System.out.println("height:"
                      + pdfdict.get(PdfName.HEIGHT));
                  System.out.println("width:"
                      + pdfdict.get(PdfName.WIDTH));
                  System.out.println("bitspercomponent:"
                      + pdfdict.get(PdfName.BITSPERCOMPONENT));
                  byte[] barr = PdfReader
                      .getStreamBytesRaw((PRStream) pdfdict);
                  java.awt.Image im = Toolkit
                      .getDefaultToolkit().createImage(barr);
                  javax.swing.ImageIcon ii = new javax.swing.ImageIcon(im);

                  JLabel label = new JLabel();
                  label.setIcon(ii);
                  image_panel.add(label, String.valueOf(total_number_of_pictures++));
                }
              }
            }
          } catch (InstantiationException ex) {
          } catch (IOException ex) {
          }
          internalFrame.setCursor(Cursor.getDefaultCursor());
          return null;
        }
      };
      internalFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      task.start();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(internalFrame, e.getMessage(), e
          .getClass().getName(), JOptionPane.ERROR_MESSAGE);
      System.err.println(e.getMessage());
    }
View Full Code Here

TOP

Related Classes of com.lowagie.toolbox.swing.EventDispatchingThread

Copyright © 2018 www.massapicom. 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.