prefuse.render
Class PolygonRenderer

java.lang.Object
  extended by prefuse.render.AbstractShapeRenderer
      extended by prefuse.render.PolygonRenderer
All Implemented Interfaces:
Renderer

public class PolygonRenderer
extends AbstractShapeRenderer

Renderer for drawing a polygon, either as a closed shape, or as a series of potentially unclosed curves. VisualItems must have a data field containing an array of floats that tores the polyon. A Float.NaN value can be used to mark the end point of the polygon for float arrays larger than their contained points. By default, this renderer will create closed paths, joining the first and last points in the point array if necessary. The setClosePath(boolean) method can be used to render open paths, such as poly-lines or poly-curves.

A polygon edge type parameter (one of Constants.POLY_TYPE_LINE, Constants.POLY_TYPE_CURVE, or Constants.POLY_TYPE_STACK) determines how the edges of the polygon are drawn. The LINE type result in a standard polygon, with straight lines drawn between each sequential point. The CURVE type causes the edges of the polygon to be interpolated as a cardinal spline, giving a smooth blob-like appearance to the shape. The STACK type is similar to the curve type except that straight line segments (not curves) are used when the slope of the line between two adjacent points is zero or infinity. This is useful for drawing stacks of data with otherwise curved edges.

Author:
jeffrey heer

Field Summary
static java.lang.String POLYGON
          Default data field for storing polygon (float array) values.
static Schema POLYGON_SCHEMA
          A Schema describing the polygon specification.
 
Fields inherited from class prefuse.render.AbstractShapeRenderer
m_manageBounds, m_transform, RENDER_TYPE_DRAW, RENDER_TYPE_DRAW_AND_FILL, RENDER_TYPE_FILL, RENDER_TYPE_NONE
 
Fields inherited from interface prefuse.render.Renderer
DEFAULT_GRAPHICS
 
Constructor Summary
PolygonRenderer()
          Create a new PolygonRenderer supporting straight lines.
PolygonRenderer(int polyType)
          Create a new PolygonRenderer.
 
Method Summary
 float getCurveSlack()
          Gets the slack parameter for curved lines.
 int getPolyType()
          Get the polygon line type.
protected  java.awt.Shape getRawShape(VisualItem item)
          Return a non-transformed shape for the visual representation of the item.
 boolean isClosePath()
          Indicates if this renderer uses a closed or open path.
 void setClosePath(boolean closePath)
          Sets if this renderer uses a closed or open path.
 void setCurveSlack(float slack)
          Sets the slack parameter for curved lines.
 void setPolyType(int polyType)
          Set the polygon line type.
 
Methods inherited from class prefuse.render.AbstractShapeRenderer
drawShape, getRenderType, getShape, getStroke, getTransform, locatePoint, render, setBounds, setManageBounds, setRenderType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLYGON

public static final java.lang.String POLYGON
Default data field for storing polygon (float array) values.

See Also:
Constant Field Values

POLYGON_SCHEMA

public static final Schema POLYGON_SCHEMA
A Schema describing the polygon specification.

Constructor Detail

PolygonRenderer

public PolygonRenderer()
Create a new PolygonRenderer supporting straight lines.


PolygonRenderer

public PolygonRenderer(int polyType)
Create a new PolygonRenderer.

Parameters:
polyType - the polygon edge type, one of Constants.POLY_TYPE_LINE, Constants.POLY_TYPE_CURVE, or Constants.POLY_TYPE_STACK).
Method Detail

getPolyType

public int getPolyType()
Get the polygon line type.

Returns:
the polygon edge type, one of Constants.POLY_TYPE_LINE, Constants.POLY_TYPE_CURVE, or Constants.POLY_TYPE_STACK).

setPolyType

public void setPolyType(int polyType)
Set the polygon line type.

Parameters:
polyType - the polygon edge type, one of Constants.POLY_TYPE_LINE, Constants.POLY_TYPE_CURVE, or Constants.POLY_TYPE_STACK).

isClosePath

public boolean isClosePath()
Indicates if this renderer uses a closed or open path. If true, the renderer will draw closed polygons, if false, the renderer will draw poly-lines or poly-curves.

Returns:
true if paths are closed, false otherwise.

setClosePath

public void setClosePath(boolean closePath)
Sets if this renderer uses a closed or open path. If true, the renderer will draw closed polygons, if false, the renderer will

Parameters:
closePath - true to close paths, false otherwise.

getCurveSlack

public float getCurveSlack()
Gets the slack parameter for curved lines. The slack parameter determines how tightly the curves are string between the points of the polygon. A value of zero results in straight lines. Values near 0.1 (0.08 is the default) typically result in visible curvature that still follows the polygon boundary nicely.

Returns:
the curve slack parameter

setCurveSlack

public void setCurveSlack(float slack)
Sets the slack parameter for curved lines. The slack parameter determines how tightly the curves are string between the points of the polygon. A value of zero results in straight lines. Values near 0.1 (0.08 is the default) typically results in visible curvature that still follows the polygon boundary nicely.

Parameters:
slack - the curve slack parameter to use

getRawShape

protected java.awt.Shape getRawShape(VisualItem item)
Description copied from class: AbstractShapeRenderer
Return a non-transformed shape for the visual representation of the item. Subclasses must implement this method.

Specified by:
getRawShape in class AbstractShapeRenderer
Parameters:
item - the VisualItem being drawn
Returns:
the "raw", untransformed shape.
See Also:
AbstractShapeRenderer.getRawShape(prefuse.visual.VisualItem)


Copyright © 2007 Regents of the University of California