y.view
Class ImageNodeRealizer

java.lang.Object
  |
  +--y.view.NodeRealizer
        |
        +--y.view.ImageNodeRealizer
All Implemented Interfaces:
NodeLayout

public class ImageNodeRealizer
extends NodeRealizer

A node realizer that displays a node as an image.


Field Summary
 
Fields inherited from class y.view.NodeRealizer
height, HOTSPOT_E, HOTSPOT_N, HOTSPOT_NE, HOTSPOT_NONE, HOTSPOT_NW, HOTSPOT_S, HOTSPOT_SE, HOTSPOT_SW, HOTSPOT_W, width, x, y
 
Constructor Summary
ImageNodeRealizer()
          Creates a new ImageNodeRealizer with no image associated with it.
ImageNodeRealizer(NodeRealizer argNodeRealizer)
          Creates a new ImageNodeRealizer whose attributes are copied from the given realizer.
 
Method Summary
static Image addImage(URL imageURL)
          Adds an image Object to ImageNodeRealizer's image cache.
static void addImages(String userHomeRes, String classPathRes)
          Adds images that are specified in a property file.
static void addImages(URL url)
          Adds images that are specified in a property file parsable by class java.util.PropertyResourceBundle An example of such a file follows: basepath=imagenodes image1=flower.gif image2=trousers.gif image3=pike.gif The optional key "basepath" signifies a path that is prepended to all given image values. if "basepath' signifies an absolute path then the given url is not prepended to basepath.
static Vector availableImageURLs()
          Returns a vector of all URL objects, that have are used as keys to ImageNodeRealizer's image cache.
 NodeRealizer createCopy(NodeRealizer nr)
          Creates and returns a new ImageNodeRealizer whose attributes are copied from the given realizer.
 Image getImage()
          Returns the image that is displayed by this realizer.
static Image getImage(URL url)
          Returns the image that is stored under the given URL in ImageNodeRealizer's image cache, or null if there is no image registered with that URL.
static Hashtable getImageTable()
          Returns ImageNodeRealizer's image cache. the keys to the cached Image objects are their URLs.
 URL getImageURL()
          Returns the URL of the displayed image, or null if no URL is associated with this realizer.
 void paintNode(Graphics2D g)
          This method must be implemented by subclasses.
 void read(ObjectInputStream in)
          Reads in the serialized form of this realizer.
 void setImage(Image image)
          Sets the image that will be displayed by this realizer.
 void setImageURL(URL imageURL)
          Sets the URL of the image that will be displayed by this realizer.
 void setToImageSize()
          Sets the size of this realizer to the original size of the image being displayed.
 void write(ObjectOutputStream out)
          Writes out this realizer in a serialized form.
 
Methods inherited from class y.view.NodeRealizer
addLabel, calcUnionRect, calcUnionRect, contains, createCopy, createNodeLabel, findBBIntersection, findIntersection, getBoundingBox, getCenterX, getCenterY, getFillColor, getFillColor2, getHeight, getHotSpotColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getNode, getPortCandidates, getSloppySelectionColor, getWidth, getX, getY, hotSpotHit, intersects, isInBox, isSelected, isTransparent, isVisible, labelCount, moveBy, paint, paintHotSpots, paintLayer, paintLayerSloppy, paintSloppy, paintText, removeLabel, setCenter, setCenterX, setCenterY, setEdgesDirty, setFillColor, setFillColor2, setFrame, setFrame, setHeight, setHotSpotColor, setLabel, setLabelText, setLayer, setLayer, setLineColor, setLineType, setLocation, setSelected, setSize, setSloppySelectionColor, setTransparent, setVisible, setWidth, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageNodeRealizer

public ImageNodeRealizer()
Creates a new ImageNodeRealizer with no image associated with it.


ImageNodeRealizer

public ImageNodeRealizer(NodeRealizer argNodeRealizer)
Creates a new ImageNodeRealizer whose attributes are copied from the given realizer.

Method Detail

createCopy

public NodeRealizer createCopy(NodeRealizer nr)
Creates and returns a new ImageNodeRealizer whose attributes are copied from the given realizer.

Specified by:
createCopy in class NodeRealizer

addImages

public static void addImages(String userHomeRes,
                             String classPathRes)
Adds images that are specified in a property file.

Parameters:
userHomeRes - A user home relative path to the property file. If this file is not found then ...
classPathRes - ... a classpath relative path to the property file will be tried instead.
See Also:
ImageNodeRealizer.addImages(URL)

addImages

public static void addImages(URL url)
Adds images that are specified in a property file parsable by class java.util.PropertyResourceBundle

An example of such a file follows:

   basepath=imagenodes
   image1=flower.gif
   image2=trousers.gif
   image3=pike.gif
 
The optional key "basepath" signifies a path that is prepended to all given image values. if "basepath' signifies an absolute path then the given url is not prepended to basepath.

Parameters:
url - the url of the properties file.

addImage

public static Image addImage(URL imageURL)
Adds an image Object to ImageNodeRealizer's image cache. The image will be loaded and accessed via the given URL.


availableImageURLs

public static Vector availableImageURLs()
Returns a vector of all URL objects, that have are used as keys to ImageNodeRealizer's image cache.


getImageTable

public static Hashtable getImageTable()
Returns ImageNodeRealizer's image cache. the keys to the cached Image objects are their URLs.


getImage

public static Image getImage(URL url)
Returns the image that is stored under the given URL in ImageNodeRealizer's image cache, or null if there is no image registered with that URL.


setImageURL

public void setImageURL(URL imageURL)
Sets the URL of the image that will be displayed by this realizer. The given URL must point to a GIF or JPG image.

The image will be automatically entered in ImageNodeRealizer's static image cache under the given URL.


setImage

public void setImage(Image image)
Sets the image that will be displayed by this realizer. By setting the image directly, the associated image URL will be reset to null.


getImage

public Image getImage()
Returns the image that is displayed by this realizer.


getImageURL

public URL getImageURL()
Returns the URL of the displayed image, or null if no URL is associated with this realizer.


setToImageSize

public void setToImageSize()
Sets the size of this realizer to the original size of the image being displayed.


paintNode

public void paintNode(Graphics2D g)
Description copied from class: NodeRealizer
This method must be implemented by subclasses. It defines in wich way the realizer paints itself on a graphics context.

Specified by:
paintNode in class NodeRealizer

write

public void write(ObjectOutputStream out)
           throws IOException
Writes out this realizer in a serialized form.

Overrides:
write in class NodeRealizer
IOException

read

public void read(ObjectInputStream in)
          throws IOException,
                 ClassNotFoundException
Reads in the serialized form of this realizer. The realizer must have been written out before by it's ImageNodeRealizer.write(ObjectOutputStream) method.

Overrides:
read in class NodeRealizer
IOException
ClassNotFoundException

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003