类 JSONExportVisitor
java.lang.Object
com.example.renderer.visitor.JSONExportVisitor
- 所有已实现的接口:
ExportVisitor
JSON导出访问者实现类
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
将圆形对象转换为JSON格式输出 格式: {"type":"circle", "x":x, "y":y, "r":radius}void
将椭圆对象转换为JSON格式输出 格式: {"type":"ellipse", "x":x, "y":y, "rx":xRadius, "ry":yRadius}void
将矩形对象转换为JSON格式输出 格式: {"type":"rectangle", "x":x, "y":y, "w":width, "h":height}void
将三角形对象转换为JSON格式输出 格式: {"type":"triangle", "x1":x1, "y1":y1, ..., "y3":y3}
-
构造器详细资料
-
JSONExportVisitor
public JSONExportVisitor()
-
-
方法详细资料
-
visitCircle
将圆形对象转换为JSON格式输出 格式: {"type":"circle", "x":x, "y":y, "r":radius}- 指定者:
visitCircle
在接口中ExportVisitor
- 参数:
c
- 要导出的圆形对象,不能为null- 抛出:
NullPointerException
- 如果参数c为nullIllegalArgumentException
- 如果半径值为负数
-
visitRectangle
将矩形对象转换为JSON格式输出 格式: {"type":"rectangle", "x":x, "y":y, "w":width, "h":height}- 指定者:
visitRectangle
在接口中ExportVisitor
- 参数:
r
- 要导出的矩形对象,不能为null- 抛出:
NullPointerException
- 如果参数r为nullIllegalArgumentException
- 如果宽度或高度为负数
-
visitEllipse
将椭圆对象转换为JSON格式输出 格式: {"type":"ellipse", "x":x, "y":y, "rx":xRadius, "ry":yRadius}- 指定者:
visitEllipse
在接口中ExportVisitor
- 参数:
e
- 要导出的椭圆对象,不能为null- 抛出:
NullPointerException
- 如果参数e为nullIllegalArgumentException
- 如果宽度或高度为负数
-
visitTriangle
将三角形对象转换为JSON格式输出 格式: {"type":"triangle", "x1":x1, "y1":y1, ..., "y3":y3}- 指定者:
visitTriangle
在接口中ExportVisitor
- 参数:
t
- 要导出的三角形对象,不能为null- 抛出:
NullPointerException
- 如果参数t为null
-