Package net.sf.jiga.xtended

Examples of net.sf.jiga.xtended.JXAException


                Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
                if (this.isDebugEnabled()) {
                        System.out.println("Writing sprite image to stream...");
                }
                if (output == null) {
                        throw new JXAException("WARNING ! No suitable image output stream to write ! " + this.toString());
                }
                try {
                        final Monitor monitor = this.renderableImpl.imageSynch;
                        synchronized (monitor) {
                                Dimension dim = null;
                                IIOMetadata metadata = null;
                                ImageWriter w = this.renderableImpl.io.getWriter(0, this.storeMime);
                                ImageWriteParam iwp = this.renderableImpl.io._getIWP(w, dim, this.storeMime, this._type, compressionQuality);
                                if (this.renderableImpl.io.IIOcontrollerEnabled) {
                                        iwp.setController(SpriteIO.IIOControllers.get(this.storeMime));
                                        if (iwp.hasController()) {
                                                iwp.activateController();
                                        }
                                }
                                ImageTypeSpecifier its = (this.renderableImpl.getStoreMode() & Sf3RenderableImpl.MODE_TILE) != 0 ? SpriteIO._getITS(this._type) : SpriteIO._getITS((RenderedImage) this.data);
                                if ((this.renderableImpl.getStoreMode() & Sf3RenderableImpl.MODE_TILE) == 0) {
                                        if (!(this.data instanceof BufferedImage)) {
                                                this.data = convertToBuffered(this.data, this.renderableImpl.io.obs, true);
                                        }
                                        if (((BufferedImage) this.data).getType() != this._type) {
                                                this.data = convertToBuffered(this.data, this.renderableImpl.io.obs, true);
                                        }
                                        this.waitFor(this.data);
                                        if (this.data == null) {
                                                throw new JXAException("Sprite " + this.toString() + " had no data to write ");
                                        }
                                        if (!(this.data instanceof RenderedImage)) {
                                                throw new JXAException("READ/WRITE ERROR : Sprite image isn't compatible with RenderedImage. " + this.data.getClass().getName());
                                        }
                                        dim = new Dimension(this.data.getWidth(this.renderableImpl.io.obs), this.data.getHeight(this.renderableImpl.io.obs));
                                        this.renderableImpl.io.prepareWrite(dim, w, its, iwp, this.isUseIIOCacheEnabled(), output, this.data, this._type);
                                        this.renderableImpl.io.writeToOutput(metadata, null, w, iwp, (BufferedImage) this.data);
                                } else {
                                        ImageReader r = this.renderableImpl.io.getReader(0, this.tileMime);
                                        r = this.renderableImpl.io.__getInput(this.tileSrc, this.innerResource, r, this.isUseIIOCacheEnabled());
                                        dim = new Dimension(r.getWidth(0), r.getHeight(0));

                                        if ((this.renderableImpl.io.prepareWrite(dim, w, its, iwp, this.isUseIIOCacheEnabled(), output, r, this._type) & _TILEFLAGS) == _TILEFLAGS) {
                                                this.renderableImpl.io.writeToOutputTiled(dim, SpriteIO._WRITE_TILES_DIMENSION, w, iwp, r, this._type, null);
                                        } else {
                                                this.renderableImpl.io.writeToOutput(dim, w, iwp, r, this._type, null);
                                        }
                                }
                                this.renderableImpl.io.endWrite(w);
                                if (this.isDebugEnabled()) {
                                        System.out.println("writing is done.");
                                }
                                Thread.currentThread().setPriority(pty);
                        }
                } catch (IllegalArgumentException ex) {
                        JXAException e = new JXAException(ex);
                        throw e;
                }
        }
View Full Code Here


                                        }
                                        threadEdit = Thread.currentThread().getId();
                                        threadEditLvl++;
                                }
                        } catch (InterruptedException ex) {
                                throw new JXAException(ex);
                        }
                }
