Search this API

y.view
Class ImageNodePainter

java.lang.Object
  extended by y.view.AbstractCustomNodePainter
      extended by y.view.ImageNodePainter
All Implemented Interfaces:
GenericNodeRealizer.ContainsTest, GenericNodeRealizer.Painter

public class ImageNodePainter
extends AbstractCustomNodePainter
implements GenericNodeRealizer.ContainsTest

This class is an implementation of GenericNodeRealizer.Painter. The visual representation of the painted node is essentially determined by its associated image content.

 

Field Summary
protected  java.lang.Object interpolationPolicy
           
 
Constructor Summary
ImageNodePainter()
           
ImageNodePainter(java.awt.Image image)
           
ImageNodePainter(java.net.URL imageURL)
           
 
Method Summary
 boolean contains(NodeRealizer context, double x, double y)
          Used as a callback for the GenericNodeRealizer.contains(double, double) method.
 java.awt.Image getImage()
          Returns the image that is displayed by this realizer.
 java.net.URL getImageURL()
          Returns the URL of the displayed image, or null if no URL is associated with this painter.
 java.lang.Object getInterpolationPolicy()
          Returns the interpolation policy that is used when painting the node image.
protected  void paintNode(NodeRealizer context, java.awt.Graphics2D graphics, boolean sloppy)
          Callback method to be overwritten by subclasses called by AbstractCustomNodePainter.paint(NodeRealizer, Graphics2D).
 void setAlphaImageUsed(boolean use)
          Determines whether the contains(NodeRealizer,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 painter.
 void setImageURL(java.net.URL imageURL)
          Sets the URL of the image that will be displayed by this painter.
 void setInterpolationPolicy(java.lang.Object interpolationPolicy)
          Sets the interpolation policy that is used when painting the node image.
 
Methods inherited from class y.view.AbstractCustomNodePainter
backupGraphics, createSelectionColor, getFillColor, getFillColor2, getFillPaint, getLineColor, getLinePaint, getLineStroke, initializeFill, initializeLine, paint, paintHotSpots, paintPorts, paintSloppy, paintText, restoreGraphics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interpolationPolicy

protected java.lang.Object interpolationPolicy
Constructor Detail

ImageNodePainter

public ImageNodePainter()

ImageNodePainter

public ImageNodePainter(java.net.URL imageURL)

ImageNodePainter

public ImageNodePainter(java.awt.Image image)
Method Detail

paintNode

protected void paintNode(NodeRealizer context,
                         java.awt.Graphics2D graphics,
                         boolean sloppy)
Description copied from class: AbstractCustomNodePainter
Callback method to be overwritten by subclasses called by AbstractCustomNodePainter.paint(NodeRealizer, Graphics2D). This method is responsible for drawing the actual node only - neither the hotspots, nor the labels, should be painted by this method.

Specified by:
paintNode in class AbstractCustomNodePainter
Parameters:
context - the context node
graphics - the graphics context to use
sloppy - whether to draw the node sloppily
See Also:
AbstractCustomNodePainter.initializeLine(NodeRealizer, Graphics2D), AbstractCustomNodePainter.initializeFill(NodeRealizer, Graphics2D)

setImageURL

public void setImageURL(java.net.URL imageURL)
Sets the URL of the image that will be displayed by this painter.

Parameters:
imageURL - the url fof the image that is to be set.

getImageURL

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

Returns:
the url of the currently set image.

setImage

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

Parameters:
image - the image that is to be set for this painter.

getImage

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

Returns:
the image that is displayed by this realizer.

getInterpolationPolicy

public java.lang.Object getInterpolationPolicy()
Returns the interpolation policy that is used when painting the node image. By default no policy is explicitly set.

Returns:
the interpolation policy that is used when painting the node image or null, if none has been explicitly set.

setInterpolationPolicy

public void setInterpolationPolicy(java.lang.Object interpolationPolicy)
Sets the interpolation policy that is used when painting the node image. By default no policy is explicitly set.

Parameters:
interpolationPolicy - One of RenderingHints.VALUE_INTERPOLATION_BICUBIC, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR

contains

public boolean contains(NodeRealizer context,
                        double x,
                        double y)
Description copied from interface: GenericNodeRealizer.ContainsTest
Used as a callback for the GenericNodeRealizer.contains(double, double) method.

Specified by:
contains in interface GenericNodeRealizer.ContainsTest

setAlphaImageUsed

public void setAlphaImageUsed(boolean use)
Determines whether the contains(NodeRealizer,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

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