package model; import config.subConfig.RoomConfig; import java.awt.*; import java.util.ArrayList; import java.util.List; /** * @author duh * @create 2018/7/17 16:19 * @email duh@elab-plus.com **/ public class Room extends ModuleInAxis { private int length; private int width; private int bottomLeft; private int rightLeft; private int topLeft; private int leftLeft; public Room(){ } public Room(RoomConfig config) { this.length = config.getLength(); this.width = config.getWidth(); this.x = config.getX(); this.y = config.getY(); } @Override public void drawSelf(Graphics g) { matchAxis(); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(Color.GRAY); // 1. 绘制一个矩形: 起点(30, 20), 宽80, 高100 g2d.drawString(x+","+y,x,y); g2d.drawRect(x, y-width, length, width); g2d.dispose(); } public List getRoomLengthLeft(){ List roomLength = new ArrayList<>(); roomLength.add(bottomLeft); roomLength.add(rightLeft); roomLength.add(topLeft); roomLength.add(leftLeft); return roomLength; } public int getLength() { return length; } public void setLength(int length) { this.length = length; } public int getWidth() { return width; } public void setWidth(int width) { this.width = width; } public int getBottomLeft() { return bottomLeft; } public void setBottomLeft(int bottomLeft) { this.bottomLeft = bottomLeft; } public int getRightLeft() { return rightLeft; } public void setRightLeft(int rightLeft) { this.rightLeft = rightLeft; } public int getTopLeft() { return topLeft; } public void setTopLeft(int topLeft) { this.topLeft = topLeft; } public int getLeftLeft() { return leftLeft; } public void setLeftLeft(int leftLeft) { this.leftLeft = leftLeft; } }