package net.timbusproject.extractors.modules.tavernaextractor.utils;
import uk.ac.bolton.archimate.model.IArchimateElement;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class Container {
public enum Orientation {
VERTICAL, HORIZONTAL;
}
private List<IArchimateElement> elements;
private Point maxExtensions;
public Orientation orientation;
// by default HORIZONTAL
public Container() {
this.orientation = Orientation.HORIZONTAL;
this.elements = new ArrayList<IArchimateElement>();
this.maxExtensions = new Point(150, 150);
}
public Container(Orientation orientation) {
this();
this.orientation = orientation;
}
public void add(IArchimateElement element) {
if (element != null) {
elements.add(element);
resize();
}
}
public List<IArchimateElement> getElements() {
return elements;
}
public IArchimateElement getElementById(String id) {
for (IArchimateElement element : elements) {
if (element.getId().equals(id)) {
return element;
}
}
return null;
}
public Point getContainerExtensions() {
return maxExtensions;
}
public Orientation getOrientation() {
return orientation;
}
private void resize() {
if (orientation == Orientation.HORIZONTAL) {
maxExtensions.x += 100;
} else {
// it is vertical
maxExtensions.y += 100;
}
}
}