Search in sources :

Example 6 with FlameMoviePart

use of org.jwildfire.create.tina.animate.FlameMoviePart 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 7 with FlameMoviePart

use of org.jwildfire.create.tina.animate.FlameMoviePart in project JWildfire by thargor6.

the class TinaSWFAnimatorController method refreshControls.

protected void refreshControls() {
    noRefresh = true;
    try {
        swfAnimatorFramesPerSecondREd.setValue(currMovie.getFramesPerSecond());
        for (int i = 0; i < globalScripts.size(); i++) {
            ScriptContainer container = globalScripts.get(i);
            setGlobalScriptToUI(currMovie.getGlobalScripts()[i], container.getScriptCmb(), container.getScriptREd());
        }
        for (int i = 0; i < xFormScripts.size(); i++) {
            ScriptContainer container = xFormScripts.get(i);
            setXFormScriptToUI(currMovie.getxFormScripts()[i], container.getScriptCmb(), container.getScriptREd());
        }
        {
            ResolutionProfile fittingProfile = null;
            ResolutionProfile doubleProfile = null;
            for (int i = 0; i < swfAnimatorResolutionProfileCmb.getItemCount(); i++) {
                ResolutionProfile profile = (ResolutionProfile) swfAnimatorResolutionProfileCmb.getItemAt(i);
                if (profile.getWidth() == currMovie.getFrameWidth() && profile.getHeight() == currMovie.getFrameHeight()) {
                    fittingProfile = profile;
                    break;
                } else if ((profile.getWidth() / 2) == currMovie.getFrameWidth() && (profile.getHeight() / 2) == currMovie.getFrameHeight()) {
                    doubleProfile = profile;
                }
            }
            if (fittingProfile != null) {
                swfAnimatorResolutionProfileCmb.setSelectedItem(fittingProfile);
            } else if (doubleProfile != null) {
                swfAnimatorResolutionProfileCmb.setSelectedItem(doubleProfile);
            }
        }
        {
            QualityProfile qualityProfile = null;
            for (int i = 0; i < swfAnimatorQualityProfileCmb.getItemCount(); i++) {
                QualityProfile profile = (QualityProfile) swfAnimatorQualityProfileCmb.getItemAt(i);
                if (qualityProfile == null) {
                    qualityProfile = profile;
                } else if (profile.getQuality() == currMovie.getQuality()) {
                    qualityProfile = profile;
                    break;
                }
            }
            if (qualityProfile != null) {
                swfAnimatorQualityProfileCmb.setSelectedItem(qualityProfile);
            }
        }
        swfAnimatorOutputTypeCmb.setSelectedItem(currMovie.getSequenceOutputType());
        for (JPanel panel : flamePartPanelList) {
            swfAnimatorFlamesPanel.remove(panel);
        }
        flamePartPanelList.clear();
        for (AbstractButton btn : flamePartRadioButtonList) {
            swfAnimatorFlamesButtonGroup.remove(btn);
        }
        flamePartRadioButtonList.clear();
        swfAnimatorFlamesPanel.getParent().validate();
        swfAnimatorFrameSlider.setValue(1);
        swfAnimatorFrameSlider.setMaximum(currMovie.getFrameCount());
        int frameCount = currMovie.getFrameCount();
        swfAnimatorFramesREd.setValue(frameCount);
        swfAnimatorFrameREd.setValue(1);
        swfAnimatorFrameREd.setMaxValue(frameCount);
        swfAnimatorMotionBlurLengthREd.setValue(currMovie.getMotionBlurLength());
        swfAnimatorMotionBlurTimeStepREd.setValue(currMovie.getMotionBlurTimeStep());
        for (FlameMoviePart part : currMovie.getParts()) {
            addFlameToFlamePanel(part);
        }
        enableControls();
    } finally {
        noRefresh = false;
    }
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) JPanel(javax.swing.JPanel) AbstractButton(javax.swing.AbstractButton) QualityProfile(org.jwildfire.base.QualityProfile) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart)

Example 8 with FlameMoviePart

