HTML Parser Home Page

org.htmlparser.lexerapplications.thumbelina
Class Picture

java.lang.Object
  extended by java.awt.geom.RectangularShape
      extended by java.awt.geom.Rectangle2D
          extended by java.awt.Rectangle
              extended by org.htmlparser.lexerapplications.thumbelina.Picture
All Implemented Interfaces:
ImageObserver, Shape, Serializable, Cloneable, Runnable, Tile

public class Picture
extends Rectangle
implements Runnable, ImageObserver, Tile

Class to track pictures within the frame. Maintains an image, an area and the URL for it.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
 
Field Summary
protected  Point mExtent
          The lower right hand corner of the image.
protected  Image mImage
          The cached image.
 PictureListener mListener
          The object to notify about picture events;
protected  File mLocalFile
          The local file containing the picture.
protected  Point mOrigin
          The upper left hand corner of the image.
protected  URL mURL
          The URL for the picture.
protected  boolean mValid
          Flag indicating the image is valid.
static Point ORIGIN
          The origin for new points from the zero args constructor.
protected  int TRANSFER_SIZE
          Copy buffer size.
 
Fields inherited from class java.awt.Rectangle
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Picture(URL url, PictureListener listener, Rectangle r)
          Construct a picture over the rectangle given.
 
Method Summary
 Point getExtent()
          Getter for property extent.
 Object getIdentity()
          Getter for property identity.
 Image getImage()
          Getter for property image.
 Point getOrigin()
          Getter for property origin.
 boolean getValid()
           
 boolean imageUpdate(Image image, int infoflags, int x, int y, int width, int height)
          This method is called when information about an image which was previously requested using an asynchronous interface becomes available.
 void reset()
          Reset the picture to uncropped size.
 void run()
           
 void setBounds(int x, int y, int width, int height)
           
 void setBounds(Rectangle r)
          Set the rectangular region for this tile.
 void setExtent(Point extent)
          Setter for property extent.
 void setIdentity(Object object)
          Setter for property identity.
 void setOrigin(Point origin)
          Setter for property origin.
 void setValid(boolean valid)
          Sets the validity of the picture.
 String toString()
          Create a string representation of the picture.
 
Methods inherited from class java.awt.Rectangle
add, add, add, contains, contains, contains, contains, createIntersection, createUnion, equals, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setLocation, setLocation, setRect, setSize, setSize, translate, union
 
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
 
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.htmlparser.lexerapplications.thumbelina.Tile
clone, getBounds
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects
 

Field Detail

TRANSFER_SIZE

protected final int TRANSFER_SIZE
Copy buffer size. Resources are moved to disk in chunks this size or less.

See Also:
Constant Field Values

ORIGIN

public static final Point ORIGIN
The origin for new points from the zero args constructor.


mURL

protected URL mURL
The URL for the picture.


mListener

public PictureListener mListener
The object to notify about picture events;


mValid

protected boolean mValid
Flag indicating the image is valid.


mOrigin

protected Point mOrigin
The upper left hand corner of the image. This doesn't change, even if the image is cropped. For example, if the left half of the image is obscured by another, the Rectangle fields x, y, width and height will change, but the origin remains the same.


mExtent

protected Point mExtent
The lower right hand corner of the image. This doesn't change, even if the image is cropped. For example, if the right half of the image is obscured by another, the Rectangle fields width and height will change, but the extent remains the same.


mImage

protected Image mImage
The cached image.


mLocalFile

protected File mLocalFile
The local file containing the picture.

Constructor Detail

Picture

public Picture(URL url,
               PictureListener listener,
               Rectangle r)
Construct a picture over the rectangle given.

Parameters:
r - The coordinates of the area.
Method Detail

getOrigin

public Point getOrigin()
Getter for property origin.

Returns:
Value of property origin.

setOrigin

public void setOrigin(Point origin)
Setter for property origin.

Parameters:
origin - New value of property origin.

getExtent

public Point getExtent()
Getter for property extent.

Returns:
Value of property extent.

setExtent

public void setExtent(Point extent)
Setter for property extent.

Parameters:
extent - New value of property extent.

getImage

public Image getImage()
Getter for property image.

Returns:
Value of property image.

run

public void run()
Specified by:
run in interface Runnable

getValid

public boolean getValid()
Specified by:
getValid in interface Tile

setValid

public void setValid(boolean valid)
Sets the validity of the picture.

Specified by:
setValid in interface Tile
Parameters:
valid - If true the picture is marked valid, false otherwise.

getIdentity

public Object getIdentity()
Getter for property identity.

Specified by:
getIdentity in interface Tile
Returns:
Value of property identity.

setIdentity

public void setIdentity(Object object)
Setter for property identity.

Specified by:
setIdentity in interface Tile
Parameters:
object - New value of property identity.

reset

public void reset()
Reset the picture to uncropped size.

Specified by:
reset in interface Tile

setBounds

public void setBounds(Rectangle r)
Description copied from interface: Tile
Set the rectangular region for this tile. Crops the tile to the size provided.

Specified by:
setBounds in interface Tile
Overrides:
setBounds in class Rectangle
Parameters:
r - The new boundary.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overrides:
setBounds in class Rectangle

imageUpdate

public boolean imageUpdate(Image image,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
This method is called when information about an image which was previously requested using an asynchronous interface becomes available. Asynchronous interfaces are method calls such as getWidth(ImageObserver) and drawImage(img, x, y, ImageObserver) which take an ImageObserver object as an argument. Those methods register the caller as interested either in information about the overall image itself (in the case of getWidth(ImageObserver)) or about an output version of an image (in the case of the drawImage(img, x, y, [w, h,] ImageObserver) call).

This method should return true if further updates are needed or false if the required information has been acquired. The image which was being tracked is passed in using the img argument. Various constants are combined to form the infoflags argument which indicates what information about the image is now available. The interpretation of the x, y, width, and height arguments depends on the contents of the infoflags argument.

The infoflags argument should be the bitwise inclusive OR of the following flags: WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.

Specified by:
imageUpdate in interface ImageObserver
Parameters:
image - the image being observed.
infoflags - the bitwise inclusive OR of the following flags: WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.
x - the x coordinate.
y - the y coordinate.
width - the width.
height - the height.
Returns:
false if the infoflags indicate that the image is completely loaded; true otherwise.
See Also:
ImageObserver.WIDTH, ImageObserver.HEIGHT, ImageObserver.PROPERTIES, ImageObserver.SOMEBITS, ImageObserver.FRAMEBITS, ImageObserver.ALLBITS, ImageObserver.ERROR, ImageObserver.ABORT, Image.getWidth(java.awt.image.ImageObserver), Image.getHeight(java.awt.image.ImageObserver), Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)

toString

public String toString()
Create a string representation of the picture.

Overrides:
toString in class Rectangle
Returns:
A string that shows this picture URL and size.

© 2006 Derrick Oswald
Sep 17, 2006

HTML Parser is an open source library released under Common Public License. SourceForge.net