Search in sources :

Example 21 with FlameReader

use of org.jwildfire.create.tina.io.FlameReader in project JWildfire by thargor6.

the class TinaSWFAnimatorController method loadFlameFromClipboardButton_clicked.

public void loadFlameFromClipboardButton_clicked() {
    Flame newFlame = null;
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                String xml = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
                List<Flame> flames = new FlameReader(prefs).readFlamesfromXML(xml);
                if (flames.size() > 0) {
                    newFlame = flames.get(0);
                }
            }
        }
        if (newFlame == null) {
            throw new Exception("There is currently no valid flame in the clipboard");
        } else {
            addFlame(newFlame);
            enableControls();
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameReader(org.jwildfire.create.tina.io.FlameReader) Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 22 with FlameReader

use of org.jwildfire.create.tina.io.FlameReader in project JWildfire by thargor6.

the class TinaController method loadFlameFromClipboard.

public void loadFlameFromClipboard() {
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                String xml = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
                List<Flame> flames = new FlameReader(prefs).readFlamesfromXML(xml);
                Flame flame = flames.get(0);
                setCurrFlame(flame);
                undoManager.initUndoStack(getCurrFlame());
                for (int i = flames.size() - 1; i >= 1; i--) {
                    randomBatch.add(0, new FlameThumbnail(flames.get(i), null, null));
                }
                setupProfiles(getCurrFlame());
                updateThumbnails();
                refreshUI();
                messageHelper.showStatusMessage(getCurrFlame(), "opened from clipboard");
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameReader(org.jwildfire.create.tina.io.FlameReader) Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 23 with FlameReader

use of org.jwildfire.create.tina.io.FlameReader in project JWildfire by thargor6.

the class TinaController method loadFlameButton_actionPerformed.

public void loadFlameButton_actionPerformed(ActionEvent e) {
    try {
        JFileChooser chooser = new FlameFileChooser(prefs);
        if (prefs.getInputFlamePath() != null) {
            try {
                chooser.setCurrentDirectory(new File(prefs.getInputFlamePath()));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            List<Flame> flames = new FlameReader(prefs).readFlames(file.getAbsolutePath());
            Flame flame = flames.get(0);
            prefs.setLastInputFlameFile(file);
            if (data.layerAppendBtn.isSelected() && getCurrFlame() != null) {
                if (appendToFlame(flame)) {
                    refreshUI();
                    messageHelper.showStatusMessage(getCurrFlame(), "opened from disc and added as new layers");
                }
            } else {
                setCurrFlame(flame);
                getCurrFlame().setLastFilename(file.getName());
                undoManager.initUndoStack(getCurrFlameStack());
                for (int i = flames.size() - 1; i >= 1; i--) {
                    randomBatch.add(0, new FlameThumbnail(flames.get(i), null, null));
                }
                updateThumbnails();
                setupProfiles(getCurrFlame());
                refreshUI();
                if (flames.size() > 1) {
                    messageHelper.showStatusMessage(flames.size() + " flame opened from disc");
                } else {
                    messageHelper.showStatusMessage(getCurrFlame(), "opened from disc");
                }
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) FlameReader(org.jwildfire.create.tina.io.FlameReader) File(java.io.File) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 24 with FlameReader

use of org.jwildfire.create.tina.io.FlameReader in project JWildfire by thargor6.

the class TinaInteractiveRendererController method loadFlameButton_clicked.

public void loadFlameButton_clicked() {
    try {
        JFileChooser chooser = new FlameFileChooser(prefs);
        if (prefs.getInputFlamePath() != null) {
            try {
                chooser.setCurrentDirectory(new File(prefs.getInputFlamePath()));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        if (chooser.showOpenDialog(imageRootPanel) == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            List<Flame> flames = new FlameReader(prefs).readFlames(file.getAbsolutePath());
            Flame newFlame = flames.get(0);
            prefs.setLastInputFlameFile(file);
            currFlame = newFlame;
            importFlame(newFlame);
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) FlameReader(org.jwildfire.create.tina.io.FlameReader) File(java.io.File) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 25 with FlameReader

use of org.jwildfire.create.tina.io.FlameReader in project JWildfire by thargor6.

the class TinaInteractiveRendererController method fromClipboardButton_clicked.

public void fromClipboardButton_clicked() {
    Flame newFlame = null;
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                String xml = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
                List<Flame> flames = new FlameReader(prefs).readFlamesfromXML(xml);
                if (flames.size() > 0) {
                    newFlame = flames.get(0);
                }
            }
        }
        if (newFlame == null) {
            throw new Exception("There is currently no valid flame in the clipboard");
        } else {
            currFlame = newFlame;
            storeCurrFlame();
            cancelRender();
            setupProfiles(currFlame);
            renderButton_clicked();
            enableControls();
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameReader(org.jwildfire.create.tina.io.FlameReader) Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Aggregations

FlameReader (org.jwildfire.create.tina.io.FlameReader)25 Flame (org.jwildfire.create.tina.base.Flame)24 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)20 File (java.io.File)12 JFileChooser (javax.swing.JFileChooser)10 Clipboard (java.awt.datatransfer.Clipboard)7 Transferable (java.awt.datatransfer.Transferable)7 FlameFileChooser (org.jwildfire.create.tina.swing.FlameFileChooser)5 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)3 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)3 ArrayList (java.util.ArrayList)2 ThumbnailCacheKey (org.jwildfire.create.tina.swing.ThumbnailCacheKey)2 HashMap (java.util.HashMap)1 ImageIcon (javax.swing.ImageIcon)1 XForm (org.jwildfire.create.tina.base.XForm)1 FACLFlameWriter (org.jwildfire.create.tina.faclrender.FACLFlameWriter)1 FACLRenderResult (org.jwildfire.create.tina.faclrender.FACLRenderResult)1 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)1 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)1 Variation (org.jwildfire.create.tina.variation.Variation)1