Room.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package model;
  2. import config.subConfig.RoomConfig;
  3. import java.awt.*;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. /**
  7. * @author duh
  8. * @create 2018/7/17 16:19
  9. * @email duh@elab-plus.com
  10. **/
  11. public class Room extends ModuleInAxis {
  12. private int length;
  13. private int width;
  14. private int bottomLeft;
  15. private int rightLeft;
  16. private int topLeft;
  17. private int leftLeft;
  18. public Room(){
  19. }
  20. public Room(RoomConfig config) {
  21. this.length = config.getLength();
  22. this.width = config.getWidth();
  23. this.x = config.getX();
  24. this.y = config.getY();
  25. }
  26. @Override
  27. public void drawSelf(Graphics g) {
  28. matchAxis();
  29. Graphics2D g2d = (Graphics2D) g.create();
  30. g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  31. g2d.setColor(Color.GRAY);
  32. // 1. 绘制一个矩形: 起点(30, 20), 宽80, 高100
  33. g2d.drawString(x+","+y,x,y);
  34. g2d.drawRect(x, y-width, length, width);
  35. g2d.dispose();
  36. }
  37. public List<Integer> getRoomLengthLeft(){
  38. List<Integer> roomLength = new ArrayList<>();
  39. roomLength.add(bottomLeft);
  40. roomLength.add(rightLeft);
  41. roomLength.add(topLeft);
  42. roomLength.add(leftLeft);
  43. return roomLength;
  44. }
  45. public int getLength() {
  46. return length;
  47. }
  48. public void setLength(int length) {
  49. this.length = length;
  50. }
  51. public int getWidth() {
  52. return width;
  53. }
  54. public void setWidth(int width) {
  55. this.width = width;
  56. }
  57. public int getBottomLeft() {
  58. return bottomLeft;
  59. }
  60. public void setBottomLeft(int bottomLeft) {
  61. this.bottomLeft = bottomLeft;
  62. }
  63. public int getRightLeft() {
  64. return rightLeft;
  65. }
  66. public void setRightLeft(int rightLeft) {
  67. this.rightLeft = rightLeft;
  68. }
  69. public int getTopLeft() {
  70. return topLeft;
  71. }
  72. public void setTopLeft(int topLeft) {
  73. this.topLeft = topLeft;
  74. }
  75. public int getLeftLeft() {
  76. return leftLeft;
  77. }
  78. public void setLeftLeft(int leftLeft) {
  79. this.leftLeft = leftLeft;
  80. }
  81. }