public class BoundedVoronoiDrawingUtility extends Object
Note: This class is under construction and not yet fully tested. Use with caution.
Constructor and Description |
---|
BoundedVoronoiDrawingUtility(BoundedVoronoiDiagram diagram,
int width,
int height,
int pad,
Rectangle2D optionalBounds)
Constructs drawing utility instance for the specified Bounded Voronoi
Diagram.
|
BoundedVoronoiDrawingUtility(BoundedVoronoiDiagram diagram,
Rectangle2D clipBounds,
AffineTransform af) |
Modifier and Type | Method and Description |
---|---|
void |
assignAutomaticColors()
Assigns automatic color selections to the vertices and associated polygons
in the bounded Voronoi diagram stored when this instance was constructed.
|
void |
draw(Graphics g,
IBoundedVoronoiStyler specifiedStyler)
Draws the Bounded Voronoi Diagram using the specified styler
|
void |
drawEdges(Graphics g,
Color foreground,
double strokeWidth,
List<IQuadEdge> edgeList)
Draws a the edges from the specified list.
|
void |
drawPolygons(Graphics g,
Paint[] paintSpec,
boolean assignAutomaticColors)
Performs area-fill operations on the polygons that are defined by the
Voronoi Diagram.
|
void |
drawVertices(Graphics g,
Color foreground,
Font font,
List<Vertex> vertexList)
Draws a the vertices of the specified list.
|
void |
drawWireframe(Graphics g,
Color foreground,
double strokeWidth,
Font font)
Draws a the edges and vertices of the Voronoi Diagram.
|
public BoundedVoronoiDrawingUtility(BoundedVoronoiDiagram diagram, int width, int height, int pad, Rectangle2D optionalBounds)
The width and height define the size of the intended graphics surface. An affine transform will be created to map the coordinate system of the Voronoi Diagram to the specified graphics surface. The aspect ratio of the diagram will be preserved and fit to use the maximum available space. If desired, an application may specify a padding factor to reserve some blank space around the edges of the diagram.
Normally, the transform will be initialized using the a rectangle slightly larger than the sample bounds of the diagram, but if desired an application may specify an alternate alternate bounds specification.
diagram
- a valid instance of a Voronoi Diagram structurewidth
- the width of the graphics surfaceheight
- the height of the graphics surfacepad
- an optional padding factoroptionalBounds
- an alternate bounds specification, or a null if the
defaults are to be used.public BoundedVoronoiDrawingUtility(BoundedVoronoiDiagram diagram, Rectangle2D clipBounds, AffineTransform af)
public void drawWireframe(Graphics g, Color foreground, double strokeWidth, Font font)
g
- the graphics surface for drawingforeground
- the color for drawing the graphicsstrokeWidth
- the width of the line features to be draw (typically, a
value of 2).font
- an optional font specification for labeling vertices; or null
if no labeling is to be performed.public void drawVertices(Graphics g, Color foreground, Font font, List<Vertex> vertexList)
g
- the graphics surface for drawingforeground
- the color for drawing the graphicsfont
- an optional font specification for labeling vertices; or null
if no labeling is to be performed.vertexList
- the list of vertices to be drawnpublic void drawPolygons(Graphics g, Paint[] paintSpec, boolean assignAutomaticColors)
Recall that in Java, the Color object implemented the Paint interface. So an array of Color objects is a valid input.
g
- the graphics surface for drawingpaintSpec
- an array of paint instances corresponding to the color
index values of each vertexassignAutomaticColors
- indicates that the vertices are to be assigned
color index values automatically. Doing so will override any color-index
values previously stored in the vertices.public void drawEdges(Graphics g, Color foreground, double strokeWidth, List<IQuadEdge> edgeList)
g
- the graphics surface for drawingforeground
- the color for drawing the graphicsstrokeWidth
- the width of the line features to be draw (typically, a
value of 2).edgeList
- the edges to be drawnpublic void assignAutomaticColors()
This method is potentially costly for diagrams containing a large number of vertices. Therefore, it should only be called once when rendering.
This method assigns six color indices to polygons (in the range 0 to 5). If applications that use automatic color assignment require a custom palette, they must specify and array of Color or Paint instances with at least six elements. If a smaller palette is supplied, the results are undefined.
public void draw(Graphics g, IBoundedVoronoiStyler specifiedStyler)
This method is under development. It is not yet ready for use and may be subject to changes.
g
- a valid graphic surfacespecifiedStyler
- a valid styler implementation, or a null if defaults
are to be usedCopyright © 2021. All rights reserved.