public final class BufferedImageRenderer extends Object implements Renderer
Renderer
implementation to paint on a BufferedImage
.Constructor and Description |
---|
BufferedImageRenderer(int sx,
int sy)
Size of image in pixels.
|
Modifier and Type | Method and Description |
---|---|
Renderer |
drawBorder(Area area,
int overflow)
Draw border in/around an Area.
|
Renderer |
drawEllipse(Area area)
Draw an ellipse or circle.
|
Renderer |
drawLine(int x1,
int y1,
int x2,
int y2)
Draw a line.
|
Renderer |
drawLine(Px2d p1,
Px2d p2)
Draw a line.
|
Renderer |
drawMolecule(Molecule mol,
Area area)
Render a
Molecule into an area. |
Renderer |
fillArea(Area area,
int overflow)
Fill an area.
|
Renderer |
fillEllipse(Area area)
Draw an ellipse or circle.
|
int |
getSx()
Horizontal size.
|
int |
getSy()
Vertical size.
|
Renderer |
placeCenteredHorizontalTextInto(String sq,
Area area)
Place text into the middle of an area.
|
Renderer |
placeHorizontalTextInto(String text,
Halign halign,
Valign valign,
Area area,
int offsetX,
int offsetY)
Render text into an area.
|
Renderer |
placeVerticalTextInto(String text,
Halign halign,
Valign valign,
Area area,
int offsetX,
int offsetY)
Render rotated text into an area.
|
Renderer |
setColor(String spec)
Set color.
|
Renderer |
setFontHeight(int desiredHeight)
Set a suitable font size for a specific pixel height.
|
Renderer |
setFontHeight(int desiredHeight,
double scale)
Set a suitable font size for a specific pixel height.
|
Renderer |
setRGB(int r,
int g,
int b)
Set RGB color.
|
boolean |
writePngImage(OutputStream outputStream)
Write image.
|
public BufferedImageRenderer(int sx, int sy)
sx
- Horizontal sizesy
- Vertical sizepublic boolean writePngImage(OutputStream outputStream) throws IOException
outputStream
- See ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.OutputStream)
ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.OutputStream)
IOException
- propagated from See ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.OutputStream)
public int getSx()
public int getSy()
public Renderer setColor(String spec)
Renderer
setColor
in interface Renderer
spec
- Color to set. Should be compatible with Integer.decode(java.lang.String)
.Renderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer setRGB(int r, int g, int b)
Renderer
setRGB
in interface Renderer
r
- Red component, value must be between 0
and 255
, inclusiveg
- Green component, value must be between 0
and 255
, inclusiveb
- Blue component, value must be between 0
and 255
, inclusiveRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer drawLine(int x1, int y1, int x2, int y2)
Renderer
public Renderer drawLine(Px2d p1, Px2d p2)
Renderer
public Renderer drawBorder(Area area, int overflow)
Renderer
drawBorder
in interface Renderer
area
- Areaoverflow
- Use 0
to draw the inside bounds, 1
to draw immediate outside bounds.Renderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer fillArea(Area area, int overflow)
Renderer
public Renderer drawEllipse(Area area)
Renderer
Area
. In case of a Graphics
based
target the delegated method Graphics.drawOval(int, int, int, int)
will be invoked 1 pixel by 1 pixel
smaller size.drawEllipse
in interface Renderer
area
- Area to fit intoRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer fillEllipse(Area area)
Renderer
fillEllipse
in interface Renderer
area
- Area to fit intoRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer setFontHeight(int desiredHeight)
Renderer
setFontHeight
in interface Renderer
desiredHeight
- Desired font heightRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer setFontHeight(int desiredHeight, double scale)
Renderer
setFontHeight
in interface Renderer
desiredHeight
- Desired font heightscale
- Scale factor to apply to the desired heightRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer placeHorizontalTextInto(String text, Halign halign, Valign valign, Area area, int offsetX, int offsetY)
Renderer
placeHorizontalTextInto
in interface Renderer
text
- Single line text to renderhalign
- Horizontal alignment of the text in the containing areavalign
- Vertical alignment of the text in the containing areaarea
- The containing areaoffsetX
- X offset, applied after alignmentoffsetY
- Y offset, applied after alignmentRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer placeVerticalTextInto(String text, Halign halign, Valign valign, Area area, int offsetX, int offsetY)
Renderer
placeVerticalTextInto
in interface Renderer
text
- Single line text to renderhalign
- Horizontal alignment of the rendered text in the containing areavalign
- Vertical alignment of the rendered text in the containing areaarea
- The containing areaoffsetX
- X offset, applied after alignmentoffsetY
- Y offset, applied after alignmentRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer placeCenteredHorizontalTextInto(String sq, Area area)
Renderer
placeCenteredHorizontalTextInto
in interface Renderer
sq
- Text to placearea
- An areaRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.public Renderer drawMolecule(Molecule mol, Area area)
Renderer
Molecule
into an area.drawMolecule
in interface Renderer
mol
- Molecule to renderarea
- Target areaRenderer
which can be used equivalently to this
. An implementation might
choose to return this
.