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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
POLYGON
Default data field for storing polygon (float array) values.
|
static Schema |
POLYGON_SCHEMA
A Schema describing the polygon specification.
|
m_manageBounds, m_transform, RENDER_TYPE_DRAW, RENDER_TYPE_DRAW_AND_FILL, RENDER_TYPE_FILL, RENDER_TYPE_NONE
DEFAULT_GRAPHICS
Constructor and Description |
---|
PolygonRenderer()
Create a new PolygonRenderer supporting straight lines.
|
PolygonRenderer(int polyType)
Create a new PolygonRenderer.
|
Modifier and Type | Method and Description |
---|---|
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.
|
drawShape, getRenderType, getShape, getStroke, getTransform, locatePoint, render, setBounds, setManageBounds, setRenderType
public static final java.lang.String POLYGON
public static final Schema POLYGON_SCHEMA
public PolygonRenderer()
public PolygonRenderer(int polyType)
polyType
- the polygon edge type, one of
Constants.POLY_TYPE_LINE
,
Constants.POLY_TYPE_CURVE
, or
Constants.POLY_TYPE_STACK
).public int getPolyType()
Constants.POLY_TYPE_LINE
,
Constants.POLY_TYPE_CURVE
, or
Constants.POLY_TYPE_STACK
).public void setPolyType(int polyType)
polyType
- the polygon edge type, one of
Constants.POLY_TYPE_LINE
,
Constants.POLY_TYPE_CURVE
, or
Constants.POLY_TYPE_STACK
).public boolean isClosePath()
public void setClosePath(boolean closePath)
closePath
- true to close paths, false otherwise.public float getCurveSlack()
public void setCurveSlack(float slack)
slack
- the curve slack parameter to useprotected java.awt.Shape getRawShape(VisualItem item)
AbstractShapeRenderer
getRawShape
in class AbstractShapeRenderer
item
- the VisualItem being drawnAbstractShapeRenderer.getRawShape(prefuse.visual.VisualItem)
Copyright ? 2013 Regents of the University of California