Q
- Pixel typeI
- Image typepublic abstract class ImageRenderer<Q,I extends Image<Q,I>> extends Object
Modifier and Type | Field and Description |
---|---|
protected RenderHints |
hints |
protected I |
targetImage |
Constructor and Description |
---|
ImageRenderer(I targetImage)
Construct with given target image.
|
ImageRenderer(I targetImage,
RenderHints hints)
Construct with given target image and rendering hints.
|
Modifier and Type | Method and Description |
---|---|
abstract Q |
defaultBackgroundColour()
Get the default foreground colour.
|
abstract Q |
defaultForegroundColour()
Get the default foreground colour.
|
void |
drawConnectedPoints(List<? extends Point2d> pts,
Q col)
Draw onto this image lines drawn with the given colour between the points
given.
|
Point2d[] |
drawCubicBezier(Point2d p1,
Point2d p2,
Point2d c1,
Point2d c2,
int thickness,
Q col)
Draw a cubic Bezier curve into the image with 100 point accuracy.
|
protected abstract void |
drawHorizLine(int x1,
int x2,
int y,
Q col)
Draw a horizontal line with the specified colour.
|
void |
drawImage(I image,
int x,
int y)
Draw into this image the provided image at the given coordinates.
|
void |
drawImage(I image,
int x,
int y,
Q... ignoreList)
Draw into this image the provided image at the given coordinates ignoring
certain pixels.
|
abstract void |
drawLine(float x0,
float y0,
float x1,
float y1,
int thickness,
Q col)
Draw a line from the coordinates specified by
(x0,y0) to the
coordinates specified by (x1,y1) using the given color and
thickness. |
abstract void |
drawLine(int x1,
int y1,
double theta,
int length,
int thickness,
Q col)
Draw a line from the coordinates specified by
(x1,y1) at an
angle of theta with the given length, thickness and colour. |
void |
drawLine(int x1,
int y1,
double theta,
int length,
Q col)
Draw a line from the coordinates specified by
(x1,y1) at an
angle of theta with the given length and colour. |
abstract void |
drawLine(int x0,
int y0,
int x1,
int y1,
int thickness,
Q col)
Draw a line from the coordinates specified by
(x0,y0) to the
coordinates specified by (x1,y1) using the given color and
thickness. |
void |
drawLine(int x0,
int y0,
int x1,
int y1,
Q col)
Draw a line from the coordinates specified by
(x0,y0) to
(x1,y1) using the given colour. |
void |
drawLine(Path2d line,
int thickness,
Q col)
Draw a line from the specified
Path2d object |
void |
drawLine(Point2d p1,
Point2d p2,
int thickness,
Q col)
Draw a line from the coordinates specified by
(x0,y0) to
(x1,y1) using the given colour and thickness. |
void |
drawLine(Point2d p1,
Point2d p2,
Q col)
Draw a line from the coordinates specified by
(x0,y0) to
(x1,y1) using the given colour. |
void |
drawLines(Iterable<? extends Path2d> lines,
int thickness,
Q col)
Draw the given list of lines using
drawLine(Path2d, int, Object)
with the given colour and thickness. |
void |
drawPath(Path2d path,
int thickness,
Q col)
Draw a path from the specified
Path2d object |
void |
drawPaths(Iterable<? extends Path2d> paths,
int thickness,
Q col)
Draw the given list of lines using
drawLine(Path2d, int, Object)
with the given colour and thickness. |
abstract void |
drawPoint(Point2d p,
Q col,
int size)
Draw a dot centered on the given location (rounded to nearest integer
location) at the given size and with the given color.
|
void |
drawPoints(Iterable<? extends Point2d> pts,
Q col,
int size)
Draw the given list of points using
drawPoint(Point2d, Object, int) with the given colour and size. |
abstract void |
drawPolygon(Polygon p,
int thickness,
Q col)
Draw the given polygon in the specified colour with the given thickness
lines.
|
void |
drawPolygon(Polygon p,
Q col)
Draw the given polygon in the specified colour.
|
void |
drawPolygonFilled(Polygon p,
Q col)
Draw the given polygon, filled with the specified colour.
|
Point2d[] |
drawQuadBezier(Point2d p1,
Point2d p2,
Point2d c1,
int thickness,
Q colour)
Draw a Quadratic Bezier curve
|
void |
drawShape(Shape s,
int thickness,
Q col)
Draw the given shape in the specified colour with the given thickness
lines.
|
void |
drawShape(Shape p,
Q col)
Draw the given shape in the specified colour.
|
void |
drawShapeFilled(Shape s,
Q col)
Draw the given shape, filled with the specified colour.
|
void |
drawText(AttributedString text,
int x,
int y)
Render the text using its attributes.
|
void |
drawText(AttributedString text,
Point2d pt)
Render the text using its attributes.
|
<F extends Font<F>> |
drawText(String text,
int x,
int y,
F f,
int sz)
Render the text in the given font with the default style.
|
<F extends Font<F>> |
drawText(String text,
int x,
int y,
F f,
int sz,
Q col)
Render the text in the given font in the given colour with the default
style.
|
void |
drawText(String text,
int x,
int y,
FontStyle<Q> f)
Render the text with the given
FontStyle . |
<F extends Font<F>> |
drawText(String text,
Point2d pt,
F f,
int sz)
Render the text in the given font with the default style.
|
<F extends Font<F>> |
drawText(String text,
Point2d pt,
F f,
int sz,
Q col)
Render the text in the given font in the given colour with the default
style.
|
void |
drawText(String text,
Point2d pt,
FontStyle<Q> f)
Render the text with the given
FontStyle . |
I |
getImage()
Get the target image
|
RenderHints |
getRenderHints()
Get the render hints object associated with this renderer
|
protected abstract Q |
sanitise(Q colour)
Sanitize the colour given to fit this image's pixel type.
|
void |
setImage(I image)
Change the target image of this renderer.
|
void |
setRenderHints(RenderHints hints)
Set the render hints associated with this renderer
|
protected RenderHints hints
protected I extends Image<Q,I> targetImage
public ImageRenderer(I targetImage)
targetImage
- the target image.public ImageRenderer(I targetImage, RenderHints hints)
targetImage
- the target image.hints
- the render hintspublic void drawConnectedPoints(List<? extends Point2d> pts, Q col)
pts
- The point list to draw onto this image.col
- The colour to draw the linespublic void drawImage(I image, int x, int y)
image
- The image to draw.x
- The x-coordinate of the top-left of the imagey
- The y-coordinate of the top-left of the imagepublic void drawImage(I image, int x, int y, Q... ignoreList)
image
- The image to draw.x
- The x-coordinate of the top-left of the imagey
- The y-coordinate of the top-left of the imageignoreList
- The list of pixels to ignore when copying the imagepublic abstract void drawLine(int x1, int y1, double theta, int length, int thickness, Q col)
(x1,y1)
at an
angle of theta
with the given length, thickness and colour.x1
- The x-coordinate to start the line.y1
- The y-coordinate to start the line.theta
- The angle at which to draw the line.length
- The length to draw the line.thickness
- The thickness to draw the line.col
- The colour to draw the line.public void drawLine(int x1, int y1, double theta, int length, Q col)
(x1,y1)
at an
angle of theta
with the given length and colour.
Line-thickness will be 1.x1
- The x-coordinate to start the line.y1
- The y-coordinate to start the line.theta
- The angle at which to draw the line.length
- The length to draw the line.col
- The colour to draw the line.public abstract void drawLine(int x0, int y0, int x1, int y1, int thickness, Q col)
(x0,y0)
to the
coordinates specified by (x1,y1)
using the given color and
thickness.x0
- The x-coordinate at the start of the line.y0
- The y-coordinate at the start of the line.x1
- The x-coordinate at the end of the line.y1
- The y-coordinate at the end of the line.thickness
- The thickness which to draw the line.col
- The colour in which to draw the line.public abstract void drawLine(float x0, float y0, float x1, float y1, int thickness, Q col)
(x0,y0)
to the
coordinates specified by (x1,y1)
using the given color and
thickness.x0
- The x-coordinate at the start of the line.y0
- The y-coordinate at the start of the line.x1
- The x-coordinate at the end of the line.y1
- The y-coordinate at the end of the line.thickness
- The thickness which to draw the line.col
- The colour in which to draw the line.public void drawLine(int x0, int y0, int x1, int y1, Q col)
(x0,y0)
to
(x1,y1)
using the given colour. The line thickness will be 1
pixel.x0
- The x-coordinate at the start of the line.y0
- The y-coordinate at the start of the line.x1
- The x-coordinate at the end of the line.y1
- The y-coordinate at the end of the line.col
- The colour in which to draw the line.public void drawLine(Point2d p1, Point2d p2, Q col)
(x0,y0)
to
(x1,y1)
using the given colour. The line thickness will be 1
pixel.p1
- The coordinate of the start of the line.p2
- The coordinate of the end of the line.col
- The colour in which to draw the line.public void drawLine(Point2d p1, Point2d p2, int thickness, Q col)
(x0,y0)
to
(x1,y1)
using the given colour and thickness.p1
- The coordinate of the start of the line.p2
- The coordinate of the end of the line.thickness
- the stroke widthcol
- The colour in which to draw the line.public void drawLine(Path2d line, int thickness, Q col)
Path2d
objectline
- the linethickness
- the stroke widthcol
- The colour in which to draw the line.public void drawPath(Path2d path, int thickness, Q col)
Path2d
objectpath
- the paththickness
- the stroke widthcol
- The colour in which to draw the line.public void drawLines(Iterable<? extends Path2d> lines, int thickness, Q col)
drawLine(Path2d, int, Object)
with the given colour and thickness.lines
- The list of lines to draw.thickness
- the stroke widthcol
- The colour to draw each point.public void drawPaths(Iterable<? extends Path2d> paths, int thickness, Q col)
drawLine(Path2d, int, Object)
with the given colour and thickness.paths
- The list of paths to draw.thickness
- the stroke widthcol
- The colour to draw each point.public abstract void drawPoint(Point2d p, Q col, int size)
p
- The coordinates at which to draw the pointcol
- The colour to draw the pointsize
- The size at which to draw the point.public void drawPoints(Iterable<? extends Point2d> pts, Q col, int size)
drawPoint(Point2d, Object, int)
with the given colour and size.pts
- The list of points to draw.col
- The colour to draw each point.size
- The size to draw each point.public abstract void drawPolygon(Polygon p, int thickness, Q col)
p
- The polygon to draw.thickness
- The thickness of the lines to usecol
- The colour to draw the lines inpublic void drawPolygon(Polygon p, Q col)
drawPolygon(Polygon, int, Object)
with line thickness 1.p
- The polygon to draw.col
- The colour to draw the polygon in.protected abstract void drawHorizLine(int x1, int x2, int y, Q col)
x1
- starting x (inclusive)x2
- ending x (inclusive)y
- ycol
- the colourpublic void drawPolygonFilled(Polygon p, Q col)
p
- The polygon to draw.col
- The colour to fill the polygon with.public void drawShape(Shape s, int thickness, Q col)
s
- The shape to draw.thickness
- The thickness of the lines to usecol
- The colour to draw the lines inpublic void drawShape(Shape p, Q col)
drawPolygon(Polygon, int, Object)
with line thickness 1.p
- The shape to draw.col
- The colour to draw the polygon in.public void drawShapeFilled(Shape s, Q col)
s
- The shape to draw.col
- The colour to fill the polygon with.public <F extends Font<F>> void drawText(String text, int x, int y, F f, int sz)
F
- the fonttext
- the textx
- the x-ordinatey
- the y-ordinatef
- the fontsz
- the sizepublic <F extends Font<F>> void drawText(String text, int x, int y, F f, int sz, Q col)
F
- the fonttext
- the textx
- the x-ordinatey
- the y-ordinatef
- the fontsz
- the sizecol
- the font colorpublic <F extends Font<F>> void drawText(String text, Point2d pt, F f, int sz)
F
- the fonttext
- the textpt
- the coordinate to render atf
- the fontsz
- the sizepublic <F extends Font<F>> void drawText(String text, Point2d pt, F f, int sz, Q col)
F
- the fonttext
- the textpt
- the coordinate to render atf
- the fontsz
- the sizecol
- the font colourpublic void drawText(String text, int x, int y, FontStyle<Q> f)
FontStyle
.text
- the textx
- the x-ordinatey
- the y-ordinatef
- the font stylepublic void drawText(String text, Point2d pt, FontStyle<Q> f)
FontStyle
.text
- the textpt
- the coordinate to render atf
- the font stylepublic void drawText(AttributedString text, int x, int y)
text
- the textx
- the x-ordinatey
- the y-ordinatepublic void drawText(AttributedString text, Point2d pt)
text
- the textpt
- the coordinate to render atpublic Point2d[] drawCubicBezier(Point2d p1, Point2d p2, Point2d c1, Point2d c2, int thickness, Q col)
p1
- One end point of the linep2
- The other end point of the linec1
- The control point associated with p1c2
- The control point associated with p2thickness
- The thickness to draw the linecol
- The colour to draw the linepublic Point2d[] drawQuadBezier(Point2d p1, Point2d p2, Point2d c1, int thickness, Q colour)
p1
- p2
- c1
- thickness
- colour
- public abstract Q defaultForegroundColour()
public abstract Q defaultBackgroundColour()
public void setImage(I image)
image
- new targetpublic RenderHints getRenderHints()
public void setRenderHints(RenderHints hints)
hints
- the new hints