PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Java|javax|swing|BufferStrategyPaintManager.java =

page 9 of 10



            Container root = getRoot();
            if (root == null) {
                return null;
            }
            BufferStrategy bs = null;
            if (TRY_FLIP) {
                bs = createBufferStrategy(root,BufferCapabilities.FlipContents.
                                          COPIED);
                usingFlip = true;
                if (LOGGER.isLoggable(Level.FINER)) {
                    LOGGER.finer("createBufferStrategy: using flip strategy");
                }
            }
            if (bs == null) {
                bs = createBufferStrategy(root, null);
                usingFlip = false;
            }
            if (!(bs instanceof SubRegionShowable)) {
                // We do this for two reasons:
                // 1. So that we know we can cast to SubRegionShowable and
                //    invoke show with the minimal region to update
                // 2. To avoid the possibility of invoking client code
                //    on the toolkit thread.
                bs = null;
            }
            return bs;
        }

        // Creates and returns a buffer strategy of the requested type.  If
        // there is a problem creating the buffer strategy this will
        // eat the exception and return null.
        private BufferStrategy createBufferStrategy(Container root,
                                     BufferCapabilities.FlipContents type) {
            BufferCapabilities caps = new BufferCapabilities(
		    new ImageCapabilities(true),
                    new ImageCapabilities(true),
                    type);
            BufferStrategy bs = null;
            if (root instanceof Applet) {
                try {
                    getCreateBufferStrategyMethod().invoke(root, 2, caps);
                    bs = (BufferStrategy)getGetBufferStrategyMethod().
                                            invoke(root);
                } catch (InvocationTargetException ite) {
                    // Type is not supported
                    if (LOGGER.isLoggable(Level.FINER)) {
                        LOGGER.log(Level.FINER, "createBufferStratety failed",
                                   ite);
                    }
                } catch (IllegalArgumentException iae) {
                    assert false;
                } catch (IllegalAccessException iae2) {
                    assert false;
                }
            }
            else {
                try {
                    ((Window)root).createBufferStrategy(2, caps);
                    bs = ((Window)root).getBufferStrategy();
                } catch (AWTException e) {
                    // Type not supported
                    if (LOGGER.isLoggable(Level.FINER)) {
                        LOGGER.log(Level.FINER, "createBufferStratety failed",
                                   e);
                    }
                }
            }
            return bs;
        }

        /**
         * Cleans up and removes any references.
         */
        public void dispose() {
            Container root = getRoot();
            if (LOGGER.isLoggable(Level.FINER)) {
                LOGGER.log(Level.FINER, "disposed BufferInfo for: " + root);
            }
            if (root != null) {
                root.removeComponentListener(this);
                if (root instanceof Window) {
                    ((Window)root).removeWindowListener(this);
                }
                BufferStrategy bs = getBufferStrategy(false);
                if (bs != null) {
                    bs.dispose();
                }
            }
            this.root = null;
            weakBS = null;
        }

        // We mark the buffer as needing to be painted on a hide/iconify
        // because the developer may have conditionalized painting based on
        // visibility.
        // Ideally we would also move to having the BufferStrategy being
        // a SoftReference in Component here, but that requires changes to
        // Component and the like.
        public void componentHidden(ComponentEvent e) {
            Container root = getRoot();
=9=

1|2|3|4|5|6|7|8| < PREV = PAGE 9 = NEXT > |10

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.011687 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)