org.w3c.mwi.mobileok.basic
Class GifImageContent

java.lang.Object
  extended by org.w3c.mwi.mobileok.basic.DecodedContent
      extended by org.w3c.mwi.mobileok.basic.ImageContent
          extended by org.w3c.mwi.mobileok.basic.GifImageContent

public class GifImageContent
extends ImageContent

Represents a image/gif image resource.

Version:
$Revision: 1.1 $
Author:
The W3C mobileOK Checker Task Force

Field Summary
private  java.util.List<ValidationByteMessage> imageErrorMessageList
          List of image format validation errors.
private  int imageHeight
          Height of the image in pixels.
private  int imageWidth
          Width of the image in pixels.
private  boolean transparency
          True when the image uses transparency (GIF images only).
private  boolean valid
          True when the format of the image could be validated successfully.
 
Constructor Summary
GifImageContent(java.net.URI uri, java.util.List<RetrievalElement> retrieved)
          Creates a class instance bound to a URI.
 
Method Summary
private  boolean checkTransparency(RetrievalElement retrieved)
          Checks whether the image/gif image uses transparency.
 java.util.List<ValidationByteMessage> getImageErrorMessageList()
          Returns the list of image format validation error messages.
 int getImageHeight()
          Returns the height of the image.
 java.lang.String getImageType()
          Returns the image content-type.
 int getImageWidth()
          Returns the width of the image.
 boolean hasTransparency()
          Returns true when the image uses transparency.
private  boolean isTransparent(java.awt.Image img, int w, int h)
          Checks whether the given image/gif image is fully transparent.
 boolean isValid()
          Returns true when the content could be successfully decoded.
 
Methods inherited from class org.w3c.mwi.mobileok.basic.ImageContent
toMokiNode
 
Methods inherited from class org.w3c.mwi.mobileok.basic.DecodedContent
addByteErrorMessages, addLineAndColumnMessages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

valid

private boolean valid
True when the format of the image could be validated successfully.


imageWidth

private int imageWidth
Width of the image in pixels.


imageHeight

private int imageHeight
Height of the image in pixels.


transparency

private boolean transparency
True when the image uses transparency (GIF images only).


imageErrorMessageList

private java.util.List<ValidationByteMessage> imageErrorMessageList
List of image format validation errors.

Constructor Detail

GifImageContent

public GifImageContent(java.net.URI uri,
                       java.util.List<RetrievalElement> retrieved)
                throws TestException
Creates a class instance bound to a URI.

The content is validated while it is instantiated.

Parameters:
uri - absolute URI of the resource.
retrieved - the retrieved representation of the resource.
Throws:
TestException - an unexpected error occurred while retrieving the resource.
Method Detail

checkTransparency

private boolean checkTransparency(RetrievalElement retrieved)
                           throws TestException
Checks whether the image/gif image uses transparency.

ImageIO is used to check transparency because JhoveBase does not provide that functionality.

Parameters:
retrieved - the last retrieved exchange that represents the resource.
Returns:
true when the image uses transparency, false otherwise.
Throws:
TestException

isTransparent

private boolean isTransparent(java.awt.Image img,
                              int w,
                              int h)
                       throws TestException
Checks whether the given image/gif image is fully transparent.

Returns:
true when the image is fully transparent, false otherwise.
Throws:
TestException

getImageHeight

public int getImageHeight()
Description copied from class: ImageContent
Returns the height of the image.

Specified by:
getImageHeight in class ImageContent
Returns:
the height of the image, in pixels.

getImageWidth

public int getImageWidth()
Description copied from class: ImageContent
Returns the width of the image.

Specified by:
getImageWidth in class ImageContent
Returns:
the width of the image, in pixels.

hasTransparency

public boolean hasTransparency()
Description copied from class: ImageContent
Returns true when the image uses transparency.

Support for transparency may depend on the image format. A false may thus also mean that transparency simply cannot be used.

Specified by:
hasTransparency in class ImageContent
Returns:
true when the image uses transparency, false otherwise.

isValid

public boolean isValid()
Description copied from class: DecodedContent
Returns true when the content could be successfully decoded.

Specified by:
isValid in class DecodedContent
Returns:
true when the content is valid, false otherwise.

getImageErrorMessageList

public java.util.List<ValidationByteMessage> getImageErrorMessageList()
Description copied from class: ImageContent
Returns the list of image format validation error messages.

Specified by:
getImageErrorMessageList in class ImageContent
Returns:
the list of validation error messages.

getImageType

public java.lang.String getImageType()
Description copied from class: ImageContent
Returns the image content-type.

Specified by:
getImageType in class ImageContent
Returns:
the image type