Search in sources :

Example 16 with FlamePanel

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

the class FlamePreviewHelper method refreshFlameImage.

public void refreshFlameImage(boolean pQuickRender, boolean pMouseDown, int pDownScale, boolean pReRender, boolean pAllowUseCache) {
    cancelBackgroundRender();
    if (pQuickRender && detachedPreviewProvider != null && detachedPreviewProvider.getDetachedPreviewController() != null && pDownScale == 1) {
        detachedPreviewProvider.getDetachedPreviewController().setFlame(flameHolder.getFlame());
    }
    FlamePanel imgPanel = flamePanelProvider.getFlamePanel();
    FlamePanelConfig cfg = flamePanelProvider.getFlamePanelConfig();
    if (pReRender) {
        if (!pQuickRender || !isProgressivePreviewEnabled(cfg)) {
            SimpleImage img = renderFlameImage(pQuickRender, pMouseDown, pDownScale, pAllowUseCache);
            if (img != null) {
                imgPanel.setImage(img);
            }
        }
    }
    imgPanel.setBounds(imgPanel.getParentImageBounds());
    if (!cfg.isNoControls()) {
        centerPanel.getParent().validate();
        centerPanel.repaint();
    } else {
        imgPanel.repaint();
    }
    if (pReRender && isProgressivePreviewEnabled(cfg) && pQuickRender) {
        if (pAllowUseCache) {
            SimpleImage img = renderFlameImage(pQuickRender, pMouseDown, pDownScale, pAllowUseCache);
            if (img != null) {
                imgPanel.setImage(img);
            }
        } else {
            startBackgroundRender(imgPanel);
        }
    }
    if (pQuickRender && !cfg.isNoControls() && randomBatchHolder != null) {
        refreshThumbnail();
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) FlamePanelConfig(org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)

Example 17 with FlamePanel

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

the class EnvelopeDialog method refreshFlameImage.

public void refreshFlameImage() {
    FlamePanel imgPanel = getFlamePanel();
    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 = 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.getPrefs(), false, false);
                renderer.setProgressUpdater(null);
                if (flame.getSolidRenderSettings().isSolidRenderingEnabled()) {
                    flame.setCamDOF(0.0);
                    flame.getSolidRenderSettings().setAoEnabled(false);
                    if (ShadowType.SMOOTH.equals(flame.getSolidRenderSettings().getShadowType())) {
                        flame.getSolidRenderSettings().setShadowType(ShadowType.FAST);
                    } else {
                        flame.getSolidRenderSettings().setShadowType(ShadowType.OFF);
                    }
                    flame.setSampleDensity(Prefs.getPrefs().getTinaRenderRealtimeQuality() * 2.0);
                } else {
                    flame.setSampleDensity(Prefs.getPrefs().getTinaRenderRealtimeQuality() * 6.0);
                }
                flame.setSpatialFilterRadius(0.0);
                RenderedFlame res = renderer.renderFlame(info);
                imgPanel.setImage(res.getImage());
            } finally {
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSampleDensity(oldSampleDensity);
            }
        }
    } else {
        imgPanel.setImage(new SimpleImage(width, height));
    }
    getPreviewRootPanel().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) Point(java.awt.Point) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 18 with FlamePanel

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

the class IFlamesController method getFlamePanel.

@Override
public FlamePanel getFlamePanel() {
    if (flamePanel == null) {
        Prefs prefs = Prefs.getPrefs();
        int width = centerPanel.getWidth();
        int height = centerPanel.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        flamePanel = new FlamePanel(prefs, img, 0, 0, centerPanel.getWidth(), this, null);
        flamePanel.getConfig().setWithColoredTransforms(prefs.isTinaEditorControlsWithColor());
        flamePanel.setFlamePanelTriangleMode(prefs.getTinaEditorControlsStyle());
        flamePanel.getConfig().setProgressivePreview(prefs.isTinaEditorProgressivePreview());
        flamePanel.importOptions(prevFlamePanel);
        prevFlamePanel = null;
        ResolutionProfile resProfile = getResolutionProfile();
        flamePanel.setRenderWidth(resProfile.getWidth());
        flamePanel.setRenderHeight(resProfile.getHeight());
        flamePanel.setFocusable(true);
        if (firstFlamePanel) {
            centerPanel.remove(0);
            firstFlamePanel = false;
        }
        centerPanel.add(flamePanel, BorderLayout.CENTER);
        centerPanel.getParent().validate();
        centerPanel.repaint();
        flamePanel.requestFocusInWindow();
    }
    return flamePanel;
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) Prefs(org.jwildfire.base.Prefs)

Example 19 with FlamePanel

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

the class IFlamesController method refreshBaseFlamePreview.

private void refreshBaseFlamePreview() {
    FlamePanel imgPanel = getBaseFlamePreviewPanel();
    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 = getBaseFlame();
        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);
                renderer.setProgressUpdater(null);
                flame.setSampleDensity(1.0);
                flame.setSpatialFilterRadius(0.0);
                RenderedFlame res = renderer.renderFlame(info);
                imgPanel.setImage(res.getImage());
            } finally {
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSampleDensity(oldSampleDensity);
            }
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
    } else {
        imgPanel.setImage(new SimpleImage(width, height));
    }
    baseFlamePreviewRootPnl.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 20 with FlamePanel

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

the class MeshGenController method getFlamePanel.

private FlamePanel getFlamePanel(JPanel pRootPanel, FlameHolder pFlameHolder) {
    FlamePanel flamePanel = flamepanels.get(pRootPanel);
    if (flamePanel == null) {
        int width = pRootPanel.getWidth();
        int height = pRootPanel.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        flamePanel = new FlamePanel(prefs, img, 0, 0, pRootPanel.getWidth(), pFlameHolder, null);
        flamePanel.setRenderWidth(renderWidthREd.getIntValue());
        flamePanel.setRenderHeight(renderHeightREd.getIntValue());
        flamePanel.setFocusable(true);
        pRootPanel.add(flamePanel, BorderLayout.CENTER);
        pRootPanel.getParent().validate();
        pRootPanel.repaint();
        flamePanel.requestFocusInWindow();
        flamepanels.put(pRootPanel, flamePanel);
    }
    return flamePanel;
}
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