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)
RenderersetColor in interface Rendererspec - 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)
RenderersetRGB in interface Rendererr - 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)
Rendererpublic Renderer drawLine(Px2d p1, Px2d p2)
Rendererpublic Renderer drawBorder(Area area, int overflow)
RendererdrawBorder in interface Rendererarea - 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)
Rendererpublic Renderer drawEllipse(Area area)
RendererArea. 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 Rendererarea - Area to fit intoRenderer which can be used equivalently to this. An implementation might
choose to return this.public Renderer fillEllipse(Area area)
RendererfillEllipse in interface Rendererarea - Area to fit intoRenderer which can be used equivalently to this. An implementation might
choose to return this.public Renderer setFontHeight(int desiredHeight)
RenderersetFontHeight in interface RendererdesiredHeight - Desired font heightRenderer which can be used equivalently to this. An implementation might
choose to return this.public Renderer setFontHeight(int desiredHeight, double scale)
RenderersetFontHeight in interface RendererdesiredHeight - 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)
RendererplaceHorizontalTextInto in interface Renderertext - 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)
RendererplaceVerticalTextInto in interface Renderertext - 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)
RendererplaceCenteredHorizontalTextInto in interface Renderersq - 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)
RendererMolecule into an area.drawMolecule in interface Renderermol - Molecule to renderarea - Target areaRenderer which can be used equivalently to this. An implementation might
choose to return this.