View Full Code Here

                                        if (JXAenvUtils._debug) {
                                                System.err.println(JXAenvUtils.log("no edit-paint is current", JXAenvUtils.LVL.APP_WRN));
                                        }
                                } else {
                                        if (threadEdit != Thread.currentThread().getId()) {
                                                throw new JXAException("another edit-paint is current on another Thread " + threadEdit);
                                        }
                                        threadEditLvl = Math.max(0, threadEditLvl - 1);
                                        threadEdit = threadEditLvl != 0 ? threadEdit : 0;
                                }
                                editMonitor.notifyAll();
View Full Code Here

                File f, rf;
                f = map.get(key = i.next());
                rkey = in.readInt();
                rf = (File) in.readObject();
                if (key != rkey) {
                    throw new JXAException("wrong key in Animation " + renderableImpl.base + " image files base : " + key + " read : " + rkey);
                }
                if (!f.equals(rf)) {
                    throw new JXAException("wrong file in Animation " + renderableImpl.base + " image files base : " + f + " read : " + rf);
                }
                long len;
                boolean skipped = false;
                if ((len = in.readLong()) > 0) {
                    if (!f.exists() || f.length() != len) {
View Full Code Here

            synchronized (monitor1) {
                renderableImpl.painting = false;
                monitor1.notifyAll();
            }
            if (interrupt_) {
                throw new JXAException("Animation " + renderableImpl.base + " caught an interruption.");
            }
            return complete;
        }
    }
View Full Code Here

    }

    @Override
    public void setFrameRate(long delay) {
        if (delay < 0) {
            throw new JXAException("framerate delay must be different from Zero!");
        }
        frameRate = delay * 1000000;
    }
View Full Code Here

         * @throws InterruptedException
         * @throws InvocationTargetException
         */
        public static void invokeAndWait(Runnable r) throws InterruptedException, InvocationTargetException {
            if (isEventDispatchThread()) {
                throw new JXAException("Illegal call to invokeAndWait while being on the Event Dispatcher Thread.");
            }
            SwingUtilities.invokeAndWait(loaderRun(r));
        }
View Full Code Here

        if (!(tmpDir = new File(FileHelper._TMPDIRECTORY.getPath() + File.separator + image_dir)).isDirectory()) {
            tmpDir.mkdirs();
            FileHelper._makeWritable(tmpDir);
        }
        if (src == null) {
            throw new JXAException("src is null !");
        } else {
            if (DebugMap._getInstance().isDebuggerEnabled(Sprite.class) && DebugMap._getInstance().isDebugLevelEnabled(DebugMap._getInstance()._VOID)) {
                System.out.println("New IIO Input " + (useCache ? "(may be cached)" : "(direct)") + ": " + src.getClass().getName() + " " + r.getFormatName());
            }
        }
        if (!innerResource && (src instanceof String)) {
            File inputFile = new File((String) src);
            if (!inputFile.isFile()) {
                throw new JXAException(src + " cannot be read");
            }
            raf = new RandomAccessFile(inputFile, "r");
            is = JXAenvUtils2.__getBuffered(new FileInputStream(raf.getFD()), bigBuffer);
            if (useCache) {
                r.setInput(new FileCacheImageInputStream(is, tmpDir));
            } else {
                r.setInput(ImageIO.createImageInputStream(is));
            }
        } else if (src instanceof ImageInputStream) {
            r.setInput(src);
        } else if (src instanceof InputStream) {
            is = JXAenvUtils2.__getBuffered((InputStream) src, bigBuffer);
            if (useCache) {
                r.setInput(new FileCacheImageInputStream(is, tmpDir));
            } else {
                r.setInput(ImageIO.createImageInputStream(is));
            }
        } else if (src instanceof String) {
            if (!src.equals(NO_SOURCE)) {
                if (!isExtClassLoaderRes()) {
                    is = JXAenvUtils2.__getBuffered(Sprite.class.getResourceAsStream((String) src), bigBuffer);
                } else {
                    is = JXAenvUtils2.__getBuffered(ExtensionsClassLoader.getInstance().getClassLoader().getResourceAsStream(_contextResource((String) src)), bigBuffer); /*
                     * Thread.currentThread().getContextClassLoader().getResourceAsStream(_contextResource((String)
                     * src));
                     */

                }
                if (useCache) {
                    r.setInput(new FileCacheImageInputStream(is, tmpDir));
                } else {
                    r.setInput(ImageIO.createImageInputStream(is));
                }
            } else {
                throw new JXAException("reading is not supported from " + src);
            }
        } else if (src instanceof File) {
            raf = new RandomAccessFile((File) src, "r");
            is = JXAenvUtils2.__getBuffered(new FileInputStream(raf.getFD()), bigBuffer);
            if (useCache) {
                r.setInput(new FileCacheImageInputStream(is, tmpDir));
            } else {
                r.setInput(ImageIO.createImageInputStream(is));
            }
        } else {
            throw new JXAException(src.getClass() + " input is not supported");
        }
        RefPool.getInstance().queueRef(is, false);
        return r;
    }
