use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.
the class TinaInteractiveRendererController method saveZBufferButton_clicked.
public void saveZBufferButton_clicked() {
try {
pauseRenderThreads();
try {
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getOutputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showSaveDialog(imageRootPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
double zBufferScale = Double.parseDouble(JOptionPane.showInputDialog(imageRootPanel, "Enter ZBuffer-Scale", currFlame.getZBufferScale()));
currFlame.setZBufferScale(zBufferScale);
RenderedFlame res = renderer.finishZBuffer(displayUpdater.getSampleCount());
if (res.getZBuffer() != null) {
new ImageWriter().saveImage(res.getZBuffer(), file.getAbsolutePath());
if (autoLoadImageCBx.isSelected()) {
parentCtrl.mainController.loadImage(file.getAbsolutePath(), false);
}
}
}
} finally {
resumeRenderThreads();
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.
the class MeshGenController method generateButton_clicked.
public void generateButton_clicked() {
if (renderSlicesThread != null) {
renderSlicesThread.setForceAbort();
while (renderSlicesThread.isFinished()) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
renderSlicesThread = null;
enableControls();
} else if (currBaseFlame != null) {
try {
JFileChooser chooser;
if (isPointCloudMode()) {
chooser = new PointCloudOutputFileChooser(Tools.FILEEXT_PLY);
if (prefs.getTinaMeshPath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getTinaMeshPath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
} else {
chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getOutputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
if (chooser.showSaveDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
final File file = chooser.getSelectedFile();
prefs.setLastOutputImageFile(file);
MeshGenGenerateThreadFinishEvent finishEvent = new MeshGenGenerateThreadFinishEvent() {
@Override
public void succeeded(double pElapsedTime) {
try {
tinaController.getMessageHelper().showStatusMessage(currBaseFlame, "render time: " + Tools.doubleToString(pElapsedTime) + "s");
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
renderSlicesThread = null;
enableControls();
}
@Override
public void failed(Throwable exception) {
errorHandler.handleError(exception);
renderSlicesThread = null;
enableControls();
}
};
Flame flame = currBaseFlame.makeCopy();
switch(getOutputType()) {
case VOXELSTACK:
{
String outfilenamePattern = SequenceFilenameGen.createFilenamePattern(file);
Flame grayFlame = flame.makeCopy();
RGBPalette gradient = new RGBPalette();
for (int i = 0; i < RGBPalette.PALETTE_SIZE; i++) {
gradient.setColor(i, 225, 225, 225);
}
grayFlame.getFirstLayer().setPalette(gradient);
renderSlicesThread = new RenderSlicesThread(prefs, grayFlame, outfilenamePattern, finishEvent, renderSequenceProgressUpdater, renderWidthREd.getIntValue(), renderHeightREd.getIntValue(), sliceCountREd.getIntValue(), slicesPerRenderREd.getIntValue(), renderQualityREd.getIntValue(), zminREd.getDoubleValue(), zmaxREd.getDoubleValue());
lastRenderedSequenceOutFilePattern = outfilenamePattern;
break;
}
case POINTCLOUD:
{
renderSlicesThread = new RenderPointCloudThread(prefs, flame, file.getAbsolutePath(), finishEvent, renderSequenceProgressUpdater, renderWidthREd.getIntValue(), renderHeightREd.getIntValue(), renderQualityREd.getIntValue(), zminREd.getDoubleValue(), zmaxREd.getDoubleValue(), meshGenCellSizeREd.getDoubleValue());
break;
}
}
enableControls();
new Thread(renderSlicesThread).start();
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
}
use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.
the class IFlamesController method loadImagesButton_clicked.
public void loadImagesButton_clicked() {
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getInputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
chooser.setMultiSelectionEnabled(true);
if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
Throwable lastError = null;
for (File file : chooser.getSelectedFiles()) {
try {
String filename = file.getAbsolutePath();
WFImage img = RessourceManager.getImage(filename);
if (img.getImageWidth() < 16 || img.getImageHeight() < 16 || !(img instanceof SimpleImage)) {
throw new Exception("Invalid image");
}
prefs.setLastInputImageFile(file);
addImageToImageLibrary(filename, new ThumbnailCacheKey(filename));
} catch (Throwable ex) {
lastError = ex;
}
}
refreshImageLibrary();
if (lastError != null) {
errorHandler.handleError(lastError);
}
}
}
use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.
the class MeshGenController method loadSequenceButton_clicked.
public void loadSequenceButton_clicked() {
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getInputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showOpenDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
prefs.setLastInputImageFile(file);
importSequence(SequenceFilenameGen.guessFilenamePattern(file));
}
}
use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.
the class TinaController method renderImageButton_actionPerformed.
public void renderImageButton_actionPerformed() {
if (mainRenderThread != null) {
mainRenderThread.setForceAbort();
while (mainRenderThread.isFinished()) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
mainRenderThread = null;
enableMainRenderControls();
} else if (getCurrFlame() != null) {
try {
String dfltFileExt = Stereo3dMode.SIDE_BY_SIDE.equals(getCurrFlame().getStereo3dMode()) ? Tools.FILEEXT_PNS : Tools.FILEEXT_PNG;
JFileChooser chooser = new ImageFileChooser(dfltFileExt);
if (prefs.getOutputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showSaveDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
QualityProfile qualProfile = getQualityProfile();
ResolutionProfile resProfile = getResolutionProfile();
final Flame flame = getCurrFlame();
final File file = chooser.getSelectedFile();
prefs.setLastOutputImageFile(file);
RenderMainFlameThreadFinishEvent finishEvent = new RenderMainFlameThreadFinishEvent() {
@Override
public void succeeded(double pElapsedTime) {
try {
messageHelper.showStatusMessage(flame, "render time: " + Tools.doubleToString(pElapsedTime) + "s");
mainController.loadImage(file.getAbsolutePath(), false);
File zBuffer = new File(Tools.makeZBufferFilename(file.getAbsolutePath()));
if (zBuffer.exists()) {
mainController.loadImage(zBuffer.getAbsolutePath(), false);
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
mainRenderThread = null;
enableMainRenderControls();
}
@Override
public void failed(Throwable exception) {
errorHandler.handleError(exception);
mainRenderThread = null;
enableMainRenderControls();
}
};
mainRenderThread = new RenderMainFlameThread(prefs, flame, file, qualProfile, resProfile, finishEvent, mainProgressUpdater);
enableMainRenderControls();
Thread worker = new Thread(mainRenderThread);
worker.setPriority(Thread.MIN_PRIORITY);
worker.start();
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
}
Aggregations