FileDocCategorySizeDatePackage
PictTour.javaAPI DocExample4096Wed Nov 10 12:38:08 GMT 2004com.oreilly.qtjnotebook.ch05

PictTour

public class PictTour extends Object

Fields Summary
static final int[]
imagetypes
static int
frameX
static int
frameY
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


          
        try {
            QTSessionCheck.check();

            // import a graphic
            QTSessionCheck.check();
            QTFile inFile =  QTFile.standardGetFilePreview (imagetypes);
            GraphicsImporter importer =
                new GraphicsImporter (inFile);
            showFrameForImporter (importer,
                                  "Original Import");
            // get a pict object and then save it
            // then load again and show
            Pict pict = importer.getAsPicture();
            String absPictPath = (new File ("pict.pict")).getAbsolutePath();
            File pictFile = new File (absPictPath);
            if (pictFile.exists())
                pictFile.delete();
            try { Thread.sleep (1000); } catch (InterruptedException ie) {}
            pict.writeToFile (pictFile);
            QTFile pictQTFile = new QTFile (pictFile);
            GraphicsImporter pictImporter =
                new GraphicsImporter (pictQTFile);
            showFrameForImporter (pictImporter,
                                  "pict.pict");
            // write to a pict file from importer
            // then load and show it
            String absGIPictPath = (new File ("gipict.pict")).getAbsolutePath();
            QTFile giPictQTFile = new QTFile (absGIPictPath);
            if (giPictQTFile.exists())
                giPictQTFile.delete();
            try { Thread.sleep (1000); } catch (InterruptedException ie) {}
            importer.saveAsPicture (giPictQTFile,
                                    IOConstants.smSystemScript);
            GraphicsImporter giPictImporter =
                new GraphicsImporter (giPictQTFile);
            showFrameForImporter (giPictImporter,
                                  "gipict.pict");
        } catch (Exception e) {
            e.printStackTrace();
        }
    
public static voidshowFrameForImporter(GraphicsImporter gi, java.lang.String frameTitle)

        QTComponent qtc = QTFactory.makeQTComponent (gi);
        Component c = qtc.asComponent();
        Frame f = new Frame (frameTitle);
        f.add (c);
        f.pack();
        if (frameX == -1) {
            frameX = f.getLocation().x;
            frameY = f.getLocation().y;
        } else {
            Point location = new Point (frameX += 20,
                                        frameY += 20);
            f.setLocation (location);
        }

        f.setVisible (true);