|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprefuse.render.AbstractShapeRenderer
public abstract class AbstractShapeRenderer
Abstract base class implementation of the Renderer interface for
supporting the drawing of basic shapes. Subclasses should override the
getRawShape
method,
which returns the shape to draw. Optionally, subclasses can also override the
getTransform
method to apply a desired
AffineTransform
to the shape.
NOTE: For more efficient rendering, subclasses should use a single shape instance in memory, and update its parameters on each call to getRawShape, rather than allocating a new Shape object each time. Otherwise, a new object will be allocated every time something needs to be drawn, and then subsequently be garbage collected. This can significantly reduce performance, especially when there are many things to draw.
Field Summary | |
---|---|
protected boolean |
m_manageBounds
|
protected java.awt.geom.AffineTransform |
m_transform
|
Fields inherited from interface prefuse.render.Renderer |
---|
DEFAULT_GRAPHICS |
Constructor Summary | |
---|---|
AbstractShapeRenderer()
|
Method Summary | |
---|---|
void |
calculateBounds(VisualItem<?> item,
java.awt.geom.Rectangle2D bounds)
Calculates the bounding rectangle for an item. |
protected void |
drawShape(java.awt.Graphics2D g,
VisualItem<?> item,
java.awt.Shape shape)
Draws the specified shape into the provided Graphics context. |
protected java.awt.Color |
getFillColor(VisualItem<?> item)
Returns the fill color to use for painting shapes. |
protected abstract java.awt.Shape |
getRawShape(VisualItem<?> item)
Return a non-transformed shape for the visual representation of the item. |
RenderType |
getRenderType(VisualItem<?> item)
Returns a value indicating if a shape is drawn by its outline, by a fill, or both. |
java.awt.Shape |
getShape(VisualItem<?> item)
Returns the shape describing the boundary of an item. |
protected java.awt.BasicStroke |
getStroke(VisualItem<?> item)
Returns the stroke to use for drawing lines and shape outlines. |
protected java.awt.Color |
getStrokeColor(VisualItem<?> item)
Returns the stroke color to use for drawing lines and shape outlines. |
protected java.awt.geom.AffineTransform |
getTransform(VisualItem<?> item)
Return the graphics space transform applied to this item's shape, if any. |
boolean |
locatePoint(java.awt.geom.Point2D p,
VisualItem<?> item)
Returns true if the Point is located inside the extents of the item. |
boolean |
managesBounds()
|
void |
render(java.awt.Graphics2D g,
VisualItem<?> item)
Render item into a Graphics2D context. |
void |
setManageBounds(boolean b)
|
void |
setRenderType(RenderType type)
Sets a value indicating if a shape is drawn by its outline, by a fill, or both. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.geom.AffineTransform m_transform
protected boolean m_manageBounds
Constructor Detail |
---|
public AbstractShapeRenderer()
Method Detail |
---|
public void setManageBounds(boolean b)
public boolean managesBounds()
managesBounds
in interface Renderer
public void render(java.awt.Graphics2D g, VisualItem<?> item)
Renderer
render
in interface Renderer
g
- the Graphics2D contextitem
- the visual item to drawRenderer.render(java.awt.Graphics2D, prefuse.visual.VisualItem)
protected void drawShape(java.awt.Graphics2D g, VisualItem<?> item, java.awt.Shape shape)
public java.awt.Shape getShape(VisualItem<?> item)
item
- the item for which to get the Shapeprotected java.awt.Color getStrokeColor(VisualItem<?> item)
VisualItem.getStrokeColor()
.
Subclasses can override this method to implement custom stroke color
assignment, though changing the VisualItem
's stroke color
value is preferred.
item
- the VisualItem
protected java.awt.Color getFillColor(VisualItem<?> item)
VisualItem.getFillColor()
.
Subclasses can override this method to implement custom fill color
assignment, though changing the VisualItem
's fill color
value is preferred.
item
- the VisualItem
protected java.awt.BasicStroke getStroke(VisualItem<?> item)
VisualItem.getStroke()
.
Subclasses can override this method to implement custom stroke
assignment, though changing the VisualItem
's stroke
value is preferred.
item
- the VisualItem
protected abstract java.awt.Shape getRawShape(VisualItem<?> item)
item
- the VisualItem being drawn
protected java.awt.geom.AffineTransform getTransform(VisualItem<?> item)
item
- the VisualItem
public RenderType getRenderType(VisualItem<?> item)
public void setRenderType(RenderType type)
type
- the new rendering typepublic boolean locatePoint(java.awt.geom.Point2D p, VisualItem<?> item)
Renderer
locatePoint
in interface Renderer
p
- the point to test for containmentitem
- the item to test containment against
Renderer.locatePoint(java.awt.geom.Point2D, prefuse.visual.VisualItem)
public void calculateBounds(VisualItem<?> item, java.awt.geom.Rectangle2D bounds)
Renderer
calculateBounds
in interface Renderer
item
- the item to compute the bounding box forbounds
- the rectangle to populate with the bounding box
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |