Search in sources :

Example 6 with QualityProfile

use of org.jwildfire.base.QualityProfile in project JWildfire by thargor6.

the class HeadlessBatchRendererController method main.

public static void main(String[] args) throws Exception {
    // args = new String[]{"/dev/shm/","400","400","80"};//,"ZIGGURAT"};
    int height;
    int width;
    int quality;
    String filename;
    File f;
    List<File> files = new LinkedList<File>();
    long start = System.nanoTime();
    if (args.length < 4) {
        usage(args);
        return;
    } else {
        try {
            height = Integer.parseInt(args[1]);
            width = Integer.parseInt(args[2]);
            quality = Integer.parseInt(args[3]);
            filename = args[0].trim();
            String was = Prefs.getPrefs().getTinaRandomNumberGenerator().name();
            if (args.length > 4 && Arrays.toString(RandomGeneratorType.values()).contains(args[4])) {
                Prefs.getPrefs().setTinaRandomNumberGenerator(RandomGeneratorType.valueOf(args[4]));
                System.out.println(was + " changed to " + Prefs.getPrefs().getTinaRandomNumberGenerator().name());
            }
            f = new File(filename);
            if (!f.exists())
                throw new Exception(filename + " does not exist");
            if (f.isDirectory()) {
                final File[] listFiles = f.listFiles();
                if (listFiles != null)
                    for (File fi : listFiles) {
                        if (fi.canRead() && fi.exists() && fi.getName().toLowerCase().endsWith(".flame"))
                            files.add(fi);
                    }
            } else if (f.getName().toLowerCase().endsWith(".flame"))
                files.add(f);
        } catch (Exception e) {
            usage(args);
            System.err.println(e.getMessage());
            return;
        }
    }
    ResolutionProfile respro = new ResolutionProfile(true, width, height);
    JobRenderThreadController controller = new HeadlessBatchRendererController();
    List<Job> joblist = new ArrayList<Job>();
    for (File fi : files) {
        Job j = new Job();
        j.setCustomHeight(height);
        j.setCustomWidth(width);
        j.setCustomQuality(quality);
        j.setFlameFilename(fi.getCanonicalPath());
        joblist.add(j);
    }
    QualityProfile qualpro = new QualityProfile();
    qualpro.setQuality(quality);
    JobRenderThread job = new JobRenderThread(controller, joblist, respro, qualpro, true, false);
    job.run();
    System.out.println((System.nanoTime() - start) / 1000 / 1000 + " ms");
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) QualityProfile(org.jwildfire.base.QualityProfile) File(java.io.File)

Example 7 with QualityProfile

use of org.jwildfire.base.QualityProfile in project JWildfire by thargor6.

the class QualityProfileDialog method setProfile.

public void setProfile(QualityProfile pProfile) {
    refreshing = true;
    try {
        if (pProfile == null) {
            getProfileCmb().setSelectedIndex(-1);
        } else {
            boolean found = false;
            for (int i = 0; i < getProfileCmb().getItemCount(); i++) {
                QualityProfile profile = (QualityProfile) getProfileCmb().getItemAt(i);
                if (profile.toString().equals(pProfile.toString())) {
                    getProfileCmb().setSelectedIndex(i);
                    found = true;
                    break;
                }
            }
            if (!found) {
                getProfileCmb().setSelectedIndex(-1);
            }
        }
        editStatus = getProfileCmb().getSelectedItem() != null ? EditStatus.BROWSE : EditStatus.CLOSE;
        refreshProfileView();
        enableControls();
    } finally {
        refreshing = false;
    }
}
Also used : QualityProfile(org.jwildfire.base.QualityProfile) Point(java.awt.Point)

Example 8 with QualityProfile

use of org.jwildfire.base.QualityProfile in project JWildfire by thargor6.

the class QualityProfileDialog method setProfiles.

