1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package com.its.vms.domain;
- import lombok.Data;
- import java.io.Serializable;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * DTO Class
- */
- @Data
- public class VmsFormManager implements Serializable {
- private static final long serialVersionUID = 1L;
- private int formWidth;
- private int formHeight;
- private int totalCount;
- private int objectCount;
- private List<VmsForm> objects;
- public VmsFormManager(int formWidth, int formHeight) {
- this.formWidth = formWidth;
- this.formHeight = formHeight;
- this.totalCount = 0;
- this.objectCount = 0;
- this.objects = new ArrayList<>();
- }
- public void clear() {
- this.objectCount = 0;
- this.objects.forEach(obj -> {
- obj.clear();
- });
- }
- public VmsForm getItem(int idx) {
- if (this.objects.size() > idx) {
- return this.objects.get(idx);
- }
- return null;
- }
- public int addForm(VmsForm form) {
- this.objects.add(form);
- this.objectCount = this.objects.size();
- return this.objectCount;
- }
- public VmsForm addForm() {
- VmsForm form = null;
- if (this.objectCount < this.totalCount) {
- form = getItem(this.objectCount);
- }
- else {
- form = new VmsForm();
- form.init(this.formWidth, this.formHeight);
- this.objects.add(form);
- this.totalCount++;
- }
- this.objectCount++;
- return form;
- }
- public int count() { return this.objectCount; }
- public int total() { return this.totalCount; }
- }
|