T
- the type of the edge to renderpublic class DefaultEdgeRenderer<T extends Edge> extends java.lang.Object implements EdgeRenderer<T>
CatmullRomSpline
s and the label (Edge.toString()
) is rendered in a way that it is
always visible and not overlaid by the spline.Modifier and Type | Field and Description |
---|---|
protected int |
arrowLength
the length of the arrow
|
protected boolean |
drawArrow
a flag that indicates if the arrow should be drawn
|
protected java.awt.Font |
font
the font
|
protected java.awt.Color |
foreground
the foreground color
|
protected int |
labelX
the x position of the edge label
|
protected int |
labelY
the y position of the edge label
|
protected java.awt.Stroke |
lineStroke
the stroke for the edge
|
protected int |
lineWidth
the line width
|
protected boolean |
paintLabels
flag that indicates whether the label of the edge should be displayed
|
protected CatmullRomSpline |
spline
the spline
|
protected int |
x1
the x position of the first point
|
protected int |
x2
the x position of the second point
|
protected int |
y1
the y position of the first point
|
protected int |
y2
the y position of the second point
|
Constructor and Description |
---|
DefaultEdgeRenderer()
Creates a new default edge renderer.
|
DefaultEdgeRenderer(boolean paintLabels)
Creates a new default edge renderer.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics2D g,
T o)
Renders the object to the graphics context.
|
void |
setArrowLength(int length)
Sets the length of the arrow peak.
|
void |
setBackground(java.awt.Color c)
Sets the background color.
|
void |
setControlPosition(int x,
int y)
Sets the position of the control point of the edge.
|
void |
setDrawArrow(boolean drawArrow)
Sets a flag that indicates if the arrow should be drawn are not.
|
void |
setFirstPosition(int x1,
int y1)
Sets the position of the first point of the edge.
|
void |
setFont(java.awt.Font f)
Sets the font.
|
void |
setForeground(java.awt.Color c)
Sets the foreground color.
|
void |
setLabelPosition(int x,
int y)
Sets the position of the edge label.
|
void |
setLineWidth(int width)
Sets the line width of the edge.
|
void |
setSecondPosition(int x2,
int y2)
Sets the position of the second point of the edge.
|
void |
setSpline(CatmullRomSpline s)
Sets the spline that represents the edge visually.
|
protected boolean paintLabels
protected CatmullRomSpline spline
protected java.awt.Color foreground
protected java.awt.Font font
protected int x1
protected int y1
protected int x2
protected int y2
protected int labelX
protected int labelY
protected boolean drawArrow
protected int lineWidth
protected java.awt.Stroke lineStroke
protected int arrowLength
public DefaultEdgeRenderer()
public DefaultEdgeRenderer(boolean paintLabels)
paintLabels
- true
if the labels of the edges should be display otherwise false
public void setBackground(java.awt.Color c)
Renderer
setBackground
in interface Renderer<T extends Edge>
c
- the background colorpublic void setForeground(java.awt.Color c)
Renderer
setForeground
in interface Renderer<T extends Edge>
c
- the foreground colorpublic void setFont(java.awt.Font f)
Renderer
public void draw(java.awt.Graphics2D g, T o)
Renderer
public void setFirstPosition(int x1, int y1)
EdgeRenderer
setFirstPosition
in interface EdgeRenderer<T extends Edge>
x1
- the x positiony1
- the y positionpublic void setSecondPosition(int x2, int y2)
EdgeRenderer
setSecondPosition
in interface EdgeRenderer<T extends Edge>
x2
- the x positiony2
- the y positionpublic void setControlPosition(int x, int y)
EdgeRenderer
setControlPosition
in interface EdgeRenderer<T extends Edge>
x
- the x positiony
- the y positionpublic void setDrawArrow(boolean drawArrow)
EdgeRenderer
setDrawArrow
in interface EdgeRenderer<T extends Edge>
drawArrow
- true
if the arrow of the edge should be drawn otherwise false
public void setLineWidth(int width)
EdgeRenderer
setLineWidth
in interface EdgeRenderer<T extends Edge>
width
- the line widthpublic void setSpline(CatmullRomSpline s)
EdgeRenderer
setSpline
in interface EdgeRenderer<T extends Edge>
s
- the splineCatmullRomSpline
public void setArrowLength(int length)
EdgeRenderer
setArrowLength
in interface EdgeRenderer<T extends Edge>
length
- the lengthpublic void setLabelPosition(int x, int y)
EdgeRenderer
setLabelPosition
in interface EdgeRenderer<T extends Edge>
x
- the x positiony
- the y position