|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprefuse.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(EdgeArrowType)
method for more.
Nested Class Summary | |
---|---|
static class |
EdgeRenderer.EdgeArrowType
|
static class |
EdgeRenderer.EdgeType
|
Field Summary | |
---|---|
protected boolean |
hideNodeInternalSegments
|
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 EdgeRenderer.EdgeArrowType |
m_edgeArrow
|
protected EdgeRenderer.EdgeType |
m_edgeType
|
protected java.awt.geom.Point2D[] |
m_intersectSourcePoints
|
protected java.awt.geom.Point2D[] |
m_intersectTargetPoints
|
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 Alignment |
m_xAlign1
|
protected Alignment |
m_xAlign2
|
protected Alignment |
m_yAlign1
|
protected Alignment |
m_yAlign2
|
protected float |
splineSlack
|
Fields inherited from class prefuse.render.AbstractShapeRenderer |
---|
m_manageBounds, m_transform |
Fields inherited from interface prefuse.render.Renderer |
---|
DEFAULT_GRAPHICS |
Constructor Summary | |
---|---|
EdgeRenderer()
Create a new EdgeRenderer. |
|
EdgeRenderer(EdgeRenderer.EdgeType edgeType)
Create a new EdgeRenderer with the given edge type. |
|
EdgeRenderer(EdgeRenderer.EdgeType edgeType,
EdgeRenderer.EdgeArrowType arrowType)
Create a new EdgeRenderer with the given edge and arrow types. |
Method Summary | |
---|---|
void |
calculateBounds(VisualItem<?> item,
java.awt.geom.Rectangle2D bounds)
Calculates the bounding rectangle for an item. |
protected java.awt.Shape |
createCurvedEdge(float[] poly,
boolean[] invisibleSegments)
|
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. |
EdgeRenderer.EdgeArrowType |
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. |
EdgeRenderer.EdgeType |
getEdgeType()
Returns the type of the drawn edge. |
Alignment |
getHorizontalAlignment1()
Get the horizontal alignment of the edge mount point with the first node. |
Alignment |
getHorizontalAlignment2()
Get the horizontal alignment 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. |
RenderType |
getRenderType(VisualItem<?> item)
Returns a value indicating if a shape is drawn by its outline, by a fill, or both. |
float |
getSplineSlack()
|
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. |
Alignment |
getVerticalAlignment1()
Get the vertical alignment of the edge mount point with the first node. |
Alignment |
getVerticalAlignment2()
Get the vertical alignment of the edge mount point with the second node. |
boolean |
isHideNodeInternalSegments()
|
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(EdgeRenderer.EdgeArrowType type)
Sets the type of the drawn edge. |
void |
setDefaultLineWidth(double w)
Sets the default width of lines. |
void |
setEdgeType(EdgeRenderer.EdgeType type)
Sets the type of the drawn edge. |
void |
setHideNodeInternalSegments(boolean hideNodeInternalSegments)
|
void |
setHorizontalAlignment1(Alignment align)
Set the horizontal alignment of the edge mount point with the first node. |
void |
setHorizontalAlignment2(Alignment align)
Set the horizontal alignment of the edge mount point with the second node. |
void |
setSplineSlack(float splineSlack)
|
void |
setVerticalAlignment1(Alignment align)
Set the vertical alignment of the edge mount point with the first node. |
void |
setVerticalAlignment2(Alignment align)
Set the vertical alignment 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, getFillColor, getShape, getStrokeColor, managesBounds, setManageBounds, setRenderType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.geom.Line2D m_line
protected java.awt.geom.CubicCurve2D m_cubic
protected EdgeRenderer.EdgeType m_edgeType
protected Alignment m_xAlign1
protected Alignment m_yAlign1
protected Alignment m_xAlign2
protected Alignment 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 java.awt.geom.Point2D[] m_intersectSourcePoints
protected java.awt.geom.Point2D[] m_intersectTargetPoints
protected boolean hideNodeInternalSegments
protected EdgeRenderer.EdgeArrowType 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
protected float splineSlack
Constructor Detail |
---|
public EdgeRenderer()
public EdgeRenderer(EdgeRenderer.EdgeType edgeType)
edgeType
- the edge typepublic EdgeRenderer(EdgeRenderer.EdgeType edgeType, EdgeRenderer.EdgeArrowType arrowType)
edgeType
- the edge typearrowType
- the arrow typesetArrowType(EdgeArrowType)
Method Detail |
---|
public RenderType 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
TODO: refactor this method - it is far too complicated now
protected java.awt.Shape createCurvedEdge(float[] poly, boolean[] invisibleSegments)
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 calculateBounds(VisualItem<?> item, java.awt.geom.Rectangle2D bounds)
Renderer
calculateBounds
in interface Renderer
calculateBounds
in class AbstractShapeRenderer
item
- the item to compute the bounding box forbounds
- the rectangle to populate with the bounding boxRenderer.calculateBounds(VisualItem,Rectangle2D)
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 topublic EdgeRenderer.EdgeType getEdgeType()
public void setEdgeType(EdgeRenderer.EdgeType type)
type
- the new edge typepublic EdgeRenderer.EdgeArrowType getArrowType()
public void setArrowType(EdgeRenderer.EdgeArrowType type)
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 Alignment getHorizontalAlignment1()
public Alignment getVerticalAlignment1()
public Alignment getHorizontalAlignment2()
public Alignment getVerticalAlignment2()
public void setHorizontalAlignment1(Alignment align)
align
- the horizontal alignmentpublic void setVerticalAlignment1(Alignment align)
align
- the vertical alignmentpublic void setHorizontalAlignment2(Alignment align)
align
- the horizontal alignmentpublic void setVerticalAlignment2(Alignment align)
align
- the vertical alignmentpublic void setDefaultLineWidth(double w)
w
- the desired default line width, in pixelspublic double getDefaultLineWidth()
public float getSplineSlack()
public void setSplineSlack(float splineSlack)
public boolean isHideNodeInternalSegments()
public void setHideNodeInternalSegments(boolean hideNodeInternalSegments)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |