Package net.sf.jiga.xtended.impl

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


                }

        }

        private JComponent makeStore(BufferedImage image, final String key, String mime, Map<String, Serializable> attrs) {
                Sprite picture = new Sprite(image, mime, new Dimension(image.getWidth(), image.getHeight()));
                picture.setStoreMode(Sprite.MODE_JAVA2D);
                return makeStore(picture, key, mime, attrs);
        }
View Full Code Here


                if (!isEdit(key, false)) {
                        throw new JXAException("no edit-paint is current or another edit-paint is current on another Thread " + (lock.threadEdit));
                }
                try {
                        waitForPicture(key);
                        Sprite sprite;
                        if (collection.containsKey(key)) {
                                sprite = (Sprite) collection.get(key).get(ATTRIBUTE_SPRITE);
                                sprite.setSize((Dimension) collection.get(key).get(ATTRIBUTE_DIMENSION));
                        } else {
                                sprite = new Sprite();
                        }
                        return sprite.toBuffered();
                } catch (InterruptedException ex) {
                        ex.printStackTrace();
                        return null;
                }
        }
View Full Code Here

                        @Override
                        protected void paintComponent(Graphics g) {
                                super.paintComponent(g);
                                beginEdit(key, thumbnail);
                                Sprite picture = collection.getCollectionSprite(key, thumbnail);
                                boolean tiled = picture.isTileModeEnabled();
                                if (!thumbnail) {
                                        picture.setTileModeEnabled(picture.isTilesAvailable());
                                }
                                boolean bufferedOrig = picture.isBufferedImageEnabled();
                                picture.setBufferedImageEnabled(buffered);
                                Rectangle bounds = getBounds();
                                Rectangle origPicBds = picture.getBounds(), picBds = (Rectangle) origPicBds.clone();
                                /**
                                 * scale and preserve proportions
                                 */
                                double scale = Math.min((float) bounds.getWidth() / (float) picBds.getWidth(), (float) bounds.getHeight() / (float) picBds.getHeight());
                                picBds = AffineTransform.getScaleInstance(scale, scale).createTransformedShape(picBds).getBounds();
                                picBds.setLocation((int) Math.round(bounds.getCenterX() - picBds.getWidth() / 2.0), (int) Math.round(bounds.getCenterY() - picBds.getHeight() / 2.0));
                                FX fx = fxMap.containsKey(key) ? fxMap.get(key) : defaultFX;
                                if (isFXEnabled(key)) {
                                        picBds.grow(-Math.abs(fx.fx_loc.x), -Math.abs(fx.fx_loc.y));
                                }
                                picture.setBounds(picBds);
                                picture.runValidate();
                                g.translate(-bounds.x, -bounds.y);
                                picture.draw(this, (Graphics2D) g, fx.fx, fx.fx_loc, fx.fx_clr);
                                g.translate(bounds.x, bounds.y);
                                picture.setBounds(origPicBds);
                                picture.setTileModeEnabled(tiled);
                                picture.setBufferedImageEnabled(bufferedOrig);
                                endEdit(key, thumbnail);
                        }

                        @Override
                        public void addNotify() {
View Full Code Here

         */
        public Sprite getCollectionSprite(String key, boolean thumbnail) {
                if (!isEdit(key, thumbnail)) {
                        throw new JXAException("no edit-paint is current or another edit-paint is current on another Thread " + (thumbnail ? tbLock.threadEdit : lock.threadEdit));
                }
                Sprite picture;
                if (hasPicture(key, thumbnail)) {
                        picture = thumbnail ? (Sprite) tbCollection.get(key).get(ATTRIBUTE_SPRITE) : (Sprite) collection.get(key).get(ATTRIBUTE_SPRITE);
                } else {
                        picture = new Sprite();
                        picture.setSize(thumbnailSize);
                        picture.runValidate();
                        Image im = picture.getImage(obs);
                        Graphics2D g = Sprite.wrapRendering(Sprite._createImageGraphics(im));
                        Icon ic = UIMessage._getIcon(UIMessage.LOAD_TYPE, false);
                        ic.paintIcon(obs, g, (int) ((float) (picture.getWidth() - ic.getIconWidth()) / 2f), (int) ((float) (picture.getWidth() - ic.getIconWidth()) / 2f));
                        g.dispose();
                }
                picture.setMultiThreadingEnabled(multiThreading);
                updateIIOListeners(picture);
                picture.setMt(mt, obs);
                picture.setSPM(thumbnail ? _tbCollectionCache : _collectionCache);
                return picture;
        }
View Full Code Here

        public static SpriteGLHandler _GLgetLogo(Component c, String logo, Dimension size, boolean tileMode) {
                if (!spritesHashesBuffer.containsKey(logo)) {
                        _getLogo(c, logo, size, tileMode);
                }
                if ((_GLgetLoadState(spritesHashesBuffer.get(logo)) & _GLLOADSTATE_Cleared) != 0) {
                        Sprite sp = _getLogo(c, logo, size, tileMode);
                        _GLloadSprite(sp, (RenderingSceneGL) c);
                }
                int hash = spritesHashesBuffer.get(logo);
                return _GLSprites.getHandler(hash);
        }
View Full Code Here

                                }
                                fontMap = fontMap == null ? new HashMap<Font, Map<Integer, Integer>>(Collections.singletonMap(font, new HashMap<Integer, Integer>())) : fontMap;
                                if (newGlyph) {
                                        Shape glyph = gv.getGlyphOutline(i, -(float) glyphBounds.getX(), -(float) glyphBounds.getY());
                                        GLHandler.sTex.genVRAMBuffersMap(1);
                                        Sprite textCanvas = new Sprite();
                                        textCanvas.setBounds(glyphBounds.getBounds());
                                        textCanvas.setLocation((int) Math.round(glyphBounds.getX() + x), (int) Math.round(glyphBounds.getY() + y));
                                        textCanvas.runValidate();
                                        textCanvas.clearImageGraphics();
                                        Graphics2D g = Sprite.wrapRendering(textCanvas.getImage(gld).getGraphics());
                                        g.setFont(font);
                                        g.fill(glyph);
                                        g.draw(glyph);
                                        g.dispose();
                                        textCanvas.updateTexData(GL11.GL_LUMINANCE_ALPHA);
                                        SpriteGLHandler sp = _GLloadSprite(textCanvas, (RenderingSceneGL) gld);
                                        Sprite._GLRenderSprite(gld, true, sp, textCanvas.getBounds(), z, 0, new Point(0, 0), clr, 0, null, null, null);
                                        fontMap.get(font).put(font.getSize(), textCanvas.hashCode());
                                        _GLcharacterMap.put(glyphChar, fontMap);
                                } else {
                                        Rectangle bounds = new Rectangle((int) Math.round(glyphBounds.getX() + x), (int) Math.round(glyphBounds.getY() + y), (int) glyphBounds.getWidth(), (int) glyphBounds.getHeight());
                                        int spHash = fontMap.get(font).get(font.getSize());
                                        Sprite._GLRenderSprite(gld, true, _GLSprites.getHandler(spHash), bounds, z, 0, new Point(0, 0), clr, 0, null, null, null);
View Full Code Here

                                }
                                ll.loadBegin();
                                ll.loadProgress(0, anim.length() - 1);
                        }
                }
                Sprite sprite = frames.get(0);
                sprite.setRenderingScene(scene);
                sprite.setTexPty(anim.getTexPty());
                sprite.runValidate();
                Sf3Texture tex = sprite.getTexData().get(0);
                /**
                 * always try texture 3d mode (for smoother playback)
                 */
                if (tex.getWidth() <= GLHandler._GLgetMax3DTextureSize() && tex.getHeight() <= GLHandler._GLgetMax3DTextureSize()) {
                        anim.setTexture3D(true);
                }
                /**
                 * new texture 3d, sprites textures will be added subsequently
                 */
                final Sf3Texture3D tex3D = anim.isTexture3D() ? Sf3Texture3D._loadTexture3D(anim.getTex3DHash(), tex, anim.length()) : null;
                /*
                 * if (anim.isTexture3D()) { GLHandler._GLUnloadVRAM3D(tex3D); }
                 */
                try {
                        if (anim.isTexture3D()) {
                                GLHandler._GLLoadVRAM3D(tex3D, false, tex3D.hashCode());
                        }
                        synchronized (frames) {
                                for (int f : frames.keySet()) {
                                        final int spriteFrame = f;
                                        scene.doTaskOnGL(new Runnable() {
                                                @Override
                                                public void run() {
                                                        Sprite sprite = frames.get(spriteFrame);
                                                        if (sprite != null) {
                                                                sprite.setTexPty(anim.getTexPty());
                                                                sprite.setRenderingScene(scene);
                                                                sprite.runValidate();
                                                                try {
                                                                        if (anim.isTexture3D()) {
                                                                                _GLSprites.getHandler(sprite);
                                                                                /**
                                                                                 * add
                                                                                 * sprites
                                                                                 * tex
                                                                                 * to
                                                                                 * the
                                                                                 * texture
                                                                                 * 3d
                                                                                 * buffer
                                                                                 */
                                                                                if (!GLHandler.sTex.hasItem(tex3D.hashCode())) {
                                                                                        throw new IllegalStateException("unknown texture 3D");
                                                                                }
                                                                                GLHandler._GLLoadVRAM3D(sprite.getTexData().get(0), tex3D.hashCode(), spriteFrame);
                                                                                anim.getSprite(spriteFrame).loadIsComplete();
                                                                        } else {
                                                                                _GLloadSprite(sprite, scene);
                                                                        }
                                                                } catch (Exception ex) {
View Full Code Here

                        g.setColor(getBackground());
                        g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, arc, arc);
                        g.setColor(c);
                }
                if (offscreen == null) {
                        offscreen = /*!Sprite._isTrueVolatile() ? */ new Sprite(SpriteIO.createBufferedImage(getSize(), Sprite.DEFAULT_TYPE), "image/x-png", getSize())/* : new Sprite(Sprite.createVolatileImage(getSize()), "image/x-png", getSize())*/;
                        offscreen.setMt(new SfMediaTracker(this), this);
                }
                offscreen.setBounds(bounds);
                if (isIndeterminate()) {
                        _glow();
View Full Code Here

                Composite cps = g.getComposite();
                Color c = g.getColor();
                Rectangle compBounds = getBounds();
                Rectangle bounds = (Rectangle) compBounds.clone();
                if (mask == null) {
                        mask = /*!Sprite._isTrueVolatile() ? */ new Sprite(SpriteIO.createBufferedImage(getSize(), Sprite.DEFAULT_TYPE), "image/x-png", getSize())/* : new Sprite(Sprite.createVolatileImage(getSize()), "image/x-png", getSize())*/;
                }
                bounds.grow(6 - (int) ((float) bounds.width / 2f), 6 - (int) ((float) bounds.height / 2f));
                g.translate(-compBounds.x, -compBounds.y);
                g.clip(compBounds);
                Color ledColor = Color.WHITE;
View Full Code Here

    @Override
    protected void GLpaintComponent(RenderingScene gld, double z, int fx, Point fx_loc, Color fx_color) {
        Dimension iconSize = gui.ICONSIZE;
        Rectangle bounds = getBounds();
        if (glSprite == null) {
            Sprite icon = this.icon instanceof Sprite ? this.icon : RenderingScene._getLogo(gui.getScene(), gui.rb.getString("ICON"), iconSize);
            glSprite = RenderingScene._GLloadSprite(icon, gui.getScene());
        }
            Sprite._GLRenderSprite(gld, glSprite, bounds, z, fx, fx_loc, fx_color, 0, null, null,null);
            Color c = (isSelected() ? selectable.selectionColor.brighter() : isCellHasFocus() ? selectable.selectionColor : selectable.selectionColor.darker());
            GLGeom._GLdrawRoundRect(gld, hashCode(), true, 3f, bounds, z, GLGeom.getCWrgbaColors(c, gui.glow.glow), fx, fx_loc, fx_color);
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.