DxfText.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.fdkankan.dxf.generate.model;
  2. import com.fdkankan.dxf.generate.Vector3;
  3. import com.fdkankan.dxf.generate.model.base.BaseDxfEntity;
  4. import com.fdkankan.dxf.generate.util.DxfLineBuilder;
  5. import lombok.Getter;
  6. import lombok.Setter;
  7. /**
  8. * 文字
  9. *
  10. * @author YTZJJ
  11. */
  12. @Getter
  13. @Setter
  14. public class DxfText extends BaseDxfEntity {
  15. /**
  16. * 不翻转
  17. */
  18. public static final int REVERSE_TYPE_NONE = 0;
  19. /**
  20. * 沿X轴方向镜像翻转
  21. */
  22. public static final int REVERSE_TYPE_X = 2;
  23. /**
  24. * 沿Y轴方向镜像翻转
  25. */
  26. public static final int REVERSE_TYPE_Y = 4;
  27. // public static final int ALIGN_HORIZONTAL_LEFT = 0;
  28. // public static final int ALIGN_HORIZONTAL_CENTER = 1;
  29. // public static final int ALIGN_HORIZONTAL_RIGHT = 2;
  30. // public static final int ALIGN_VERTICAL_BASE_LINE = 0;
  31. // public static final int ALIGN_VERTICAL_BASE_BOTTOM = 1;
  32. // public static final int ALIGN_VERTICAL_BASE_CENTER = 2;
  33. // public static final int ALIGN_VERTICAL_BASE_TOP = 3;
  34. /**
  35. * 文字的起始位置
  36. */
  37. private Vector3 startPoint;
  38. /**
  39. * 文字的高度
  40. */
  41. private double high = 0;
  42. /**
  43. * 文字的宽度
  44. */
  45. private int width = 1;
  46. /**
  47. * 文字内容
  48. */
  49. private String text;
  50. /**
  51. * 旋转角度
  52. */
  53. private double angle = 0;
  54. /**
  55. * 倾斜角度
  56. */
  57. private double inclination = 0;
  58. // private String textStyle = "标准";
  59. private int reverseType = REVERSE_TYPE_NONE;
  60. // 暂时不使用这两个属性
  61. // private int alignHorizontal = ALIGN_HORIZONTAL_LEFT;
  62. // private int alignVertical = ALIGN_VERTICAL_BASE_LINE;
  63. // 这个值暂时也没用,只有当上面两个属性使用的时候这个值才有使用的必要
  64. // private Vector3 endPoint;
  65. @Override
  66. protected String getChildDxfStr() {
  67. DxfLineBuilder lineBuilder = DxfLineBuilder.build().append(10, startPoint.getX()).append(20, startPoint.getY()).append(30, startPoint.getZ()).append(40, high).append(1, text);
  68. if (angle != 0) {
  69. lineBuilder.append(50, angle);
  70. }
  71. if (width != 1) {
  72. lineBuilder.append(41, width);
  73. }
  74. if (inclination != 0) {
  75. lineBuilder.append(51, inclination);
  76. }
  77. if (reverseType != REVERSE_TYPE_NONE) {
  78. lineBuilder.append(71, reverseType);
  79. }
  80. lineBuilder.append(100, getEntityClassName());
  81. return lineBuilder.toString();
  82. }
  83. @Override
  84. public String getEntityName() {
  85. return "TEXT";
  86. }
  87. @Override
  88. public String getEntityClassName() {
  89. return "AcDbText";
  90. }
  91. }