< prev index next >

src/java.desktop/share/classes/java/awt/MediaTracker.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 352      * Returns a list of all media that have encountered an error.
 353      * @return       an array of media objects tracked by this
 354      *                        media tracker that have encountered
 355      *                        an error, or {@code null} if
 356      *                        there are none with errors
 357      * @see          java.awt.MediaTracker#isErrorAny
 358      * @see          java.awt.MediaTracker#getErrorsID
 359      */
 360     public synchronized Object[] getErrorsAny() {
 361         MediaEntry cur = head;
 362         int numerrors = 0;
 363         while (cur != null) {
 364             if ((cur.getStatus(false, true) & ERRORED) != 0) {
 365                 numerrors++;
 366             }
 367             cur = cur.next;
 368         }
 369         if (numerrors == 0) {
 370             return null;
 371         }
 372         Object errors[] = new Object[numerrors];
 373         cur = head;
 374         numerrors = 0;
 375         while (cur != null) {
 376             if ((cur.getStatus(false, false) & ERRORED) != 0) {
 377                 errors[numerrors++] = cur.getMedia();
 378             }
 379             cur = cur.next;
 380         }
 381         return errors;
 382     }
 383 
 384     /**
 385      * Starts loading all images tracked by this media tracker. This
 386      * method waits until all the images being tracked have finished
 387      * loading.
 388      * <p>
 389      * If there is an error while loading or scaling an image, then that
 390      * image is considered to have finished loading. Use the
 391      * {@code isErrorAny} or {@code isErrorID} methods to
 392      * check for errors.


 581      *                       that have encountered an error, or
 582      *                       {@code null} if there are none with errors
 583      * @see         java.awt.MediaTracker#isErrorID
 584      * @see         java.awt.MediaTracker#isErrorAny
 585      * @see         java.awt.MediaTracker#getErrorsAny
 586      */
 587     public synchronized Object[] getErrorsID(int id) {
 588         MediaEntry cur = head;
 589         int numerrors = 0;
 590         while (cur != null) {
 591             if (cur.getID() == id
 592                 && (cur.getStatus(false, true) & ERRORED) != 0)
 593             {
 594                 numerrors++;
 595             }
 596             cur = cur.next;
 597         }
 598         if (numerrors == 0) {
 599             return null;
 600         }
 601         Object errors[] = new Object[numerrors];
 602         cur = head;
 603         numerrors = 0;
 604         while (cur != null) {
 605             if (cur.getID() == id
 606                 && (cur.getStatus(false, false) & ERRORED) != 0)
 607             {
 608                 errors[numerrors++] = cur.getMedia();
 609             }
 610             cur = cur.next;
 611         }
 612         return errors;
 613     }
 614 
 615     /**
 616      * Starts loading all images tracked by this media tracker with the
 617      * specified identifier. This method waits until all the images with
 618      * the specified identifier have finished loading.
 619      * <p>
 620      * If there is an error while loading or scaling an image, then that
 621      * image is considered to have finished loading. Use the


   1 /*
   2  * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 352      * Returns a list of all media that have encountered an error.
 353      * @return       an array of media objects tracked by this
 354      *                        media tracker that have encountered
 355      *                        an error, or {@code null} if
 356      *                        there are none with errors
 357      * @see          java.awt.MediaTracker#isErrorAny
 358      * @see          java.awt.MediaTracker#getErrorsID
 359      */
 360     public synchronized Object[] getErrorsAny() {
 361         MediaEntry cur = head;
 362         int numerrors = 0;
 363         while (cur != null) {
 364             if ((cur.getStatus(false, true) & ERRORED) != 0) {
 365                 numerrors++;
 366             }
 367             cur = cur.next;
 368         }
 369         if (numerrors == 0) {
 370             return null;
 371         }
 372         Object[] errors = new Object[numerrors];
 373         cur = head;
 374         numerrors = 0;
 375         while (cur != null) {
 376             if ((cur.getStatus(false, false) & ERRORED) != 0) {
 377                 errors[numerrors++] = cur.getMedia();
 378             }
 379             cur = cur.next;
 380         }
 381         return errors;
 382     }
 383 
 384     /**
 385      * Starts loading all images tracked by this media tracker. This
 386      * method waits until all the images being tracked have finished
 387      * loading.
 388      * <p>
 389      * If there is an error while loading or scaling an image, then that
 390      * image is considered to have finished loading. Use the
 391      * {@code isErrorAny} or {@code isErrorID} methods to
 392      * check for errors.


 581      *                       that have encountered an error, or
 582      *                       {@code null} if there are none with errors
 583      * @see         java.awt.MediaTracker#isErrorID
 584      * @see         java.awt.MediaTracker#isErrorAny
 585      * @see         java.awt.MediaTracker#getErrorsAny
 586      */
 587     public synchronized Object[] getErrorsID(int id) {
 588         MediaEntry cur = head;
 589         int numerrors = 0;
 590         while (cur != null) {
 591             if (cur.getID() == id
 592                 && (cur.getStatus(false, true) & ERRORED) != 0)
 593             {
 594                 numerrors++;
 595             }
 596             cur = cur.next;
 597         }
 598         if (numerrors == 0) {
 599             return null;
 600         }
 601         Object[] errors = new Object[numerrors];
 602         cur = head;
 603         numerrors = 0;
 604         while (cur != null) {
 605             if (cur.getID() == id
 606                 && (cur.getStatus(false, false) & ERRORED) != 0)
 607             {
 608                 errors[numerrors++] = cur.getMedia();
 609             }
 610             cur = cur.next;
 611         }
 612         return errors;
 613     }
 614 
 615     /**
 616      * Starts loading all images tracked by this media tracker with the
 617      * specified identifier. This method waits until all the images with
 618      * the specified identifier have finished loading.
 619      * <p>
 620      * If there is an error while loading or scaling an image, then that
 621      * image is considered to have finished loading. Use the


< prev index next >