Search in sources :

Example 1 with ThumbnailCacheKey

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

the class IFlamesController method reloadImageLibrary.

private void reloadImageLibrary() {
    imageLibrary.clear();
    if (prefs.getIflamesImageLibraryPath() != null && prefs.getIflamesImageLibraryPath().length() > 0) {
        List<String> filenames = new ArrayList<String>();
        _scanFiles(prefs.getIflamesImageLibraryPath(), filenames);
        for (String filename : filenames) {
            if (filename.endsWith("." + Tools.FILEEXT_PNG) || filename.endsWith("." + Tools.FILEEXT_JPG)) {
                try {
                    addImageToImageLibrary(filename, new ThumbnailCacheKey(filename));
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
    refreshImageLibrary();
    imageLibraryScrollPane.getParent().repaint();
}
Also used : ThumbnailCacheKey(org.jwildfire.create.tina.swing.ThumbnailCacheKey) ArrayList(java.util.ArrayList)

Example 2 with ThumbnailCacheKey

use of org.jwildfire.create.tina.swing.ThumbnailCacheKey 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);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) WFImage(org.jwildfire.image.WFImage) ThumbnailCacheKey(org.jwildfire.create.tina.swing.ThumbnailCacheKey) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) SimpleImage(org.jwildfire.image.SimpleImage) File(java.io.File)

Example 3 with ThumbnailCacheKey

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

the class IFlamesController method reloadFlameLibrary.

private void reloadFlameLibrary() {
    flameLibrary.clear();
    if (prefs.getIflamesFlameLibraryPath() != null && prefs.getIflamesFlameLibraryPath().length() > 0) {
        List<String> filenames = new ArrayList<String>();
        _scanFiles(prefs.getIflamesFlameLibraryPath(), filenames);
        for (String filename : filenames) {
            if (filename.endsWith("." + Tools.FILEEXT_FLAME)) {
                try {
                    List<Flame> flames = new FlameReader(prefs).readFlames(filename);
                    for (int i = flames.size() - 1; i >= 0; i--) {
                        addFlameToFlameLibrary(flames.get(i), new ThumbnailCacheKey(filename, String.valueOf(i)));
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
    refreshFlameLibrary();
    flameLibraryScrollPane.getParent().repaint();
}
Also used : FlameReader(org.jwildfire.create.tina.io.FlameReader) ThumbnailCacheKey(org.jwildfire.create.tina.swing.ThumbnailCacheKey) ArrayList(java.util.ArrayList) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 4 with ThumbnailCacheKey

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

the class IFlamesController method loadFlamesButton_clicked.

public void loadFlamesButton_clicked() {
    JFileChooser chooser = new FlameFileChooser(prefs);
    if (prefs.getInputFlamePath() != null) {
        try {
            chooser.setCurrentDirectory(new File(prefs.getInputFlamePath()));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    chooser.setMultiSelectionEnabled(true);
    if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
        Throwable lastError = null;
        for (File file : chooser.getSelectedFiles()) {
            try {
                List<Flame> flames = new FlameReader(prefs).readFlames(file.getAbsolutePath());
                prefs.setLastInputFlameFile(file);
                for (int i = flames.size() - 1; i >= 0; i--) {
                    addFlameToFlameLibrary(flames.get(i), new ThumbnailCacheKey(file.getAbsolutePath(), String.valueOf(i)));
                }
            } catch (Throwable ex) {
                lastError = ex;
            }
        }
        refreshFlameLibrary();
        if (lastError != null) {
            errorHandler.handleError(lastError);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) FlameReader(org.jwildfire.create.tina.io.FlameReader) ThumbnailCacheKey(org.jwildfire.create.tina.swing.ThumbnailCacheKey) FlameFileChooser(org.jwildfire.create.tina.swing.FlameFileChooser) File(java.io.File) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Aggregations

ThumbnailCacheKey (org.jwildfire.create.tina.swing.ThumbnailCacheKey)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 JFileChooser (javax.swing.JFileChooser)2 Flame (org.jwildfire.create.tina.base.Flame)2 FlameReader (org.jwildfire.create.tina.io.FlameReader)2 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)2 FlameFileChooser (org.jwildfire.create.tina.swing.FlameFileChooser)1 SimpleImage (org.jwildfire.image.SimpleImage)1 WFImage (org.jwildfire.image.WFImage)1 ImageFileChooser (org.jwildfire.swing.ImageFileChooser)1