use of org.jwildfire.create.tina.animate.FlameMoviePart in project JWildfire by thargor6.

the class TinaSWFAnimatorController method addFlame.

private void addFlame(Flame pFlame) {
    boolean firstPart = currMovie.getParts().size() == 0;
    int frameCount, frameMorphCount;
    if (firstPart) {
        if (pFlame.getMotionBlurLength() > 0) {
            swfAnimatorMotionBlurLengthREd.setValue(pFlame.getMotionBlurLength());
            swfAnimatorMotionBlurTimeStepREd.setValue(pFlame.getMotionBlurTimeStep());
        }
        frameCount = 120;
        frameMorphCount = 60;
    } else {
        FlameMoviePart prevPart = currMovie.getParts().get(currMovie.getParts().size() - 1);
        frameCount = prevPart.getFrameCount();
        frameMorphCount = prevPart.getFrameMorphCount();
    }
    FlameMoviePart part = new FlameMoviePart();
    part.setFlame(pFlame);
    part.setFrameCount(frameCount);
    part.setFrameMorphCount(frameMorphCount);
    addFlameToFlamePanel(part);
    currMovie.addPart(part);
    refreshFrameCount();
    previewFlameImage();
    clearCurrentPreview();
    updateThumbnails();
}
Also used : FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart)

Example 9 with FlameMoviePart

use of org.jwildfire.create.tina.animate.FlameMoviePart in project JWildfire by thargor6.

the class TinaSWFAnimatorController method swapFlameMoviePart.

private void swapFlameMoviePart(int pFrom, int pTo) {
    FlameMoviePart part1 = currMovie.getParts().get(pFrom);
    FlameMoviePart part2 = currMovie.getParts().get(pTo);
    JPanel panel1 = flamePartPanelList.get(pFrom);
    JPanel panel2 = flamePartPanelList.get(pTo);
    JRadioButton radio1Btn = flamePartRadioButtonList.get(pFrom);
    JRadioButton radio2Btn = flamePartRadioButtonList.get(pTo);
    for (JPanel panel : flamePartPanelList) {
        swfAnimatorFlamesPanel.remove(panel);
    }
    currMovie.getParts().set(pFrom, part2);
    currMovie.getParts().set(pTo, part1);
    flamePartPanelList.set(pFrom, panel2);
    flamePartPanelList.set(pTo, panel1);
    flamePartRadioButtonList.set(pFrom, radio2Btn);
    flamePartRadioButtonList.set(pTo, radio1Btn);
    for (JPanel panel : flamePartPanelList) {
        swfAnimatorFlamesPanel.add(panel);
    }
    swfAnimatorFlamesPanel.getParent().validate();
    clearCurrentPreview();
    updateThumbnails();
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart)

Aggregations

FlameMoviePart (org.jwildfire.create.tina.animate.FlameMoviePart)9 FlameMovie (org.jwildfire.create.tina.animate.FlameMovie)5 Flame (org.jwildfire.create.tina.base.Flame)5 GlobalScript (org.jwildfire.create.tina.animate.GlobalScript)3 JPanel (javax.swing.JPanel)2 XFormScript (org.jwildfire.create.tina.animate.XFormScript)2 ArrayList (java.util.ArrayList)1 AbstractButton (javax.swing.AbstractButton)1 ImageIcon (javax.swing.ImageIcon)1 JRadioButton (javax.swing.JRadioButton)1 QualityProfile (org.jwildfire.base.QualityProfile)1 ResolutionProfile (org.jwildfire.base.ResolutionProfile)1 FlameMovieReader (org.jwildfire.create.tina.io.FlameMovieReader)1 Attribute (org.jwildfire.create.tina.io.SimpleXMLBuilder.Attribute)1 BubblesRandomFlameGenerator (org.jwildfire.create.tina.randomflame.BubblesRandomFlameGenerator)1 DuckiesRandomFlameGenerator (org.jwildfire.create.tina.randomflame.DuckiesRandomFlameGenerator)1 MandelbrotRandomFlameGenerator (org.jwildfire.create.tina.randomflame.MandelbrotRandomFlameGenerator)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