public class LinePainter2D
extends java.lang.Object
LinePainter2D.StrokeType
, provided that the graphics stroke is BasicStroke
),
otherwise defaults to Graphics2D.draw(Line2D.Double)
.
It's assumed that the ScaleType.USR_SCALE
factor is already applied to the values (given in the user space)
passed to the methods of this class. So the user scale factor is not taken into account.
Modifier and Type | Class and Description |
---|---|
static class |
LinePainter2D.Align
A enum bit in a flag which defines alignment for a line or a rectangle.
|
static class |
LinePainter2D.StrokeType
Defines the way the stroke is painted relative to the vector [x1, y1] -> [x2, y2].
|
Constructor and Description |
---|
LinePainter2D() |
Modifier and Type | Method and Description |
---|---|
static java.awt.geom.Line2D |
align(java.awt.Graphics2D g,
java.util.EnumSet<LinePainter2D.Align> align,
double x,
double y,
double prefLength,
boolean vertical,
LinePainter2D.StrokeType strokeType,
double strokeWidth)
Aligns the line relative to the provided
x, y according to the provided align . |
static void |
fillPolygon(java.awt.Graphics2D g,
double [] xPoints,
double [] yPoints,
int nPoints,
LinePainter2D.StrokeType strokeType,
double strokeWidth,
java.lang.Object valueAA)
Fills a polygon.
|
static double |
getStrokeCenter(java.awt.Graphics2D g,
double xy,
LinePainter2D.StrokeType strokeType,
double strokeWidth)
Returns the x (y) coordinate of the center of the stroke.
|
static void |
paint(java.awt.Graphics2D g,
double x1,
double y1,
double x2,
double y2) |
static void |
paint(java.awt.Graphics2D g,
double x1,
double y1,
double x2,
double y2,
LinePainter2D.StrokeType strokeType,
double strokeWidth) |
static void |
paint(java.awt.Graphics2D g,
double x1,
double y1,
double x2,
double y2,
LinePainter2D.StrokeType strokeType,
double strokeWidth,
java.lang.Object valueAA)
Draws a line.
|
static void |
paint(java.awt.Graphics2D g,
java.awt.geom.Line2D line,
LinePainter2D.StrokeType strokeType,
double strokeWidth,
java.lang.Object valueAA) |
static void |
paintPolygon(java.awt.Graphics2D g,
double [] xPoints,
double [] yPoints,
int nPoints,
LinePainter2D.StrokeType strokeType,
double strokeWidth,
java.lang.Object valueAA)
Draws a polygon.
|
public static void paint(java.awt.Graphics2D g, double x1, double y1, double x2, double y2)
public static void paint(java.awt.Graphics2D g, double x1, double y1, double x2, double y2, LinePainter2D.StrokeType strokeType, double strokeWidth)
public static void paint(java.awt.Graphics2D g, java.awt.geom.Line2D line, LinePainter2D.StrokeType strokeType, double strokeWidth, java.lang.Object valueAA)
public static void paint(java.awt.Graphics2D g, double x1, double y1, double x2, double y2, LinePainter2D.StrokeType strokeType, double strokeWidth, java.lang.Object valueAA)
g
- the graphics to paint onx1
- x1y1
- y1x2
- x2y2
- y2strokeType
- the stroke typestrokeWidth
- the stroke widthvalueAA
- overrides current RenderingHints.KEY_ANTIALIASING
to valueAA
public static void fillPolygon(java.awt.Graphics2D g, double [] xPoints, double [] yPoints, int nPoints, LinePainter2D.StrokeType strokeType, double strokeWidth, java.lang.Object valueAA)
g
- the graphicsxPoints
- the x polygon pointsyPoints
- the y polygon pointsnPoints
- the number of pointsstrokeType
- the stroke typestrokeWidth
- the stroke widthvalueAA
- overrides current RenderingHints.KEY_ANTIALIASING
to valueAA
public static void paintPolygon(java.awt.Graphics2D g, double [] xPoints, double [] yPoints, int nPoints, LinePainter2D.StrokeType strokeType, double strokeWidth, java.lang.Object valueAA)
g
- the graphicsxPoints
- the x polygon pointsyPoints
- the y polygon pointsnPoints
- the number of pointsstrokeType
- the stroke typestrokeWidth
- the stroke widthvalueAA
- overrides current RenderingHints.KEY_ANTIALIASING
to valueAA
public static java.awt.geom.Line2D align(java.awt.Graphics2D g, java.util.EnumSet<LinePainter2D.Align> align, double x, double y, double prefLength, boolean vertical, LinePainter2D.StrokeType strokeType, double strokeWidth)
x, y
according to the provided align
.
If align
contains CENTER_X
, the provided x
is treated as the x center.
If align
contains CENTER_Y
, the provided y
is treated as the y center.
Otherwise, x and/or y is not changed.
As the center x (y) coordinate it's expected either a value equal to integer in the device space,
in which case the prefLength
is adjusted to a closed even value in the device space,
or a value b/w two integers in the device space, in which case the prefLength
is adjusted
to a closed odd value in the device space.
g
- the graphicsalign
- the alignx
- x obeying align
y
- y obeying align
prefLength
- the preferred length of the linevertical
- whether the line is vertical or horizontalstrokeType
- the stroke typestrokeWidth
- the stroke widthpublic static double getStrokeCenter(java.awt.Graphics2D g, double xy, LinePainter2D.StrokeType strokeType, double strokeWidth)
g
- the graphicsxy
- the x or y coordinatestrokeType
- the stroke typestrokeWidth
- the stroke width