View Full Code Here

    private static ImageWriter __getOutput(Object dst, ImageWriter w, boolean useCache) throws IOException {
        RandomAccessFile raf = null;
        OutputStream os = null;
        File tmpDir = _getIIOTmpDir();
        if (dst == null) {
            throw new JXAException("dst is not supported : null");
        } else {
            if (DebugMap._getInstance().isDebuggerEnabled(Sprite.class) && DebugMap._getInstance().isDebugLevelEnabled(DebugMap._getInstance()._VOID)) {
                System.out.println("New IIO Output " + (useCache ? "(may be cached)" : "(direct)") + ": " + dst.getClass().getName() + " " + w.getOriginatingProvider().getFormatNames()[0]);
            }
        }
        if (dst instanceof String) {
            File outputFile = new File((String) dst);
            raf = new RandomAccessFile(outputFile, "rw");
            os = JXAenvUtils2.__getBuffered(new FileOutputStream(raf.getFD()), bigBuffer);
            if (useCache) {
                w.setOutput(new FileCacheImageOutputStream(os, tmpDir));
            } else {
                w.setOutput(ImageIO.createImageOutputStream(os));
            }
        } else if (dst instanceof OutputStream) {
            os = JXAenvUtils2.__getBuffered((OutputStream) dst, bigBuffer);
            if (useCache) {
                w.setOutput(new FileCacheImageOutputStream(os, tmpDir));
            } else {
                w.setOutput(ImageIO.createImageOutputStream(os));
            }
        } else if (dst instanceof File) {
            raf = new RandomAccessFile((File) dst, "rw");
            os = JXAenvUtils2.__getBuffered(new FileOutputStream(raf.getFD()), bigBuffer);
            if (useCache) {
                w.setOutput(new FileCacheImageOutputStream(os, tmpDir));
            } else {
                w.setOutput(ImageIO.createImageOutputStream(os));
            }
        } else if (dst instanceof ImageOutputStream) {
            w.setOutput(dst);
        } else {
            throw new JXAException(dst.getClass() + " output is not supported");
        }
        RefPool.getInstance().queueRef(os, false);
        return w;
    }
View Full Code Here

     * <br><b>Closes any open stream specified as output after the write
     * finishes.</b>
     */
    public void endWrite(ImageWriter w) throws IOException {
        if (!writeBlock.isOn()) {
            throw new JXAException(JXAException.LEVEL.SYSTEM, "not in write code block, use prepareWrite()-or-prepareTileWrite() before");
        }
        if (w.canWriteSequence() && (writeBlock.getTdata() & _WRITE_SEQUENCE) != 0) {
            w.endWriteSequence();
        }
        writeBlock.removeTdata();
View Full Code Here

TOP

Related Classes of net.sf.jiga.xtended.JXAException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.