01: package prefuse.render;
02:
03: import java.awt.Graphics2D;
04: import java.awt.geom.Point2D;
05: import java.awt.image.BufferedImage;
06:
07: import prefuse.visual.VisualItem;
08:
09: /**
10: * Interface for rendering VisualItems, providing drawing as well as location
11: * checking and bounding box routines.
12: *
13: * @author <a href="http://jheer.org">jeffrey heer</a>
14: * @author alan newberger
15: */
16: public interface Renderer {
17:
18: /**
19: * Provides a default graphics context for renderers to do useful
20: * things like compute string widths when an external graphics context
21: * has not yet been provided.
22: */
23: public static final Graphics2D DEFAULT_GRAPHICS = (Graphics2D) new BufferedImage(
24: 1, 1, BufferedImage.TYPE_INT_ARGB).getGraphics();
25:
26: /**
27: * Render item into a Graphics2D context.
28: * @param g the Graphics2D context
29: * @param item the visual item to draw
30: */
31: public void render(Graphics2D g, VisualItem item);
32:
33: /**
34: * Returns true if the Point is located inside the extents of the item.
35: * This calculation matches against the exaxt item shape, and so is more
36: * sensitive than just checking within a bounding box.
37: * @param p the point to test for containment
38: * @param item the item to test containment against
39: * @return true if the point is contained within the the item, else false
40: */
41: public boolean locatePoint(Point2D p, VisualItem item);
42:
43: /**
44: * Calculates and sets the bounding rectangle for an item. This is called
45: * by a VisualItem when it validates its bounds.
46: * @param item the item to compute the bounding box for
47: */
48: public void setBounds(VisualItem item);
49:
50: } // end of interface Renderer
|