Class SvgGraphics
- Object
-
- SvgGraphics
-
-
Constructor Summary
Constructors Constructor Description SvgGraphics()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all drawing operations.voiddrawCircle(double x, double y, double radius)Draws the outline of a circle.voiddrawLine(double x1, double y1, double x2, double y2)Draws a line from point (x1,y1) to point (x2,y2).voiddrawPolygon(List<Point> points)Draws the outline of a polygon defined by a list of points.voiddrawRectangle(double x, double y, double width, double height)Draws the outline of a rectangle.voiddrawText(String text, double x, double y)Draws text at the specified position.voidfillCircle(double x, double y, double radius)Fills a circle with the current fill color.voidfillPolygon(List<Point> points)Fills a polygon defined by a list of points with the current fill color.voidfillRectangle(double x, double y, double width, double height)Fills a rectangle with the current fill color.voidsetFillColor(Color color)Sets the color used for filling shapes.voidsetFont(String family, double size)Sets the font used for drawing text.voidsetStrokeColor(Color color)Sets the color used for drawing outlines.voidsetStrokeWidth(double width)Sets the width of the stroke used for drawing outlines.StringtoSvg()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:
drawRectanglein 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:
fillRectanglein 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:
drawCirclein 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:
fillCirclein 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:
drawPolygonin 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:
fillPolygonin 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:
setStrokeColorin 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:
setFillColorin 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:
setStrokeWidthin interfaceIGraphics- Parameters:
width- The width of the stroke.
-
setFont
public void setFont(String family, double size)Sets the font used for drawing text.
-
toSvg
public String toSvg()
Generates the SVG representation of all drawing operations.
-
-