View Javadoc

1   package org.kite9.diagram.primitives;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.kite9.diagram.position.Direction;
7   import org.kite9.diagram.position.RouteRenderingInformation;
8   
9   import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
10  import com.thoughtworks.xstream.annotations.XStreamImplicit;
11  
12  public abstract class AbstractContainer extends AbstractConnectedContained implements Container {
13  
14  	public Label getLabel() {
15  		return label;
16  	}
17  
18  	public RouteRenderingInformation getRenderingInformation() {
19  		if (renderingInformation==null) {
20  			renderingInformation = new RouteRenderingInformation();
21  		}
22  		
23  		return (RouteRenderingInformation) renderingInformation;
24  	}
25  
26  	private static final long serialVersionUID = 9108816802892206563L;
27  
28  	@XStreamImplicit
29  	private List<Contained> contents = new ArrayList<Contained>();
30  	
31  	@XStreamAsAttribute
32  	private Direction layout = null;
33  	
34  	@XStreamAsAttribute
35  	protected Label label = null;
36  
37  	public List<Contained> getContents() {
38  		return contents;
39  	}
40  
41  	public AbstractContainer() {
42  	}
43  	
44  	public AbstractContainer(String id, List<Contained> contents, Direction d, Label label) {
45  		super(id);
46  		this.contents = contents;
47  		for (Contained c : contents) {
48  			c.setContainer(this);
49  		}
50  		
51  		this.layout = d;
52  		if (label!=null) { 
53  			this.label = label;
54  			label.setParent(this);
55  		}
56  	}
57  
58  	public Direction getLayoutDirection() {
59  		return layout;
60  	}
61  
62  	public void setLayoutDirection(Direction layout) {
63  	    this.layout = layout;
64  	}
65  
66  	public void setLabel(Label label) {
67  	    this.label = label;
68  	    label.setParent(this);
69  	}
70  }