public class VertexShapeFactory<V> extends Object
Shape
s for drawing vertices.
The available shapes include rectangles, rounded rectangles, ellipses,
regular polygons, and regular stars. The dimensions of the requested
shapes are defined by the specified vertex size function (specified by
a Function<? super V, Integer>
) and vertex aspect ratio function
(specified by a Function<? super V, Float>
) implementations: the width
of the bounding box of the shape is given by the vertex size, and the
height is given by the size multiplied by the vertex's aspect ratio.Modifier and Type | Field and Description |
---|---|
protected com.google.common.base.Function<? super V,Float> |
varf |
protected com.google.common.base.Function<? super V,Integer> |
vsf |
Constructor and Description |
---|
VertexShapeFactory()
Creates a
VertexShapeFactory with a constant size of
10 and a constant aspect ratio of 1. |
VertexShapeFactory(com.google.common.base.Function<? super V,Integer> vsf,
com.google.common.base.Function<? super V,Float> varf)
Creates an instance with the specified vertex size and aspect ratio functions.
|
Modifier and Type | Method and Description |
---|---|
Ellipse2D |
getEllipse(V v)
Returns a
Ellipse2D whose width and
height are defined by this instance's size and
aspect ratio functions for this vertex. |
Rectangle2D |
getRectangle(V v)
Returns a
Rectangle2D whose width and
height are defined by this instance's size and
aspect ratio functions for this vertex. |
Shape |
getRegularPolygon(V v,
int num_sides)
Returns a regular
num_sides -sided
Polygon whose bounding
box's width and height are defined by this instance's size and
aspect ratio functions for this vertex. |
Shape |
getRegularStar(V v,
int num_points)
Returns a regular
Polygon of num_points
points whose bounding
box's width and height are defined by this instance's size and
aspect ratio functions for this vertex. |
RoundRectangle2D |
getRoundRectangle(V v)
Returns a
RoundRectangle2D whose width and
height are defined by this instance's size and
aspect ratio functions for this vertex. |
public VertexShapeFactory(com.google.common.base.Function<? super V,Integer> vsf, com.google.common.base.Function<? super V,Float> varf)
vsf
- provides a size (width) for each vertexvarf
- provides a height/width ratio for each vertexpublic VertexShapeFactory()
VertexShapeFactory
with a constant size of
10 and a constant aspect ratio of 1.public Rectangle2D getRectangle(V v)
Rectangle2D
whose width and
height are defined by this instance's size and
aspect ratio functions for this vertex.v
- the vertex for which the shape will be drawnpublic Ellipse2D getEllipse(V v)
Ellipse2D
whose width and
height are defined by this instance's size and
aspect ratio functions for this vertex.v
- the vertex for which the shape will be drawnpublic RoundRectangle2D getRoundRectangle(V v)
RoundRectangle2D
whose width and
height are defined by this instance's size and
aspect ratio functions for this vertex. The arc size is
set to be half the minimum of the height and width of the frame.v
- the vertex for which the shape will be drawnpublic Shape getRegularPolygon(V v, int num_sides)
num_sides
-sided
Polygon
whose bounding
box's width and height are defined by this instance's size and
aspect ratio functions for this vertex.v
- the vertex for which the shape will be drawnnum_sides
- the number of sides of the polygon; must be ≥ 3.public Shape getRegularStar(V v, int num_points)
Polygon
of num_points
points whose bounding
box's width and height are defined by this instance's size and
aspect ratio functions for this vertex.v
- the vertex for which the shape will be drawnnum_points
- the number of points of the polygon; must be ≥ 5.Copyright © 2015. All rights reserved.