Package org.tinfour.utils.rendering
Class RendererForTinInspection
- java.lang.Object
-
- org.tinfour.utils.rendering.RendererForTinInspection
-
public class RendererForTinInspection extends Object
Provides a utility for rendering instances of the incremental TIN classes (the Delaunay triangulation classes) to an image. This class provides a visual representation of the TIN that can be useful for development and diagnostic purposes.
-
-
Constructor Summary
Constructors Constructor Description RendererForTinInspection(IIncrementalTin tin)Construct an instance of a renderer configured for the default presentation of a Delaunay triangulation (e.g, a TIN).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOverlay(Shape shape, Color color, BasicStroke stroke, boolean fill)Adds a shape to be rendered after the Delaunay triangulation (TIN) content is drawn.voidaddUnderlay(Shape shape, Color color, BasicStroke stroke, boolean fill)Adds a shape to be rendered before the Delaunay triangulation (TIN) content is drawn.RenderingSurfaceAidrender(int width, int height, int pad)Depicts the content of the Delaunay triangulation (TIN) associated with this instance.voidrender(RenderingSurfaceAid rsa)Uses the application-provided RenderingSurfaceAir to depicts the content of the Delaunay triangulation (TIN) associated with this instance.BufferedImagerenderImage(int width, int height, int pad)Depicts the content of the Delaunay triangulation (TIN) associated with this instance.voidsetBackgroundColor(Color background)Sets the background color for the image.voidsetCoordinateSystemIsPixels(boolean coordinateSystemIsPixels)Indicates that the coordinate system associated with the Delaunay triangulation should be rendered as if the coordinates were based on pixels rather than a Cartesian coordinate system.voidsetDrawFrameEnabled(boolean enabled)Enables the drawing of a rectangular frame around the imagevoidsetEdgeColor(Color edgeColor)Sets the color for drawing edges.voidsetEdgeLabelDualSideConfiguration(boolean enabled)Sets the edge-rendering operation to label both sides of an edge.voidsetEdgeLabelEnabled(boolean enabled)Sets the render operation to label edges.voidsetEdgeRenderingEnabled(boolean enabled)Sets the rendering operation to draw edges.voidsetForegroundColor(Color foreground)Sets the foreground color used to draw vertices, frames, and other features.voidsetIncrementalTin(IIncrementalTin tin)Sets the incremental TIN instance to be used for renderingvoidsetVertexLabelEnabledToDisplayZ(boolean enabled)Sets the render operation to label vertices based on their z value.voidsetVertexLabelEnabledToShowIndex(boolean enabled)Sets the render operation to label vertices based on their integer index value.voidsetVertexLabelFormatZ(String format)Sets the format used when creating a label based on the numerical value of the z coordinate for a vertex.voidsetVertexRenderingEnabled(boolean enabled)Sets the render operation to draw vertices.voidsetVertexRenderingSize(double size)Set the size in pixels for the vertex symbol.Path2DtranscribeEdgesToPath2D(List<IQuadEdge> edges)Creates a Path2D from a list of edges.
-
-
-
Constructor Detail
-
RendererForTinInspection
public RendererForTinInspection(IIncrementalTin tin)
Construct an instance of a renderer configured for the default presentation of a Delaunay triangulation (e.g, a TIN).- Parameters:
tin- a valid instance of an incremental TIN class.
-
-
Method Detail
-
setIncrementalTin
public void setIncrementalTin(IIncrementalTin tin)
Sets the incremental TIN instance to be used for rendering- Parameters:
tin- a valid instance
-
addUnderlay
public void addUnderlay(Shape shape, Color color, BasicStroke stroke, boolean fill)
Adds a shape to be rendered before the Delaunay triangulation (TIN) content is drawn. The Delaunay depiction may cover features that are drawn as underlays.- Parameters:
shape- a valid shape instancecolor- the color in which the shape will be drawn.stroke- the stroke in which the shape will be drawn, or null to use the default one-pixel line.fill- true if the shape is to be area-filled; false if only an outline is required.
-
addOverlay
public void addOverlay(Shape shape, Color color, BasicStroke stroke, boolean fill)
Adds a shape to be rendered after the Delaunay triangulation (TIN) content is drawn. Overlays will be placed on top of the TIN depiction and may cover features that are drawn below them.- Parameters:
shape- a valid shape instancecolor- the color in which the shape will be drawn.stroke- the stroke in which the shape will be drawn, or null to use the default one-pixel line.fill- true if the shape is to be area-filled; false if only an outline is required.
-
renderImage
public BufferedImage renderImage(int width, int height, int pad)
Depicts the content of the Delaunay triangulation (TIN) associated with this instance. The results are returned in the form of an BufferedImage.This method is a wrapper around the render method. The render method returns a result that provides additional metadata about the image. The metadata may be useful for interactive applications or in cases where the developer wishes to depict features not directly supported by this utility.
- Parameters:
width- the width of the imageheight- the height of the imagepad- reserved space between the Delaunay triangulation features and the edge of the image; may be used for labels, etc.- Returns:
- if successful, a valid instance.
-
render
public RenderingSurfaceAid render(int width, int height, int pad)
Depicts the content of the Delaunay triangulation (TIN) associated with this instance. The results are returned in the form of an instance of the RenderingSurfaceAid class. The results include both a BufferedImage instance and a pair of associated AffineTransform instances that allow an application to convert coordinate between pixels and the real-valued coordinate system associated with the TIN.- Parameters:
width- the width of the imageheight- the height of the imagepad- reserved space between the Delaunay triangulation features and the edge of the image; may be used for labels, etc.- Returns:
- if successful, a valid instance.
-
render
public void render(RenderingSurfaceAid rsa)
Uses the application-provided RenderingSurfaceAir to depicts the content of the Delaunay triangulation (TIN) associated with this instance.- Parameters:
rsa- A valid instance providing coordinate transforms and graphics resources for depiction.
-
setBackgroundColor
public void setBackgroundColor(Color background)
Sets the background color for the image.- Parameters:
background- a valid instance.
-
setForegroundColor
public void setForegroundColor(Color foreground)
Sets the foreground color used to draw vertices, frames, and other features.- Parameters:
foreground- a valid instance.
-
setDrawFrameEnabled
public void setDrawFrameEnabled(boolean enabled)
Enables the drawing of a rectangular frame around the image- Parameters:
enabled- true if a frame is to be rendered; otherwise false.
-
setEdgeColor
public void setEdgeColor(Color edgeColor)
Sets the color for drawing edges.- Parameters:
edgeColor- a valid instance.
-
setEdgeRenderingEnabled
public void setEdgeRenderingEnabled(boolean enabled)
Sets the rendering operation to draw edges.- Parameters:
enabled- true if edges are to be drawn; false if edges are not rendered.
-
setEdgeLabelEnabled
public void setEdgeLabelEnabled(boolean enabled)
Sets the render operation to label edges. By default, only the baseline side for an edge is labeled. But the label selection can be configured for two-sided labeling using the setEdgeLabelDualSideConfiguration method.- Parameters:
enabled- true if edges are labeled; false if edge labels are not rendered.
-
setEdgeLabelDualSideConfiguration
public void setEdgeLabelDualSideConfiguration(boolean enabled)
Sets the edge-rendering operation to label both sides of an edge. By default, only the baseline side for an edge is labeled. Single sided labeling is advantageous in cases where an image includes a dense arrangement of edges and might become overly cluttered if edges were labeled on both sides.- Parameters:
enabled- true if both sides of an edge are to be labeled; false if only the baseline-side of the edge (the even-numbered side) is labeled.
-
setVertexRenderingEnabled
public void setVertexRenderingEnabled(boolean enabled)
Sets the render operation to draw vertices.- Parameters:
enabled- true if vertices are to be drawn; false if vertices are not rendered.
-
setVertexLabelEnabledToShowIndex
public void setVertexLabelEnabledToShowIndex(boolean enabled)
Sets the render operation to label vertices based on their integer index value.- Parameters:
enabled- true if index-value rendering is enabled; otherwise false.
-
setVertexLabelEnabledToDisplayZ
public void setVertexLabelEnabledToDisplayZ(boolean enabled)
Sets the render operation to label vertices based on their z value.- Parameters:
enabled- true if z-value rendering is enabled; otherwise false.
-
setVertexLabelFormatZ
public void setVertexLabelFormatZ(String format)
Sets the format used when creating a label based on the numerical value of the z coordinate for a vertex.- Parameters:
format- a valid Java format string.
-
transcribeEdgesToPath2D
public Path2D transcribeEdgesToPath2D(List<IQuadEdge> edges)
Creates a Path2D from a list of edges. In cases where the first vertex in an edge matches the second vertex in the previous edge, it is assumed that the edges are connected and they will be jointed using the Path2D.lineTo() method. In cases where there is a gap between edges, they will be processed using the Path2D.moveTo() method.- Parameters:
edges- a list containing zero or more edges.- Returns:
- a valid, potentially empty, Path2D instance
-
setCoordinateSystemIsPixels
public void setCoordinateSystemIsPixels(boolean coordinateSystemIsPixels)
Indicates that the coordinate system associated with the Delaunay triangulation should be rendered as if the coordinates were based on pixels rather than a Cartesian coordinate system. In a pixel system y coordinates are defined to be increasing downward (so that the origin would be the upper-left corner of the display surface). Setting the coordinate system to be based on pixels has the effect of flipping the rendering upside down.Setting the coordinate system to pixels has a side effect in that the triangles in the depiction may appear to be oriented in clockwise fashion rather than counterclockwise. This is an artifact of the rendering operation and does not affect the underlying Delaunay triangulation.
- Parameters:
coordinateSystemIsPixels- true if the coordinate system is to be treated as based on pixels; false if the coordinate system is to be treated as Cartesian.
-
setVertexRenderingSize
public void setVertexRenderingSize(double size)
Set the size in pixels for the vertex symbol. The default size is 5 pixels.- Parameters:
size- a positive floating point value, in pixels.
-
-