Search this API

y.view
Class ImageNodeRealizer

java.lang.Object
  extended by y.view.NodeRealizer
      extended by y.view.ImageNodeRealizer
All Implemented Interfaces:
NodeLayout

public class ImageNodeRealizer
extends NodeRealizer

A node realizer that displays a node as an image.

The visual representation of a ImageNodeRealizer is essentially determined by its associated image content. As a consequence, the implementation of paintNode(java.awt.Graphics2D) ignores the following properties:

Attention: Using the ygf writing capabilities of this class is not thread-safe!

 

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 java.awt.Image addImage(java.net.URL imageURL)
          Adds an image Object to ImageNodeRealizer's image cache.
static void addImages(java.lang.String userHomeRes, java.lang.String classPathRes)
          Adds images that are specified in a property file.
static void addImages(java.net.URL url)
          Adds images that are specified in a property file that can be parsed 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 java.util.Vector availableImageURLs()
          Returns a vector of all URL objects, that have are used as keys to ImageNodeRealizer's image cache.
 boolean contains(double x, double y)
          Determines whether the specified point lies inside this realizer
 NodeRealizer createCopy(NodeRealizer nr)
          Creates and returns a new ImageNodeRealizer whose attributes are copied from the given realizer.
 java.awt.Image getImage()
          Returns the image that is displayed by this realizer.
static java.awt.Image getImage(java.net.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 java.util.Hashtable getImageTable()
          Returns ImageNodeRealizer's image cache. the keys to the cached Image objects are their URLs.
 java.net.URL getImageURL()
          Returns the URL of the displayed image, or null if no URL is associated with this realizer.
 boolean isAlphaImageUsed()
          Returns whether the contains(double, double) method uses the alpha transparency of the image to determine whether this realizer "contains" points.
 void paintNode(java.awt.Graphics2D g)
          This method must be implemented by subclasses.
 void read(java.io.ObjectInputStream in)
          Deprecated. Use the GraphML format instead.
 void setAlphaImageUsed(boolean use)
          Determines whether the contains(double, double) method should use the alpha transparency of the image to determine whether this realizer "contains" points.
 void setImage(java.awt.Image image)
          Sets the image that will be displayed by this realizer.
 void setImageURL(java.net.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(java.io.ObjectOutputStream out)
          Deprecated. Use the GraphML format instead.
 
Methods inherited from class y.view.NodeRealizer
addLabel, addPort, boundsChanged, calcUnionRect, calcUnionRect, calcUnionRectImpl, calcUnionRectLabels, calcUnionRectPorts, createCopy, createNodeLabel, findBBIntersection, findIntersection, getAutoBoundsFeature, getBoundingBox, getCenterX, getCenterY, getFillColor, getFillColor2, getHeight, getHotSpotColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getMouseInputEditorProvider, getNode, getPort, getPortCandidates, getSizeConstraintProvider, getSloppySelectionColor, getWidth, getX, getY, hotSpotHit, intersects, invalidatePortPositions, isInBox, isSelected, isTransparent, isVisible, labelBoundsChanged, labelCount, moveBy, paint, paintHotSpots, paintLayer, paintLayerSloppy, paintPorts, paintSloppy, paintText, portCount, removeLabel, removeLabel, removePort, removePort, repaint, 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

contains

public boolean contains(double x,
                        double y)
Determines whether the specified point lies inside this realizer

Overrides:
contains in class NodeRealizer
Parameters:
x - the x-coordinate of the point to check.
y - the y-coordinate of the point to check.
Returns:
true if the bounding box of this realizer contains the specified point; false otherwise.
See Also:
setAlphaImageUsed(boolean)

setAlphaImageUsed

public void setAlphaImageUsed(boolean use)
Determines whether the contains(double, double) method should use the alpha transparency of the image to determine whether this realizer "contains" points. This influences hit testing and edge intersection calculation

Parameters:
use - whether to use the Alpha Transparency of the image

isAlphaImageUsed

public boolean isAlphaImageUsed()
Returns whether the contains(double, double) method uses the alpha transparency of the image to determine whether this realizer "contains" points. This influences hit testing and edge intersection calculation

Returns:
whether to use the Alpha Transparency of the image

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
Parameters:
nr - the prototype realizer whose attributes will be copied.

addImages

public static void addImages(java.lang.String userHomeRes,
                             java.lang.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:
addImages(URL)

addImages

public static void addImages(java.net.URL url)
Adds images that are specified in a property file that can be parsed 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 java.awt.Image addImage(java.net.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 java.util.Vector availableImageURLs()
Returns a vector of all URL objects, that have are used as keys to ImageNodeRealizer's image cache.


getImageTable

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


getImage

public static java.awt.Image getImage(java.net.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(java.net.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(java.awt.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 java.awt.Image getImage()
Returns the image that is displayed by this realizer.


getImageURL

public java.net.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. If the image is null this method returns silently.


paintNode

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

Specified by:
paintNode in class NodeRealizer

write

public void write(java.io.ObjectOutputStream out)
           throws java.io.IOException
Deprecated. Use the GraphML format instead.

Writes out this realizer in a serialized form.

Overrides:
write in class NodeRealizer
Throws:
java.io.IOException

read

public void read(java.io.ObjectInputStream in)
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
Deprecated. Use the GraphML format instead.

Reads in the serialized form of this realizer. The realizer must have been written out before by it's write(ObjectOutputStream) method.

Overrides:
read in class NodeRealizer
Throws:
java.io.IOException
java.lang.ClassNotFoundException

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