|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.render.AbstractShapeRenderer prefuse.render.EdgeRenderer
public class EdgeRenderer
Renderer that draws edges as lines connecting nodes. Both
straight and curved lines are supported. Curved lines are drawn using
cubic Bezier curves. Subclasses can override the
getCurveControlPoints(EdgeItem, Point2D[], double, double, double, double)
method to provide custom control point assignment for such curves.
This class also supports arrows for directed edges. See the
setArrowType(int)
method for more.
Field Summary | |
---|---|
static java.lang.String |
EDGE_TYPE
|
protected static double |
HALF_PI
|
protected java.awt.Polygon |
m_arrowHead
|
protected int |
m_arrowHeight
|
protected java.awt.geom.AffineTransform |
m_arrowTrans
|
protected int |
m_arrowWidth
|
protected java.awt.geom.Point2D[] |
m_ctrlPoints
|
protected java.awt.geom.CubicCurve2D |
m_cubic
|
protected java.awt.Shape |
m_curArrow
|
protected float |
m_curWidth
|
protected int |
m_edgeArrow
|
protected int |
m_edgeType
|
protected java.awt.geom.Point2D[] |
m_isctPoints
|
protected java.awt.geom.Line2D |
m_line
|
protected java.awt.geom.Point2D[] |
m_tmpPoints
|
protected double |
m_width
|
protected int |
m_xAlign1
|
protected int |
m_xAlign2
|
protected int |
m_yAlign1
|
protected int |
m_yAlign2
|
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 | |
---|---|
EdgeRenderer()
Create a new EdgeRenderer. |
|
EdgeRenderer(int edgeType)
Create a new EdgeRenderer with the given edge type. |
|
EdgeRenderer(int edgeType,
int arrowType)
Create a new EdgeRenderer with the given edge and arrow types. |
Method Summary | |
---|---|
protected static void |
getAlignedPoint(java.awt.geom.Point2D p,
java.awt.geom.Rectangle2D r,
int xAlign,
int yAlign)
Helper method, which calculates the top-left co-ordinate of a rectangle given the rectangle's alignment. |
int |
getArrowHeadHeight()
Get the height of the untransformed arrow head. |
int |
getArrowHeadWidth()
Get the width of the untransformed arrow head. |
protected java.awt.geom.AffineTransform |
getArrowTrans(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2,
double width)
Returns an affine transformation that maps the arrowhead shape to the position and orientation specified by the provided line segment end points. |
int |
getArrowType()
Returns the type of the drawn edge. |
protected void |
getCurveControlPoints(EdgeItem eitem,
java.awt.geom.Point2D[] cp,
double x1,
double y1,
double x2,
double y2)
Determines the control points to use for cubic (Bezier) curve edges. |
double |
getDefaultLineWidth()
Gets the default width of lines. |
int |
getEdgeType()
Returns the type of the drawn edge. |
int |
getHorizontalAlignment1()
Get the horizontal aligment of the edge mount point with the first node. |
int |
getHorizontalAlignment2()
Get the horizontal aligment of the edge mount point with the second node. |
protected double |
getLineWidth(VisualItem item)
Returns the line width to be used for this VisualItem. |
protected java.awt.Shape |
getRawShape(VisualItem item)
Return a non-transformed shape for the visual representation of the item. |
int |
getRenderType(VisualItem item)
Returns a value indicating if a shape is drawn by its outline, by a fill, or both. |
protected java.awt.BasicStroke |
getStroke(VisualItem item)
Returns the stroke value returned by VisualItem.getStroke() ,
scaled by the current line width
determined by the getLineWidth(VisualItem) method. |
protected java.awt.geom.AffineTransform |
getTransform(VisualItem item)
Return the graphics space transform applied to this item's shape, if any. |
int |
getVerticalAlignment1()
Get the vertical aligment of the edge mount point with the first node. |
int |
getVerticalAlignment2()
Get the vertical aligment of the edge mount point with the second node. |
boolean |
locatePoint(java.awt.geom.Point2D p,
VisualItem item)
Returns true if the Point is located inside the extents of the item. |
void |
render(java.awt.Graphics2D g,
VisualItem item)
Render item into a Graphics2D context. |
void |
setArrowHeadSize(int width,
int height)
Sets the dimensions of an arrow head for a directed edge. |
void |
setArrowType(int type)
Sets the type of the drawn edge. |
void |
setBounds(VisualItem item)
Calculates and sets the bounding rectangle for an item. |
void |
setDefaultLineWidth(double w)
Sets the default width of lines. |
void |
setEdgeType(int type)
Sets the type of the drawn edge. |
void |
setHorizontalAlignment1(int align)
Set the horizontal aligment of the edge mount point with the first node. |
void |
setHorizontalAlignment2(int align)
Set the horizontal aligment of the edge mount point with the second node. |
void |
setVerticalAlignment1(int align)
Set the vertical aligment of the edge mount point with the first node. |
void |
setVerticalAlignment2(int align)
Set the vertical aligment of the edge mount point with the second node. |
protected java.awt.Polygon |
updateArrowHead(int w,
int h)
Update the dimensions of the arrow head, creating a new arrow head if necessary. |
Methods inherited from class prefuse.render.AbstractShapeRenderer |
---|
drawShape, getShape, setManageBounds, setRenderType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String EDGE_TYPE
protected static final double HALF_PI
protected java.awt.geom.Line2D m_line
protected java.awt.geom.CubicCurve2D m_cubic
protected int m_edgeType
protected int m_xAlign1
protected int m_yAlign1
protected int m_xAlign2
protected int m_yAlign2
protected double m_width
protected float m_curWidth
protected java.awt.geom.Point2D[] m_tmpPoints
protected java.awt.geom.Point2D[] m_ctrlPoints
protected java.awt.geom.Point2D[] m_isctPoints
protected int m_edgeArrow
protected int m_arrowWidth
protected int m_arrowHeight
protected java.awt.Polygon m_arrowHead
protected java.awt.geom.AffineTransform m_arrowTrans
protected java.awt.Shape m_curArrow
Constructor Detail |
---|
public EdgeRenderer()
public EdgeRenderer(int edgeType)
edgeType
- the edge type, one of
Constants.EDGE_TYPE_LINE
or
Constants.EDGE_TYPE_CURVE
.public EdgeRenderer(int edgeType, int arrowType)
edgeType
- the edge type, one of
Constants.EDGE_TYPE_LINE
or
Constants.EDGE_TYPE_CURVE
.arrowType
- the arrow type, one of
Constants.EDGE_ARROW_FORWARD
,
Constants.EDGE_ARROW_REVERSE
, or
Constants.EDGE_ARROW_NONE
.setArrowType(int)
Method Detail |
---|
public int getRenderType(VisualItem item)
AbstractShapeRenderer
getRenderType
in class AbstractShapeRenderer
AbstractShapeRenderer.getRenderType(prefuse.visual.VisualItem)
protected java.awt.Shape getRawShape(VisualItem item)
AbstractShapeRenderer
getRawShape
in class AbstractShapeRenderer
item
- the VisualItem being drawn
AbstractShapeRenderer.getRawShape(prefuse.visual.VisualItem)
public void render(java.awt.Graphics2D g, VisualItem item)
Renderer
render
in interface Renderer
render
in class AbstractShapeRenderer
g
- the Graphics2D contextitem
- the visual item to drawRenderer.render(java.awt.Graphics2D, prefuse.visual.VisualItem)
protected java.awt.geom.AffineTransform getArrowTrans(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, double width)
protected java.awt.Polygon updateArrowHead(int w, int h)
m_arrowHead
w
- the width of the untransformed arrow head base, in pixelsh
- the height of the untransformed arrow head, in pixels
protected java.awt.geom.AffineTransform getTransform(VisualItem item)
AbstractShapeRenderer
getTransform
in class AbstractShapeRenderer
item
- the VisualItem
AbstractShapeRenderer.getTransform(prefuse.visual.VisualItem)
public boolean locatePoint(java.awt.geom.Point2D p, VisualItem item)
Renderer
locatePoint
in interface Renderer
locatePoint
in class AbstractShapeRenderer
p
- the point to test for containmentitem
- the item to test containment against
Renderer.locatePoint(java.awt.geom.Point2D, prefuse.visual.VisualItem)
public void setBounds(VisualItem item)
Renderer
setBounds
in interface Renderer
setBounds
in class AbstractShapeRenderer
item
- the item to compute the bounding box forRenderer.setBounds(prefuse.visual.VisualItem)
protected double getLineWidth(VisualItem item)
setDefaultLineWidth(double)
method, scaled by the item size returned by
VisualItem.getSize()
. Subclasses can override this method to
perform custom line width determination, however, the preferred
method is to change the item size value itself.
item
- the VisualItem for which to determine the line width
protected java.awt.BasicStroke getStroke(VisualItem item)
VisualItem.getStroke()
,
scaled by the current line width
determined by the getLineWidth(VisualItem)
method. Subclasses
may override this method to perform custom stroke assignment, but should
respect the line width paremeter stored in the m_curWidth
member variable, which caches the result of getLineWidth
.
getStroke
in class AbstractShapeRenderer
item
- the VisualItem
AbstractShapeRenderer.getStroke(prefuse.visual.VisualItem)
protected void getCurveControlPoints(EdgeItem eitem, java.awt.geom.Point2D[] cp, double x1, double y1, double x2, double y2)
eitem
- the EdgeItem we are determining the control points forcp
- array of Point2D's (length >= 2) in which to return the control pointsx1
- the x co-ordinate of the first node this edge connects toy1
- the y co-ordinate of the first node this edge connects tox2
- the x co-ordinate of the second node this edge connects toy2
- the y co-ordinate of the second node this edge connects toprotected static void getAlignedPoint(java.awt.geom.Point2D p, java.awt.geom.Rectangle2D r, int xAlign, int yAlign)
public int getEdgeType()
Constants.EDGE_TYPE_LINE
or
Constants.EDGE_TYPE_CURVE
.
public void setEdgeType(int type)
Constants.EDGE_TYPE_LINE
or
Constants.EDGE_TYPE_CURVE
.
type
- the new edge typepublic int getArrowType()
Constants.EDGE_ARROW_FORWARD
,
Constants.EDGE_ARROW_REVERSE
, or
Constants.EDGE_ARROW_NONE
.
public void setArrowType(int type)
Constants.EDGE_ARROW_NONE
for no edge arrows,
Constants.EDGE_ARROW_FORWARD
for arrows from source to
target on directed edges, or
Constants.EDGE_ARROW_REVERSE
for arrows from target to
source on directed edges.
type
- the new arrow typepublic void setArrowHeadSize(int width, int height)
width
- the untransformed arrow head width, in pixels. This
specifies the span of the base of the arrow head.height
- the untransformed arrow head height, in pixels. This
specifies the distance from the point of the arrow to its base.public int getArrowHeadHeight()
public int getArrowHeadWidth()
public int getHorizontalAlignment1()
Constants.LEFT
,
Constants.RIGHT
, or Constants.CENTER
.public int getVerticalAlignment1()
Constants.TOP
,
Constants.BOTTOM
, or Constants.CENTER
.public int getHorizontalAlignment2()
Constants.LEFT
,
Constants.RIGHT
, or Constants.CENTER
.public int getVerticalAlignment2()
Constants.TOP
,
Constants.BOTTOM
, or Constants.CENTER
.public void setHorizontalAlignment1(int align)
align
- the horizontal alignment, one of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
.public void setVerticalAlignment1(int align)
align
- the vertical alignment, one of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
.public void setHorizontalAlignment2(int align)
align
- the horizontal alignment, one of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
.public void setVerticalAlignment2(int align)
align
- the vertical alignment, one of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
.public void setDefaultLineWidth(double w)
w
- the desired default line width, in pixelspublic double getDefaultLineWidth()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |