public class PaintUtil extends Object
Constructor and Description |
---|
PaintUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
drawArrow(Graphics2D g,
double x1In,
double y1In,
double x2,
double y2,
int th,
int headW)
Draws an arrow.
|
static void |
drawCenteredText(String text,
Graphics2D g,
Rectangle rect)
Draws text centered in a rectangle.
|
static void |
drawHCenteredText(String text,
Graphics2D g,
Rectangle rect,
int y)
Draws text horizontally centered in a rectangle, with a specified y
position.
|
static void |
drawHorzArrow(Graphics2D g,
double y,
double xFrom,
double xTo,
int th,
int headW)
Draws a horizontal arrow.
|
static void |
drawHorzLine(Graphics2D g,
double y,
double x1,
double x2,
int th)
Draws a horizontal line.
|
static void |
drawHorzTriangle(Graphics2D g,
double y,
double x,
int l,
boolean right)
Draws a horizontal triangle.
|
static void |
drawOutlinedRoundRect(Graphics g,
double x,
double y,
double w,
double h,
double th,
double r,
Color color,
Color outlineColor)
Draws an outlined rectangle with rounded corners.
|
static void |
drawRect(Graphics g,
int x,
int y,
int w,
int h,
int th)
Draws a rectangle.
|
static void |
drawRect(Graphics g,
Rectangle rect,
int th)
Draws a rectangle.
|
static void |
drawVCenteredText(String text,
Graphics2D g,
Rectangle rect,
int x)
Draws text centered on a rectangle at a specified x position.
|
static void |
drawVertArrow(Graphics2D g,
double x,
double yFrom,
double yTo,
int th,
int headW)
Draws a vertical arrow.
|
static void |
drawVertLine(Graphics2D g,
double x,
double y1,
double y2,
int th)
Draws a vertical line.
|
static void |
drawVertTriangle(Graphics2D g,
double x,
double y,
int l,
boolean up)
Draws a vertical triangle.
|
static void |
fillRoundRect(Graphics g,
double x,
double y,
double w,
double h,
double r)
Fills a rectangle with rounded corners.
|
static int |
getHeadLength(int headW)
Gets the arrow head length from its width.
|
static void |
outlineEllipse(Graphics2D g,
Color extColor,
Color intColor,
double x,
double y,
double w,
double h,
int thr,
int th)
Given an ellipse drawn with a certain line thickness, draw an outline
around the line used to draw the ellipse.
|
static void |
outlineEllipse(Graphics2D g,
Color extColor,
Color intColor,
RectangularShape ellipse,
int thr,
int th)
Given an ellipse drawn with a certain line thickness, draw an outline
around the line used to draw the ellipse.
|
static void |
outlineRect(Graphics g,
Color extColor,
Color intColor,
int x,
int y,
int w,
int h,
int thr,
int th)
Given a rectangle drawn with a certain line thickness, draw an outline
around the line used to draw the rectangle.
|
static void |
outlineRect(Graphics g,
Color extColor,
Color intColor,
Rectangle rect,
int thr,
int th)
Given a rectangle drawn with a certain line thickness, draw an outline
around the line used to draw the rectangle.
|
static void |
paintHorizontalIndexes(Graphics2D g,
int[] x,
int yTop,
int leftEdge,
int rightEdge,
int pointerLen,
List<IndexItem> indexes,
long offset)
Paints a horizontal index marker and label.
|
static void |
prepareGraphics(Graphics2D g)
Sets key stroke control to pure and turns on antialiasing for a graphics
object.
|
static void |
prepareNonAAGraphics(Graphics2D g)
Sets key stroke control to pure and turns off antialiasing for a
graphics object.
|
public static void drawArrow(Graphics2D g, double x1In, double y1In, double x2, double y2, int th, int headW)
g
- graphics object to render to.x1In
- x position of arrow tail.y1In
- y position of arrow tail.x2
- x position of arrowhead.y2
- y position of arrowhead.th
- line thickness.headW
- half the arrowhead width.public static void drawCenteredText(String text, Graphics2D g, Rectangle rect)
text
- the text to render.g
- graphics object used for rendering.rect
- rectangle in which text will be centered.public static void drawHCenteredText(String text, Graphics2D g, Rectangle rect, int y)
text
- the text to render.g
- graphics object used for rendering.rect
- rectangle in which text will be horizontally centered.y
- baseline y position for text.public static void drawHorzArrow(Graphics2D g, double y, double xFrom, double xTo, int th, int headW)
g
- graphics object to render to.y
- center y position of line.xFrom
- x position of arrow tail.xTo
- x position of tip of arrowhead.th
- line thickness.headW
- half the arrowhead width.public static void drawHorzLine(Graphics2D g, double y, double x1, double x2, int th)
g
- graphics object to render to.y
- center y position of line.x1
- one x endpoint of line.x2
- one x endpoint of line.th
- line thickness.public static void drawHorzTriangle(Graphics2D g, double y, double x, int l, boolean right)
g
- graphics object to render to.y
- center y position of point.x
- x position of point.l
- half the arrow width and one third the height.right
- true if the triangle will point right, false if it will
point left.public static void drawOutlinedRoundRect(Graphics g, double x, double y, double w, double h, double th, double r, Color color, Color outlineColor)
g
- graphics object to render to.x
- x position of outer dimensions of rectangle.y
- y position of outer dimensions of rectangle.w
- width of outer dimensions of rectangle.h
- height of outer dimensions of rectangle.th
- the outline thickness.r
- the curve radius.color
- the inside color.outlineColor
- the outline color.public static void drawRect(Graphics g, int x, int y, int w, int h, int th)
g
- graphics object to render to.x
- x position of outer dimensions of rectangle.y
- y position of outer dimensions of rectangle.w
- width of outer dimensions of rectangle.h
- height of outer dimensions of rectangle.th
- line thickness.public static void drawRect(Graphics g, Rectangle rect, int th)
g
- graphics object to render to.rect
- outer dimensions of rectangle.th
- line thickness.public static void drawVCenteredText(String text, Graphics2D g, Rectangle rect, int x)
text
- the text to render.g
- graphics object used for rendering.rect
- rectangle in which text will be centered.x
- x position for text.public static void drawVertArrow(Graphics2D g, double x, double yFrom, double yTo, int th, int headW)
g
- graphics object to render to.x
- center x position of arrow.yFrom
- y position of arrow tail.yTo
- y position of tip of arrowhead.th
- line thickness.headW
- half the arrowhead width.public static void drawVertLine(Graphics2D g, double x, double y1, double y2, int th)
g
- graphics object to render to.x
- center x position of line.y1
- one y endpoint of line.y2
- one y endpoint of line.th
- line thickness.public static void drawVertTriangle(Graphics2D g, double x, double y, int l, boolean up)
g
- graphics object to render to.x
- center x position of point.y
- y position of point.l
- half the arrow height and one third the width.up
- true if the triangle will point up, false if it will point
down.public static void fillRoundRect(Graphics g, double x, double y, double w, double h, double r)
g
- graphics object to render to.x
- x position of outer dimensions of rectangle.y
- y position of outer dimensions of rectangle.w
- width of outer dimensions of rectangle.h
- height of outer dimensions of rectangle.r
- the curve radius.public static void outlineEllipse(Graphics2D g, Color extColor, Color intColor, double x, double y, double w, double h, int thr, int th)
g
- graphics object to render to.extColor
- the exterior outline color.intColor
- the interior outline color.x
- x position of outer dimensions of ellipse bounding box.y
- y position of outer dimensions of ellipse bounding box.w
- width of outer dimensions of ellipse bounding box.h
- height of outer dimensions of ellipse bounding box.thr
- thickness of ellipse edge.th
- thickness of line used to outline ellipse edge.public static void outlineEllipse(Graphics2D g, Color extColor, Color intColor, RectangularShape ellipse, int thr, int th)
extColor
- the exterior outline color.intColor
- the interior outline color.g
- graphics object to render to.ellipse
- outer dimensions of ellipse bounding box.thr
- thickness of ellipse edge.th
- thickness of line used to outline ellipse edge.public static void outlineRect(Graphics g, Color extColor, Color intColor, int x, int y, int w, int h, int thr, int th)
g
- graphics object to render to.extColor
- the exterior outline color.intColor
- the interior outline color.x
- x position of outer dimensions of rectangle.y
- y position of outer dimensions of rectangle.w
- width of outer dimensions of rectangle.h
- height of outer dimensions of rectangle.thr
- thickness of rectangle edge.th
- thickness of line used to outline rectangle edge.public static void outlineRect(Graphics g, Color extColor, Color intColor, Rectangle rect, int thr, int th)
extColor
- the exterior outline color.intColor
- the interior outline color.g
- graphics object to render to.rect
- outer dimensions of rectangle.thr
- thickness of rectangle edge.th
- thickness of line used to outline rectangle edge.public static void paintHorizontalIndexes(Graphics2D g, int[] x, int yTop, int leftEdge, int rightEdge, int pointerLen, List<IndexItem> indexes, long offset)
g
- graphics object used for rendering.x
- x center position of the labels, starting at
offset
.yTop
- y position for the top of the marker.leftEdge
- x position for the left bound of the marker.rightEdge
- x position for the right bound of the marker.pointerLen
- half the marker height.indexes
- the index items to be displayed.offset
- the first index to be displayed.public static void prepareGraphics(Graphics2D g)
g
- the graphics object that will be modified.public static void prepareNonAAGraphics(Graphics2D g)
g
- the graphics object that will be modified.public static int getHeadLength(int headW)
headW
- the arrow head width.