edu.umd.cs.jazz.component
Class ZImage

java.lang.Object
  |
  +--edu.umd.cs.jazz.scenegraph.ZVisualComponent
        |
        +--edu.umd.cs.jazz.component.ZImage

public class ZImage
extends ZVisualComponent

ZImage is a graphic object that represents a raster image


Field Summary
protected  java.lang.String fileName
           
protected  int height
           
protected  java.awt.Image image
           
protected  edu.umd.cs.jazz.component.ZImageObserver observer
           
protected  java.awt.geom.Rectangle2D rect
           
protected static java.awt.Component staticComponent
           
protected  java.net.URL url
           
protected  int width
           
protected  boolean writeEmbeddedImage
           
static boolean writeEmbeddedImage_DEFAULT
           
 
Fields inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
cacheVolatile, findable, findable_DEFAULT, isVolatile, localBounds, localBoundsDirty, parent, pickable, pickable_DEFAULT, selected
 
Constructor Summary
ZImage()
          Constructs a new Image.
ZImage(byte[] bytes)
           
ZImage(java.awt.Image i)
           
ZImage(java.lang.String aFileName)
           
ZImage(java.net.URL aUrl)
           
ZImage(ZImage zi)
          Constructs a new ZImage that is a duplicate of the reference zimage, i.e., a "copy constructor"
 
Method Summary
 java.lang.Object clone()
          Duplicates the current ZImage by using the copy constructor.
protected  void computeLocalBounds()
          Notifies this object that it has changed and that it should update its notion of its bounding box.
 java.lang.String getAbsolutePath(java.lang.String path)
          Given a directory path plus some path relative to it, return a direct absolute path.
 java.lang.String getFileName()
          Return the filename associated with this image object.
 int getHeight()
          Return height of image.
 java.awt.Image getImage()
          Return the AWT image associated with this image object.
 java.lang.String getRelativePath(java.lang.String fileName, java.lang.String basePath)
          Returns the directory path of a file name, relative to another absolute path basePath.
 java.net.URL getUrl()
          Return the URL associated with this image object.
 int getWidth()
          Return width of image.
 boolean getWriteEmbeddedImage()
          Determine if this image gets saved by writing the binary image into the file.
 boolean isLoaded()
           
protected  void loadImage(java.awt.Image im)
           
 void paint(ZRenderContext renderContext)
          Paints this object.
 void setFileName(java.lang.String aFileName)
          Sets the filename of the image.
 boolean setImage(byte[] bytes)
           
 boolean setImage(java.awt.Image i)
           
 boolean setImage(java.lang.String aFileName)
          loads an image
 boolean setImage(java.net.URL aUrl)
           
protected  void setLoaded(boolean l)
          Called when the image has been loaded.
 void setState(java.lang.String fieldType, java.lang.String fieldName, java.lang.Object fieldValue)
          Set some state of this object as it gets read back in.
 void setUrl(java.net.URL aUrl)
          Sets the URL of the image.
 void setWriteEmbeddedImage(boolean value)
          Specify if this image gets saved by writing the binary image into the file, or if it instead writes the filename of the image, and thus requires that the external image file exists in the same place to reload.
 java.lang.String toString()
          Generate a string that represents this object for debugging.
 void writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 
Methods inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
damage, damage, findNode, findVisualComponent, getLocalBounds, getParent, isFindable, isPickable, isSelected, isVolatile, pick, pickBounds, select, select, setFindable, setParent, setPickable, setSelected, setVisualComponent, setVolatile, transformChanged, unselect, updateBounds, updateChildBounds, updateLocalBounds, updateVolatility, writeObjectRecurse
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

writeEmbeddedImage_DEFAULT

public static final boolean writeEmbeddedImage_DEFAULT

staticComponent

protected static final java.awt.Component staticComponent

width

protected int width

height

protected int height

image

protected java.awt.Image image

rect

protected java.awt.geom.Rectangle2D rect

observer

protected edu.umd.cs.jazz.component.ZImageObserver observer

writeEmbeddedImage

protected boolean writeEmbeddedImage

fileName

protected java.lang.String fileName

url

protected java.net.URL url
Constructor Detail

ZImage

public ZImage()
Constructs a new Image.

ZImage

public ZImage(java.awt.Image i)

ZImage

