public class ShapeDrawer
extends java.lang.Object
ShapeDrawer
class is used to draw shapes. It is built so that the
shapes are drawn correctly on the screen, also in case of zooming in. Each
MapComponentView
relies on this class for visualization.Modifier and Type | Field and Description |
---|---|
private static java.awt.Graphics2D |
g2
Graphics.
|
private static double |
pixelRatio
The pixel ratio.
|
private static int |
xOffset
The offset in the x direction.
|
private static int |
yOffset
The offset in the y direction.
|
Modifier | Constructor and Description |
---|---|
private |
ShapeDrawer()
Private class to prevent object creation.
|
Modifier and Type | Method and Description |
---|---|
static void |
drawCircle(java.awt.Color color,
Position position,
double radius)
Draws a circle.
|
static void |
drawLine(java.awt.Color color,
Position start,
Position end)
Draws a line.
|
static void |
drawPath(java.awt.Color color,
Position position,
java.util.List<Position> positions)
Draws a path.
|
static void |
drawPolygon(java.awt.Color color,
java.util.List<Position> positions)
Draws a polygon.
|
static void |
drawRectangle(java.awt.Color color,
Position position,
double width,
double height)
Draws a rectangle.
|
static java.awt.Color |
getComplementaryColor(java.awt.Color color)
Gets the complement of a
Color . |
static java.awt.Rectangle |
getRectangle(Position position,
double width,
double height)
Gets a rectangle that can be used as a bounding box.
|
static void |
updateVariables(java.awt.Graphics2D g2,
double pixelRatio,
int xOffset,
int yOffset)
Updates the variables.
|
private static java.awt.Graphics2D g2
private static double pixelRatio
private static int xOffset
private static int yOffset
public static void drawCircle(java.awt.Color color, Position position, double radius)
color
- The color.position
- The center of the circle.radius
- The radius.public static void drawLine(java.awt.Color color, Position start, Position end)
color
- The color.start
- The start position.end
- The end position.public static void drawPath(java.awt.Color color, Position position, java.util.List<Position> positions)
color
- The color.position
- The start position.positions
- The positions of the path.public static void drawPolygon(java.awt.Color color, java.util.List<Position> positions)
color
- The color.positions
- The corners.public static void drawRectangle(java.awt.Color color, Position position, double width, double height)
color
- The color.position
- The top left position.width
- The width.height
- The height.public static java.awt.Color getComplementaryColor(java.awt.Color color)
Color
.color
- The color.public static java.awt.Rectangle getRectangle(Position position, double width, double height)
position
- The top left position.width
- The width.height
- The height.public static void updateVariables(java.awt.Graphics2D g2, double pixelRatio, int xOffset, int yOffset)
g2
- Graphics.pixelRatio
- Ratio.xOffset
- x offset.yOffset
- y offset.