Package java.awt

Examples of java.awt.MediaTracker$MediaEntry


    public static Image loadImage (String strFileName,
           Component component,
           boolean boolWait) {
        Image          image;
        MediaTracker   trackerMedia;

        image = loadImage ( strFileName );

        if ( image != null  &&  boolWait == true ) {
            trackerMedia = new MediaTracker ( component );
            trackerMedia.addImage ( image, 1001 );
            try {
                trackerMedia.waitForID ( 1001 );
            }
            catch ( Exception exception ) {
            }
        }
View Full Code Here


   */
  public Image readImage(byte[] bytes) throws JRException
  {
    Image image = Toolkit.getDefaultToolkit().createImage(bytes);

    MediaTracker tracker = new MediaTracker(new Panel());
    tracker.addImage(image, 0);
    try
    {
      tracker.waitForID(0);
    }
    catch (Exception e)
    {
      //image = null;
      throw new JRException(e);
    }

    if(tracker.isErrorID(0))
    {
      throw new JRException("Image read failed.");
    }

    return image;
View Full Code Here

    //Preparing parameters
    Image image =
      Toolkit.getDefaultToolkit().createImage(
        JRLoader.loadBytesFromLocation("dukesign.jpg")
        );
    MediaTracker traker = new MediaTracker(new Panel());
    traker.addImage(image, 0);
    try
    {
      traker.waitForID(0);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
View Full Code Here

    //Preparing parameters
    Image image =
      Toolkit.getDefaultToolkit().createImage(
        JRLoader.loadBytesFromLocation("dukesign.jpg")
        );
    MediaTracker traker = new MediaTracker(new Panel());
    traker.addImage(image, 0);
    try
    {
      traker.waitForID(0);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
View Full Code Here

  public void run() throws JRException
  {
    long start = System.currentTimeMillis();
    //Preparing parameters
    Image image = Toolkit.getDefaultToolkit().createImage("dukesign.jpg");
    MediaTracker traker = new MediaTracker(new Panel());
    traker.addImage(image, 0);
    try
    {
      traker.waitForID(0);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
View Full Code Here

                }

                if (w != width && h != height) {
                    // compute scaled image
                    final Image scaled = image.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING);
                    final MediaTracker mediaTracker = new MediaTracker(new Container());
                    mediaTracker.addImage(scaled, 0);
                    try {mediaTracker.waitForID(0);} catch (final InterruptedException e) {}

                    // make a BufferedImage out of that
                    final BufferedImage i = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                    try {
                        i.createGraphics().drawImage(scaled, 0, 0, width, height, null);
View Full Code Here

   * @param component image producer component
   * @return image or <code>null</code> if the image did not load
   */
  public static Image waitFor(Image image, Component component) {
    if (image != null) {
      MediaTracker tracker = new MediaTracker(component);
      tracker.addImage(image, 0);
      try {
        tracker.waitForAll();
        return image;
      }
      catch (InterruptedException ie) {
        ie.printStackTrace();
      }
      if (tracker.isErrorAny()) {
        /* DEBUG */System.err.println(MessageFormat.format(Messages.getString("UIUtil.imageDidNotLoad"), new Object[] { image.toString() } ) ); //$NON-NLS-1$
      }
    }
    /* DEBUG */System.err.println(Messages.getString("UIUtil.noImage")); //$NON-NLS-1$
    return null;
View Full Code Here

import net.yacy.document.parser.images.icoParser;

public class ImageParser {
   
    public static final Image parse(final String filename, final byte[] source) {
        final MediaTracker mediaTracker = new MediaTracker(new Container());
        Image image;
        if (((filename.endsWith(".ico")) || (filename.endsWith(".bmp"))) && (bmpParser.isBMP(source))) {
            // parse image with BMP parser
            image = bmpParser.parse(source).getImage();
            if (image == null) return null;
        } else if ((filename.endsWith(".ico")) && (icoParser.isICO(source))) {
            // parse image with ICO parser
            icoParser icoparser;
            icoparser = new icoParser(source);
            image = icoparser.getImage(0);
            if (image == null) return null;
        } else {
            // awt can handle jpg, png and gif formats, try it
            image = Toolkit.getDefaultToolkit().createImage(source);
            /*
            try {
                ImageIO.setUseCache(false); // do not write a cache to disc; keep in RAM
                image = ImageIO.read(new ByteArrayInputStream(source));
            } catch (IOException e) {
                Image i = Toolkit.getDefaultToolkit().createImage(source);
                mediaTracker.addImage(i, 0);
                try {mediaTracker.waitForID(0);} catch (final InterruptedException ee) {}
               
                int width = i.getWidth(null); if (width < 0) width = 96; // bad hack
                int height = i.getHeight(null); if (height < 0) height = 96; // bad hack
                image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                image.createGraphics().drawImage(i, 0, 0, width, height, null);
            }
             */
        }
       
        final int handle = image.hashCode();
        mediaTracker.addImage(image, handle);
        try {mediaTracker.waitForID(handle);} catch (final InterruptedException e) {}
       
        return image;
    }
View Full Code Here

      Component comp = new Component() {
        private static final long  serialVersionUID  = 1L;
      };

      Image i2 = orig.getScaledInstance(destWidth, destHeight, Image.SCALE_SMOOTH);
      MediaTracker tracker = new MediaTracker(comp);
      tracker.addImage(i2, 0);
      try {
        tracker.waitForID(0);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      // Log.log("ServletExtension: i2 size : "+i2.getWidth(comp)+"x"+i2.getHeight(comp));
View Full Code Here

    // Frame icon
    final String iconName1
      = baseName +(Util.isWindows() ? "16x16.png" : "32x32.png");
    // Max OS X dock icon
    final String iconName2 = baseName +"128x128.png";
    final MediaTracker tracker = new MediaTracker(frame);
    try {
      final URL[] urls = new URL[]{
        getClass().getResource(iconName1),
        getClass().getResource(iconName2)
      };

      final Image[] images = new Image[urls.length];
      for (int i=0; i<urls.length; i++) {
        if(urls[i] != null) {
          images[i] = frame.getToolkit().getImage(urls[i]);
          tracker.addImage(images[i], 0);
        }
      }
      tracker.waitForID(0);

      if (null!=images[0]) frame.setIconImage(images[0]);
      // Set the dock icon.
      if(null!=images[1] && bMacOS) {
        try {
View Full Code Here

TOP

Related Classes of java.awt.MediaTracker$MediaEntry

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.