public ZImage(ZImage zi)
Constructs a new ZImage that is a duplicate of the reference zimage, i.e., a "copy constructor"
Parameters:
zi - Reference zimage

ZImage

public ZImage(java.lang.String aFileName)

ZImage

public ZImage(java.net.URL aUrl)

ZImage

public ZImage(byte[] bytes)
Method Detail

clone

public java.lang.Object clone()
Duplicates the current ZImage by using the copy constructor. See the copy constructor comments for complete information about what is duplicated.
Overrides:
clone in class ZVisualComponent
See Also:
ZImage(ZImage)

getAbsolutePath

public java.lang.String getAbsolutePath(java.lang.String path)
Given a directory path plus some path relative to it, return a direct absolute path. eg "/a/b/c/" + "../../e/f/g.ext" yields: /a/e/f/g.ext

getRelativePath

public java.lang.String getRelativePath(java.lang.String fileName,
                                        java.lang.String basePath)
Returns the directory path of a file name, relative to another absolute path basePath.
Parameters:
fileName - absolute path of a file.
baseName - absolute base path.

setImage

public boolean setImage(java.awt.Image i)

setImage

public boolean setImage(byte[] bytes)

setImage

public boolean setImage(java.lang.String aFileName)
loads an image
Parameters:
aFileName - the file name of the image.

setImage

public boolean setImage(java.net.URL aUrl)

loadImage

protected void loadImage(java.awt.Image im)

getImage

public java.awt.Image getImage()
Return the AWT image associated with this image object.
Returns:
the AWT image.

setFileName

public void setFileName(java.lang.String aFileName)
Sets the filename of the image. This does not change the image, but rather just stores the filename for future access.
Parameters:
aFileName - the file name.

getFileName

public java.lang.String getFileName()
Return the filename associated with this image object.
Returns:
the filename.

setUrl

public void setUrl(java.net.URL aUrl)
Sets the URL of the image. This does not change the image, but rather just stores the URL for future access.
Parameters:
aURL - the file name.

getUrl

public java.net.URL getUrl()
Return the URL associated with this image object.
Returns:
the URL.

setWriteEmbeddedImage

public void setWriteEmbeddedImage(boolean value)
Specify if this image gets saved by writing the binary image into the file, or if it instead writes the filename of the image, and thus requires that the external image file exists in the same place to reload.
Parameters:
value - true to embed image in file, and false to store a link

getWriteEmbeddedImage

public boolean getWriteEmbeddedImage()
Determine if this image gets saved by writing the binary image into the file. Return false if it stores the name of the file that contains the image.
Returns:
true to embed image in file

computeLocalBounds

protected void computeLocalBounds()
Notifies this object that it has changed and that it should update its notion of its bounding box. Note that this should not be called directly. Instead, it is called by updateBounds when needed.
Overrides:
computeLocalBounds in class ZVisualComponent
See Also:
ZNode.getGlobalBounds()

paint

public void paint(ZRenderContext renderContext)
Paints this object.
Parameters:
g2 - The graphics context to paint into.
Overrides:
paint in class ZVisualComponent

getWidth

public int getWidth()
Return width of image. If the width is not yet available, this will return -1, and the observer will be notified of the dimensions later.
Returns:
width.

getHeight

public int getHeight()
Return height of image. If the height is not yet available, this will return -1, and the observer will be notified of the dimensions later.
Returns:
height.

isLoaded

public boolean isLoaded()

setLoaded

protected void setLoaded(boolean l)
Called when the image has been loaded.

toString

public java.lang.String toString()
Generate a string that represents this object for debugging.
Returns:
the string that represents this object for debugging
Overrides:
toString in class ZVisualComponent

writeObject

public void writeObject(ZObjectOutputStream out)
                 throws java.io.IOException
Write out all of this object's state.
Parameters:
out - The stream that this object writes into
Overrides:
writeObject in class ZVisualComponent

setState

public void setState(java.lang.String fieldType,
                     java.lang.String fieldName,
                     java.lang.Object fieldValue)
Set some state of this object as it gets read back in. After the object is created with its default no-arg constructor, this method will be called on the object once for each bit of state that was written out through calls to ZObjectOutputStream.writeState() within the writeObject method.
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field
Overrides:
setState in class ZVisualComponent