Package net.sf.jiga.xtended.impl

Examples of net.sf.jiga.xtended.impl.Sprite


            if (custom.getAttribute(_linkedModelsArray) != null) {
                model.setAttribute(_linkedModelsArray, custom.getAttribute(_linkedModelsArray));
            }
            try {
                if (iconFile != null) {
                    model.setAttribute("icon", new Sprite(ImageIO.read(iconFile), "image/x-png", _iconSize));
                }
            } catch (IOException ex) {
                if (JXAenvUtils._debug) {
                    ex.printStackTrace();
                }
View Full Code Here


            currentFile = f;
            /*
             * model.setAttribute(ATTR_CUSTOMIZED, false);
             */
            if (model.getAttribute("icon") instanceof Sprite) {
                Sprite sp = (Sprite) model.getAttribute("icon");
                sp.runValidate();
                sw_icon = Display._Display(sp.getImage(iconPanel), null, _iconSize).getJComponentDisplay();
                iconFile = new File("icon.png");
                sp.writeImageToOutput(iconFile, .8f);
                updateIconPanel();
                customizeFrame.pack();
                customizeFrame.repaint();
                viewerPanel.removeAll();
                viewerPanel.add(sw_icon, BorderLayout.CENTER);
View Full Code Here

            SpriteIO._mt.removeImage(bi);
            r.dispose();
        } else {
            throw new JXAException("src is not one of the supported class.");
        }
        Sprite sp = null;
        boolean flushSp = false;
        ImageTypeSpecifier type = SpriteIO._getITS(DEFAULT_TYPE);
        if (!(src instanceof Sprite)) {
            sp = new Sprite(bi, "image/x-png", imageSize = new Dimension(bi.getWidth(null), bi.getHeight(null)));
            if (bi instanceof BufferedImage) {
                type = SpriteIO._getITS((BufferedImage) bi);
            }
            flushSp = true;
        } else {
            sp = (Sprite) src;
            type = sp.getFeatures();
            imageSize = sp.getSize();
        }
        sp.setBufferedType(type.getNumComponents() == 3 ? BufferedImage.TYPE_3BYTE_BGR : DEFAULT_TYPE);
        BufferedImage data = null;
        if (sp != null) {
            /**
             * provide a shortcut to texture rectangle (no resizing) ^^
             */
            if (_EXTtex == ARBTextureRectangle.GL_TEXTURE_RECTANGLE_ARB) {
                textureSize = imageSize.getSize();
            } else {
                textureSize.width = Sf3Texture._getNextPowerOfTwo(imageSize.width);
                textureSize.height = Sf3Texture._getNextPowerOfTwo(imageSize.height);
            }
            sp.setSize(textureSize);
            sp.runValidate();
            data = sp.toBuffered();
            textureSize.setSize(data.getWidth(), data.getHeight());
            Raster dataRaster = data.getRaster();
            dataBuffer = dataRaster.getDataBuffer();
            bands = dataRaster.getNumBands();
            if (JXAenvUtils._debug) {
                System.out.println("bufferedimage for texture has " + data.getRaster().getDataBuffer().getNumBanks() + " banks");
            }
        } else {
            return null;
        }
        Buffer pixelBuffer = null;
        switch (dataBuffer.getDataType()) {
            case DataBuffer.TYPE_BYTE:
                pixelBuffer = BufferIO._wrap(((DataBufferByte) dataBuffer).getData()).order(ByteOrder.nativeOrder());
                break;
            case DataBuffer.TYPE_DOUBLE:
                pixelBuffer = BufferIO._wrapd(((DataBufferDouble) dataBuffer).getData());
                break;
            case DataBuffer.TYPE_FLOAT:
                pixelBuffer = BufferIO._wrapf(((DataBufferFloat) dataBuffer).getData());
                break;
            case DataBuffer.TYPE_INT:
                pixelBuffer = BufferIO._wrapi(((DataBufferInt) dataBuffer).getData());
                break;
            case DataBuffer.TYPE_SHORT:
                pixelBuffer = BufferIO._wraps(((DataBufferShort) dataBuffer).getData());
                break;
            case DataBuffer.TYPE_USHORT:
                pixelBuffer = BufferIO._wraps(((DataBufferUShort) dataBuffer).getData());
                break;
            default:
                throw new JXAException("incompatible or unknown BufferedImage type :" + texture.toString());
        }
        data.flush();
        pixelBuffer = _convert2DTexBuffer(pixelBuffer, textureSize, bands, transferMode, dataBuffer.getDataType());
        if (pixelBuffer != null) {
            /**
             * instance Sf3Texture with the filled up pixelBuffer
             */
            texture = new Sf3Texture(hashCode, pixelBuffer, textureSize.width, textureSize.height, bands, imageSize, transferMode);
            if (JXAenvUtils._debug) {
                System.err.println("new Sf3Texture buffer " + BufferIO._getBufferDataTypeName(pixelBuffer) + " size : " + BufferIO._countByteSize(pixelBuffer) + " w/ " + bands + " bands is POT ? : " + (isPOT((float) pixelBuffer.limit() / (float) bands) ? "yes" : "no"));
            }
        } else {
            throw new JXAException("pixel buffer is null, no data could be loaded");
        }
        if (flushSp) {
            sp.clearResource();
        }
        return texture;
    }
View Full Code Here

            }
        }
        /**
         * display anim bounds
         */
        Sprite animSp = animRecord.getCurrentSprite();
        animSp.runValidate();
        Rectangle animBounds = animSp.getBounds();
        g.draw(animBounds);
        animSp.clearResource();
        /**
         * display default animBounds
         */
        Rectangle defBounds = new Rectangle(animBounds.getSize());
        g.draw(defBounds);
View Full Code Here

TOP

Related Classes of net.sf.jiga.xtended.impl.Sprite

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.