home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / hotjava / classsrc / browser / imgtag~1.jav < prev    next >
Encoding:
Text File  |  1995-08-11  |  1.9 KB  |  74 lines

  1. /*
  2.  * @(#)ImgTagRef.java    1.16 95/04/13 Jonathan Payne
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package browser;
  21.  
  22. import awt.DisplayItem;
  23. import net.www.html.Tag;
  24. import net.www.html.TagRef;
  25.  
  26. /**
  27.  * An instance of ImgTagRef is created for each instance of an <img>
  28.  * tag in an html document.
  29.  * @version 1.16, 13 Apr 1995
  30.  * @author Jonathan Payne
  31.  */
  32.  
  33. public class ImgTagRef extends DisplayItemTagRef {
  34.     public ImgTagRef(Tag t, int pos, boolean isEnd) {
  35.     super(t, pos, isEnd);
  36.     }
  37.  
  38.     public void prime(WRWindow w) {
  39.     if (!WRWindow.delayImageLoading) {
  40.         WRImageItem.kickImage(w, this);
  41.     }
  42.     }
  43.  
  44.     public void nuke() {
  45.     if (di != null) {
  46.         ((WRImageItem)di).nuke();
  47.     }
  48.     }
  49.  
  50.     public void buildDisplayItem(WRFormatter f) {
  51.     TagRef    anchor = f.anchorContext();
  52.     String    href = null;
  53.  
  54.     if (anchor != null) {
  55.         href = anchor.getAttribute("href");
  56.     }
  57.     di = new WRImageItem((WRWindow) f.win, this, href);
  58.     }
  59.  
  60.     public void apply(WRFormatter f) {
  61.     WRImageItem wim = (WRImageItem) di;
  62.  
  63.     if (wim == null) {
  64.         buildDisplayItem(f);
  65.         wim = (WRImageItem) di;
  66.     } else {
  67.         wim.checkImage(f.win);
  68.     }
  69.  
  70.     wim.waitForImageSize();
  71.     super.apply(f);
  72.     }
  73. }
  74.