KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > render > Renderer


1 package prefuse.render;
2
3 import java.awt.Graphics2D JavaDoc;
4 import java.awt.geom.Point2D JavaDoc;
5 import java.awt.image.BufferedImage JavaDoc;
6
7 import prefuse.visual.VisualItem;
8
9
10 /**
11  * Interface for rendering VisualItems, providing drawing as well as location
12  * checking and bounding box routines.
13  *
14  * @author <a HREF="http://jheer.org">jeffrey heer</a>
15  * @author alan newberger
16  */

17 public interface Renderer {
18
19     /**
20      * Provides a default graphics context for renderers to do useful
21      * things like compute string widths when an external graphics context
22      * has not yet been provided.
23      */

24     public static final Graphics2D JavaDoc DEFAULT_GRAPHICS = (Graphics2D JavaDoc)
25         new BufferedImage JavaDoc(1, 1, BufferedImage.TYPE_INT_ARGB).getGraphics();
26
27     /**
28      * Render item into a Graphics2D context.
29      * @param g the Graphics2D context
30      * @param item the visual item to draw
31      */

32     public void render(Graphics2D JavaDoc g, VisualItem item);
33
34     /**
35      * Returns true if the Point is located inside the extents of the item.
36      * This calculation matches against the exaxt item shape, and so is more
37      * sensitive than just checking within a bounding box.
38      * @param p the point to test for containment
39      * @param item the item to test containment against
40      * @return true if the point is contained within the the item, else false
41      */

42     public boolean locatePoint(Point2D JavaDoc p, VisualItem item);
43
44     /**
45      * Calculates and sets the bounding rectangle for an item. This is called
46      * by a VisualItem when it validates its bounds.
47      * @param item the item to compute the bounding box for
48      */

49     public void setBounds(VisualItem item);
50
51 } // end of interface Renderer
52
Popular Tags