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(); }
private FlamePanel getPoolPreviewFlamePanel() { if (poolFlamePreviewFlamePanel == null && poolFlamePreviewPnl != null) { int width = poolFlamePreviewPnl.getWidth(); int height = poolFlamePreviewPnl.getHeight(); SimpleImage img = new SimpleImage(width, height); img.fillBackground(0, 0, 0); poolFlamePreviewFlamePanel = new FlamePanel(prefs, img, 0, 0, poolFlamePreviewPnl.getWidth(), poolFlameHolder, null); poolFlamePreviewFlamePanel.setRenderWidth(640); poolFlamePreviewFlamePanel.setRenderHeight(480); poolFlamePreviewFlamePanel.setDrawTriangles(false); poolFlamePreviewPnl.add(poolFlamePreviewFlamePanel, BorderLayout.CENTER); poolFlamePreviewPnl.getParent().validate(); poolFlamePreviewPnl.repaint(); } return poolFlamePreviewFlamePanel; }
private FlamePanel getFlamePanel() { if (flamePanel == null && flameRootPanel != null) { int borderWidth = flameRootPanel.getBorder().getBorderInsets(flameRootPanel).left; int width = flameRootPanel.getWidth() - borderWidth; int height = flameRootPanel.getHeight() - borderWidth; if (width < 16 || height < 16) return null; SimpleImage img = new SimpleImage(width, height); img.fillBackground(0, 0, 0); flamePanel = new FlamePanel(prefs, img, 0, 0, flameRootPanel.getWidth() - borderWidth, null, null); flamePanel.setRenderWidth(640); flamePanel.setRenderHeight(480); flameRootPanel.add(flamePanel, BorderLayout.CENTER); flameRootPanel.getParent().validate(); flameRootPanel.repaint(); } flamePanel.setFlameHolder(renderThread); return flamePanel; }
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(); }