Class VertexShapeFactory<V>
java.lang.Object
edu.uci.ics.jung.visualization.util.VertexShapeFactory<V>
A utility class for generating
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Ellipse2D
private static final GeneralPath
private static final Rectangle2D
private static final RoundRectangle2D
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aVertexShapeFactory
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. -
Method Summary
Modifier and TypeMethodDescriptiongetEllipse
(V v) Returns aEllipse2D
whose width and height are defined by this instance's size and aspect ratio functions for this vertex.getRectangle
(V v) Returns aRectangle2D
whose width and height are defined by this instance's size and aspect ratio functions for this vertex.getRegularPolygon
(V v, int num_sides) Returns a regularnum_sides
-sidedPolygon
whose bounding box's width and height are defined by this instance's size and aspect ratio functions for this vertex.getRegularStar
(V v, int num_points) Returns a regularPolygon
ofnum_points
points whose bounding box's width and height are defined by this instance's size and aspect ratio functions for this vertex.Returns aRoundRectangle2D
whose width and height are defined by this instance's size and aspect ratio functions for this vertex.
-
Field Details
-
vsf
-
varf
-
theRectangle
-
theEllipse
-
theRoundRectangle
-
thePolygon
-
-
Constructor Details
-
VertexShapeFactory
public 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.- Parameters:
vsf
- provides a size (width) for each vertexvarf
- provides a height/width ratio for each vertex
-
VertexShapeFactory
public VertexShapeFactory()Creates aVertexShapeFactory
with a constant size of 10 and a constant aspect ratio of 1.
-
-
Method Details
-
getRectangle
Returns aRectangle2D
whose width and height are defined by this instance's size and aspect ratio functions for this vertex.- Parameters:
v
- the vertex for which the shape will be drawn- Returns:
- a rectangle for this vertex
-
getEllipse
Returns aEllipse2D
whose width and height are defined by this instance's size and aspect ratio functions for this vertex.- Parameters:
v
- the vertex for which the shape will be drawn- Returns:
- an ellipse for this vertex
-
getRoundRectangle
Returns aRoundRectangle2D
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.- Parameters:
v
- the vertex for which the shape will be drawn- Returns:
- an round rectangle for this vertex
-
getRegularPolygon
Returns a regularnum_sides
-sidedPolygon
whose bounding box's width and height are defined by this instance's size and aspect ratio functions for this vertex.- Parameters:
v
- the vertex for which the shape will be drawnnum_sides
- the number of sides of the polygon; must be ≥ 3.- Returns:
- a regular polygon for this vertex
-
getRegularStar
Returns a regularPolygon
ofnum_points
points whose bounding box's width and height are defined by this instance's size and aspect ratio functions for this vertex.- Parameters:
v
- the vertex for which the shape will be drawnnum_points
- the number of points of the polygon; must be ≥ 5.- Returns:
- an star shape for this vertex
-