public void setProfiles(List<QualityProfile> pProfiles) {
    refreshing = true;
    try {
        getProfileCmb().removeAllItems();
        if (pProfiles != null) {
            for (QualityProfile profile : pProfiles) {
                QualityProfile clonedProfile = (QualityProfile) profile.makeCopy();
                getProfileCmb().addItem(clonedProfile);
            }
        }
        getProfileCmb().setSelectedIndex(-1);
        editStatus = EditStatus.CLOSE;
    } finally {
        refreshing = false;
    }
}
Also used : QualityProfile(org.jwildfire.base.QualityProfile)

Example 9 with QualityProfile

use of org.jwildfire.base.QualityProfile in project JWildfire by thargor6.

the class QualityProfileDialog method getProfiles.

public List<QualityProfile> getProfiles() {
    List<QualityProfile> res = new ArrayList<QualityProfile>();
    for (int i = 0; i < getProfileCmb().getItemCount(); i++) {
        res.add((QualityProfile) getProfileCmb().getItemAt(i));
    }
    Collections.sort(res, new QualityProfileComparator());
    return res;
}
Also used : QualityProfileComparator(org.jwildfire.base.QualityProfileComparator) ArrayList(java.util.ArrayList) QualityProfile(org.jwildfire.base.QualityProfile) Point(java.awt.Point)

Example 10 with QualityProfile

use of org.jwildfire.base.QualityProfile in project JWildfire by thargor6.

the class QualityProfileDialog method applyChanges.

private boolean applyChanges() {
    try {
        final int MIN_QUALITY = 1;
        String caption = getCaptionREd().getText();
        if (caption == null || caption.trim().length() == 0) {
            throw new Exception("Caption must not be empty");
        }
        int quality = Integer.parseInt(getQualityREd().getText());
        if (quality < MIN_QUALITY) {
            throw new Exception("Quality must be at least " + MIN_QUALITY);
        }
        QualityProfile profile;
        if (editStatus == EditStatus.NEW) {
            profile = new QualityProfile();
        } else {
            profile = (QualityProfile) getProfileCmb().getSelectedItem();
        }
        profile.setCaption(caption);
        profile.setQuality(quality);
        profile.setWithHDR(getWithHDRCBx().isSelected());
        profile.setWithZBuffer(getWithZBufferCBx().isSelected());
        profile.setDefaultProfile(getDefaultCBx().isSelected());
        if (editStatus == EditStatus.NEW) {
            refreshing = true;
            try {
                getProfileCmb().addItem(profile);
                getProfileCmb().setSelectedItem(profile);
            } finally {
                refreshing = false;
            }
        }
        if (profile.isDefaultProfile()) {
            for (int i = 0; i < getProfileCmb().getItemCount(); i++) {
                QualityProfile lProfile = (QualityProfile) getProfileCmb().getItemAt(i);
                if (lProfile != profile) {
                    lProfile.setDefaultProfile(false);
                }
            }
        }
        getProfileCmb().requestFocus();
        editStatus = EditStatus.BROWSE;
        enableControls();
        configChanged = true;
        return true;
    } catch (Throwable ex) {
        getStatusLbl().setText(ex.getMessage());
        return false;
    }
}
Also used : QualityProfile(org.jwildfire.base.QualityProfile) Point(java.awt.Point)

Aggregations

QualityProfile (org.jwildfire.base.QualityProfile)14 ResolutionProfile (org.jwildfire.base.ResolutionProfile)6 ArrayList (java.util.ArrayList)4 Point (java.awt.Point)3 Flame (org.jwildfire.create.tina.base.Flame)3 File (java.io.File)2 Test (org.junit.Test)2 Layer (org.jwildfire.create.tina.base.Layer)2 XForm (org.jwildfire.create.tina.base.XForm)2 HeadlessBatchRendererController (org.jwildfire.create.tina.batch.HeadlessBatchRendererController)2 Job (org.jwildfire.create.tina.batch.Job)2 JobRenderThread (org.jwildfire.create.tina.batch.JobRenderThread)2 JobRenderThreadController (org.jwildfire.create.tina.batch.JobRenderThreadController)2 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 LinkedList (java.util.LinkedList)1 AbstractButton (javax.swing.AbstractButton)1 JFileChooser (javax.swing.JFileChooser)1 JPanel (javax.swing.JPanel)1 Ignore (org.junit.Ignore)1