org.xhtmlrenderer.swing
Class DeferredImageReplacedElement

java.lang.Object
  extended by org.xhtmlrenderer.swing.ImageReplacedElement
      extended by org.xhtmlrenderer.swing.DeferredImageReplacedElement
All Implemented Interfaces:
ReplacedElement

public class DeferredImageReplacedElement
extends ImageReplacedElement

An DeferredImageReplacedElement is a ReplacedElement that contains a Image which by default is simply a transparent image scaled to the size provided to the constructor. The DeferredImageReplacedElement also has a reference to an ImageResource which points to the image which will be returned for this replaced element. That Image may be loaded some time after this DeferredImageReplacedElement is created. Calling getImage() on instances of DeferredImageReplacedElement will return either the original dummy image, or the actual image loaded into the ImageResource.


Field Summary
 
Fields inherited from class org.xhtmlrenderer.swing.ImageReplacedElement
_image
 
Constructor Summary
DeferredImageReplacedElement(ImageResource imageResource, RepaintListener repaintListener, int w, int h)
          Creates a new ImageReplacedElement and scales it to the size specified if either width or height has a valid value (values are > -1), otherwise original size is preserved.
 
Method Summary
 void detach(LayoutContext c)
          
 int getBaseline()
           
 Image getImage()
          The image we're replacing.
 int getIntrinsicHeight()
          
 int getIntrinsicWidth()
          
 Point getLocation()
          Returns the current location where the element will be rendered on the canvas
 boolean hasBaseline()
           
 boolean isRequiresInteractivePaint()
          
 void setLocation(int x, int y)
          Assigns the new locations where the element will be rendered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeferredImageReplacedElement

public DeferredImageReplacedElement(ImageResource imageResource,
                                    RepaintListener repaintListener,
                                    int w,
                                    int h)
Creates a new ImageReplacedElement and scales it to the size specified if either width or height has a valid value (values are > -1), otherwise original size is preserved. The idea is that the image was loaded at a certain size (that's the Image instance here) and that at the time we create the ImageReplacedElement we have a target W/H we want to use.

Parameters:
imageResource -
repaintListener -
Method Detail

detach

public void detach(LayoutContext c)

Specified by:
detach in interface ReplacedElement
Overrides:
detach in class ImageReplacedElement

getIntrinsicHeight

public int getIntrinsicHeight()

Specified by:
getIntrinsicHeight in interface ReplacedElement
Overrides:
getIntrinsicHeight in class ImageReplacedElement

getIntrinsicWidth

public int getIntrinsicWidth()

Specified by:
getIntrinsicWidth in interface ReplacedElement
Overrides:
getIntrinsicWidth in class ImageReplacedElement

getLocation

public Point getLocation()
Returns the current location where the element will be rendered on the canvas

Specified by:
getLocation in interface ReplacedElement
Overrides:
getLocation in class ImageReplacedElement
Returns:
see desc

isRequiresInteractivePaint

public boolean isRequiresInteractivePaint()

Specified by:
isRequiresInteractivePaint in interface ReplacedElement
Overrides:
isRequiresInteractivePaint in class ImageReplacedElement

setLocation

public void setLocation(int x,
                        int y)
Assigns the new locations where the element will be rendered.

Specified by:
setLocation in interface ReplacedElement
Overrides:
setLocation in class ImageReplacedElement
Parameters:
x - new horizontal pos
y - new vertical pos

getImage

public Image getImage()
The image we're replacing.

Overrides:
getImage in class ImageReplacedElement
Returns:
see desc

getBaseline

public int getBaseline()
Specified by:
getBaseline in interface ReplacedElement
Overrides:
getBaseline in class ImageReplacedElement

hasBaseline

public boolean hasBaseline()
Specified by:
hasBaseline in interface ReplacedElement
Overrides:
hasBaseline in class ImageReplacedElement


Copyright © 2013. All Rights Reserved.