Class SvgGraphics
- Object
-
- SvgGraphics
-
-
Constructor Summary
Constructors Constructor Description SvgGraphics()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears all drawing operations.void
drawCircle(double x, double y, double radius)
Draws the outline of a circle.void
drawLine(double x1, double y1, double x2, double y2)
Draws a line from point (x1,y1) to point (x2,y2).void
drawPolygon(List<Point> points)
Draws the outline of a polygon defined by a list of points.void
drawRectangle(double x, double y, double width, double height)
Draws the outline of a rectangle.void
drawText(String text, double x, double y)
Draws text at the specified position.void
fillCircle(double x, double y, double radius)
Fills a circle with the current fill color.void
fillPolygon(List<Point> points)
Fills a polygon defined by a list of points with the current fill color.void
fillRectangle(double x, double y, double width, double height)
Fills a rectangle with the current fill color.void
setFillColor(Color color)
Sets the color used for filling shapes.void
setFont(String fontFamily, double fontSize)
Sets the font used for drawing text.void
setStrokeColor(Color color)
Sets the color used for drawing outlines.void
setStrokeWidth(double width)
Sets the width of the stroke used for drawing outlines.String
toSvg()
Generates the SVG representation of all drawing operations.
-
-
-
Method Detail
-
drawLine
public void drawLine(double x1, double y1, double x2, double y2)
Draws a line from point (x1,y1) to point (x2,y2).
-
drawRectangle
public void drawRectangle(double x, double y, double width, double height)
Draws the outline of a rectangle.- Specified by:
drawRectangle
in interfaceIGraphics
- Parameters:
x
- The x coordinate of the upper-left corner of the rectangle.y
- The y coordinate of the upper-left corner of the rectangle.width
- The width of the rectangle.height
- The height of the rectangle.
-
fillRectangle
public void fillRectangle(double x, double y, double width, double height)
Fills a rectangle with the current fill color.- Specified by:
fillRectangle
in interfaceIGraphics
- Parameters:
x
- The x coordinate of the upper-left corner of the rectangle.y
- The y coordinate of the upper-left corner of the rectangle.width
- The width of the rectangle.height
- The height of the rectangle.
-
drawCircle
public void drawCircle(double x, double y, double radius)
Draws the outline of a circle.- Specified by:
drawCircle
in interfaceIGraphics
- Parameters:
x
- The x coordinate of the center of the circle.y
- The y coordinate of the center of the circle.radius
- The radius of the circle.
-
fillCircle
public void fillCircle(double x, double y, double radius)
Fills a circle with the current fill color.- Specified by:
fillCircle
in interfaceIGraphics
- Parameters:
x
- The x coordinate of the center of the circle.y
- The y coordinate of the center of the circle.radius
- The radius of the circle.
-
drawPolygon
public void drawPolygon(List<Point> points)
Draws the outline of a polygon defined by a list of points.- Specified by:
drawPolygon
in interfaceIGraphics
- Parameters:
points
- List of points defining the polygon.
-
fillPolygon
public void fillPolygon(List<Point> points)
Fills a polygon defined by a list of points with the current fill color.- Specified by:
fillPolygon
in interfaceIGraphics
- Parameters:
points
- List of points defining the polygon.
-
drawText
public void drawText(String text, double x, double y)
Draws text at the specified position.
-
setStrokeColor
public void setStrokeColor(Color color)
Sets the color used for drawing outlines.- Specified by:
setStrokeColor
in interfaceIGraphics
- Parameters:
color
- The color to use for drawing outlines.
-
setFillColor
public void setFillColor(Color color)
Sets the color used for filling shapes.- Specified by:
setFillColor
in interfaceIGraphics
- Parameters:
color
- The color to use for filling shapes.
-
setStrokeWidth
public void setStrokeWidth(double width)
Sets the width of the stroke used for drawing outlines.- Specified by:
setStrokeWidth
in interfaceIGraphics
- Parameters:
width
- The width of the stroke.
-
setFont
public void setFont(String fontFamily, double fontSize)
Sets the font used for drawing text.
-
toSvg
public String toSvg()
Generates the SVG representation of all drawing operations.
-
-