Search in sources :

Example 1 with MapFileChooser

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

the class GradientController method gradientSaveBtn_clicked.

public void gradientSaveBtn_clicked() {
    try {
        Layer layer = tinaController.getCurrLayer();
        if (layer != null) {
            JFileChooser chooser = new MapFileChooser(prefs);
            if (prefs.getTinaGradientPath() != null) {
                try {
                    chooser.setCurrentDirectory(new File(prefs.getTinaGradientPath()));
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            if (chooser.showSaveDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                RGBPalette gradient = layer.getPalette().makeCopy();
                gradient.setFlam3Name(file.getName());
                new MapGradientWriter().writeGradient(gradient, file.getAbsolutePath());
                tinaController.getMessageHelper().showStatusMessage(gradient, "gradient saved to disc");
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : MapGradientWriter(org.jwildfire.create.tina.io.MapGradientWriter) JFileChooser(javax.swing.JFileChooser) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) MapFileChooser(org.jwildfire.create.tina.swing.MapFileChooser) Layer(org.jwildfire.create.tina.base.Layer) File(java.io.File)

Aggregations

File (java.io.File)1 JFileChooser (javax.swing.JFileChooser)1 Layer (org.jwildfire.create.tina.base.Layer)1 MapGradientWriter (org.jwildfire.create.tina.io.MapGradientWriter)1 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)1 MapFileChooser (org.jwildfire.create.tina.swing.MapFileChooser)1