Search in sources :

Example 1 with FlameMovieReader

use of org.jwildfire.create.tina.io.FlameMovieReader in project JWildfire by thargor6.

the class TinaSWFAnimatorController method movieFromDiscButton_clicked.

public void movieFromDiscButton_clicked() {
    try {
        JFileChooser chooser = new JWFMovieFileChooser(prefs);
        if (prefs.getInputJWFMoviePath() != null) {
            try {
                chooser.setCurrentDirectory(new File(prefs.getInputJWFMoviePath()));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        if (chooser.showOpenDialog(swfAnimatorFlamesPanel) == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            FlameMovie movie = new FlameMovieReader(prefs).readMovie(file.getAbsolutePath());
            if (movie != null) {
                randomBatch.add(0, new MovieThumbnail(movie, null));
                currMovie = movie;
                updateThumbnails();
            }
            refreshControls();
            previewFlameImage();
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) FlameMovieReader(org.jwildfire.create.tina.io.FlameMovieReader) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) File(java.io.File)

Example 2 with FlameMovieReader

use of org.jwildfire.create.tina.io.FlameMovieReader in project JWildfire by thargor6.

the class JWFMovieFilePreview method createThumbnail.

public void createThumbnail() {
    if (currFile == null) {
        currThumbnail = null;
        return;
    }
    try {
        if (currFile.exists()) {
            FlameMovie movie = new FlameMovieReader(prefs).readMovie(currFile.getAbsolutePath());
            Flame flame = null;
            if (movie != null) {
                for (FlameMoviePart part : movie.getParts()) {
                    if (part.getFlame() != null) {
                        flame = part.getFlame();
                        break;
                    }
                }
            }
            if (flame != null) {
                int imgWidth = this.getPreferredSize().width;
                int imgHeight = this.getPreferredSize().height;
                double wScl = (double) imgWidth / (double) flame.getWidth();
                double hScl = (double) imgHeight / (double) flame.getHeight();
                flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
                flame.setWidth(imgWidth);
                flame.setHeight(imgHeight);
                FlameRenderer renderer = new FlameRenderer(flame, prefs, false, true);
                renderer.setProgressUpdater(null);
                flame.setSampleDensity(50);
                flame.setSpatialFilterRadius(0.0);
                RenderInfo info = new RenderInfo(imgWidth, imgHeight, RenderMode.PREVIEW);
                RenderedFlame res = renderer.renderFlame(info);
                currThumbnail = new ImageIcon(res.getImage().getBufferedImg());
            }
        }
    } catch (Exception ex) {
        currThumbnail = null;
        if (ex.getCause() != null) {
            ex.getCause().printStackTrace();
        } else {
            ex.printStackTrace();
        }
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) FlameMovieReader(org.jwildfire.create.tina.io.FlameMovieReader) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 3 with FlameMovieReader

use of org.jwildfire.create.tina.io.FlameMovieReader in project JWildfire by thargor6.

the class TinaSWFAnimatorController method movieFromClipboardButton_clicked.

public void movieFromClipboardButton_clicked() {
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                String xml = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
                FlameMovie movie = new FlameMovieReader(prefs).readMovieFromXML(xml);
                if (movie != null) {
                    randomBatch.add(0, new MovieThumbnail(movie, null));
                    currMovie = movie;
                    updateThumbnails();
                }
                refreshControls();
                previewFlameImage();
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameMovieReader(org.jwildfire.create.tina.io.FlameMovieReader) Transferable(java.awt.datatransfer.Transferable) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) Clipboard(java.awt.datatransfer.Clipboard)

Aggregations

FlameMovie (org.jwildfire.create.tina.animate.FlameMovie)3 FlameMovieReader (org.jwildfire.create.tina.io.FlameMovieReader)3 Clipboard (java.awt.datatransfer.Clipboard)1 Transferable (java.awt.datatransfer.Transferable)1 File (java.io.File)1 ImageIcon (javax.swing.ImageIcon)1 JFileChooser (javax.swing.JFileChooser)1 FlameMoviePart (org.jwildfire.create.tina.animate.FlameMoviePart)1 Flame (org.jwildfire.create.tina.base.Flame)1 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)1 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1