类 JSONExportVisitor

java.lang.Object
com.example.renderer.visitor.JSONExportVisitor
所有已实现的接口:
ExportVisitor

public class JSONExportVisitor extends Object implements ExportVisitor
JSON导出访问者实现类
  • 构造器详细资料

    • JSONExportVisitor

      public JSONExportVisitor()
  • 方法详细资料

    • visitCircle

      public void visitCircle(Circle c)
      将圆形对象转换为JSON格式输出 格式: {"type":"circle", "x":x, "y":y, "r":radius}
      指定者:
      visitCircle 在接口中 ExportVisitor
      参数:
      c - 要导出的圆形对象,不能为null
      抛出:
      NullPointerException - 如果参数c为null
      IllegalArgumentException - 如果半径值为负数
    • visitRectangle

      public void visitRectangle(Rectangle r)
      将矩形对象转换为JSON格式输出 格式: {"type":"rectangle", "x":x, "y":y, "w":width, "h":height}
      指定者:
      visitRectangle 在接口中 ExportVisitor
      参数:
      r - 要导出的矩形对象,不能为null
      抛出:
      NullPointerException - 如果参数r为null
      IllegalArgumentException - 如果宽度或高度为负数
    • visitEllipse

      public void visitEllipse(Ellipse e)
      将椭圆对象转换为JSON格式输出 格式: {"type":"ellipse", "x":x, "y":y, "rx":xRadius, "ry":yRadius}
      指定者:
      visitEllipse 在接口中 ExportVisitor
      参数:
      e - 要导出的椭圆对象,不能为null
      抛出:
      NullPointerException - 如果参数e为null
      IllegalArgumentException - 如果宽度或高度为负数
    • visitTriangle

      public void visitTriangle(Triangle t)
      将三角形对象转换为JSON格式输出 格式: {"type":"triangle", "x1":x1, "y1":y1, ..., "y3":y3}
      指定者:
      visitTriangle 在接口中 ExportVisitor
      参数:
      t - 要导出的三角形对象,不能为null
      抛出:
      NullPointerException - 如果参数t为null