Parent: [d0e47c] (diff)

Download this file

Container.java    68 lines (54 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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;
}
}
}