Search in sources :

Example 11 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class MeshGenController method refreshFlameImage.

public void refreshFlameImage(boolean pQuickRender, JPanel pRootPanel, FlameHolder pFlameHolder) {
    if (!refreshing) {
        FlamePanel imgPanel = getFlamePanel(pRootPanel, pFlameHolder);
        Rectangle bounds = imgPanel.getImageBounds();
        int width = bounds.width;
        int height = bounds.height;
        if (width >= 16 && height >= 16) {
            RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
            Flame flame = pFlameHolder.getFlame();
            if (flame != null) {
                double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
                double oldSampleDensity = flame.getSampleDensity();
                try {
                    double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
                    double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
                    flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
                    flame.setWidth(info.getImageWidth());
                    flame.setHeight(info.getImageHeight());
                    FlameRenderer renderer = new FlameRenderer(flame, prefs, false, false);
                    if (pQuickRender) {
                        renderer.setProgressUpdater(null);
                        flame.setSampleDensity(3.0);
                        flame.setSpatialFilterRadius(0.0);
                    } else {
                        renderer.setProgressUpdater(renderSequenceProgressUpdater);
                        flame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
                    }
                    RenderedFlame res = renderer.renderFlame(info);
                    imgPanel.setImage(res.getImage());
                } finally {
                    flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                    flame.setSampleDensity(oldSampleDensity);
                }
            }
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
        pRootPanel.repaint();
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 12 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class DancingFractalsController method refreshFlameImage.

public void refreshFlameImage(Flame flame, boolean pDrawTriangles, double pFPS, long pFrame, boolean pDrawFPS) {
    FlamePanel imgPanel = getFlamePanel();
    if (imgPanel == null)
        return;
    Rectangle bounds = imgPanel.getImageBounds();
    int width = bounds.width;
    int height = bounds.height;
    if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        if (flame != null) {
            double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
            double oldSampleDensity = flame.getSampleDensity();
            imgPanel.setDrawTriangles(pDrawTriangles);
            try {
                double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
                double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
                flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
                flame.setWidth(info.getImageWidth());
                flame.setHeight(info.getImageHeight());
                Flame renderFlame = new FlamePreparer(prefs).createRenderFlame(flame);
                FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, false);
                renderer.setProgressUpdater(null);
                RenderedFlame res = renderer.renderFlame(info);
                SimpleImage img = res.getImage();
                if (pDrawFPS) {
                    TextTransformer txt = new TextTransformer();
                    txt.setText1("fps: " + Tools.doubleToString(pFPS) + ", time: " + Tools.doubleToString(pFrame / 1000.0) + "s");
                    txt.setAntialiasing(false);
                    txt.setColor(Color.LIGHT_GRAY);
                    txt.setMode(Mode.NORMAL);
                    txt.setFontStyle(FontStyle.PLAIN);
                    txt.setFontName("Arial");
                    txt.setFontSize(10);
                    txt.setHAlign(HAlignment.LEFT);
                    txt.setVAlign(VAlignment.BOTTOM);
                    txt.transformImage(img);
                }
                imgPanel.setImage(img);
            } finally {
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSampleDensity(oldSampleDensity);
            }
        }
    } else {
        try {
            imgPanel.setImage(new SimpleImage(width, height));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    flameRootPanel.repaint();
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) TextTransformer(org.jwildfire.transform.TextTransformer) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 13 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class DancingFractalsController method refreshPoolPreviewFlameImage.

public void refreshPoolPreviewFlameImage(Flame flame) {
    FlamePanel imgPanel = getPoolPreviewFlamePanel();
    if (imgPanel == null)
        return;
    Rectangle bounds = imgPanel.getImageBounds();
    int width = bounds.width;
    int height = bounds.height;
    if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        if (flame != null) {
            imgPanel.setDrawTriangles(false);
            double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
            double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
            flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
            flame.setWidth(info.getImageWidth());
            flame.setHeight(info.getImageHeight());
            Flame renderFlame = new FlamePreparer(prefs).createRenderFlame(flame);
            FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, false);
            renderer.setProgressUpdater(null);
            RenderedFlame res = renderer.renderFlame(info);
            imgPanel.setImage(res.getImage());
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
    } else {
        imgPanel.setImage(new SimpleImage(width, height));
    }
    poolFlamePreviewPnl.repaint();
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 14 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class FlamePreviewHelper method setImage.

public void setImage(SimpleImage pImage) {
    FlamePanel imgPanel = flamePanelProvider.getFlamePanel();
    imgPanel.setImage(pImage);
}
Also used : FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel)

Example 15 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class FlamePreviewHelper method fastRefreshFlameImage.

public void fastRefreshFlameImage(boolean pQuickRender, boolean pMouseDown, int pDownScale) {
    FlamePanel imgPanel = flamePanelProvider.getFlamePanel();
    SimpleImage img = fastRenderFlameImage(pQuickRender, pMouseDown, pDownScale);
    if (img != null) {
        imgPanel.setImage(img);
    }
    imgPanel.repaint();
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel)

Aggregations

FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)23 SimpleImage (org.jwildfire.image.SimpleImage)20 Rectangle (java.awt.Rectangle)9 Flame (org.jwildfire.create.tina.base.Flame)9 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)9 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)9 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)9 ResolutionProfile (org.jwildfire.base.ResolutionProfile)5 FlamePanelConfig (org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)3 Point (java.awt.Point)2 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)2 DrawFocusPointFlameRenderer (org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer)2 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 MouseEvent (java.awt.event.MouseEvent)1 MouseWheelEvent (java.awt.event.MouseWheelEvent)1 MouseWheelListener (java.awt.event.MouseWheelListener)1 EmptyBorder (javax.swing.border.EmptyBorder)1 Prefs (org.jwildfire.base.Prefs)1 ComposeTransformer (org.jwildfire.transform.ComposeTransformer)1