View Javadoc

1   package org.kite9.diagram.adl;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.kite9.diagram.position.Direction;
7   import org.kite9.diagram.primitives.AbstractContainer;
8   import org.kite9.diagram.primitives.Contained;
9   import org.kite9.diagram.primitives.Container;
10  import org.kite9.diagram.primitives.Label;
11  
12  import com.thoughtworks.xstream.annotations.XStreamAlias;
13  import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
14  import com.thoughtworks.xstream.annotations.XStreamOmitField;
15  
16  
17  /***
18   * A context is a portion of the diagram with a border around it, and a label.  
19   * It contains other Glyphs or context to give the diagram a hierarchy.
20   * 
21   * @author robmoffat
22   *
23   */
24  @XStreamAlias("context")
25  public class Context extends AbstractContainer implements Contained {
26  	
27  	@Override
28  	public String toString() {
29  		return "[C:"+getID()+"]";
30  	}
31  
32  	private static final long serialVersionUID = -311300007972605832L;
33  	
34  	@XStreamOmitField
35  	private Container container;
36  	
37  	
38  	@XStreamAsAttribute
39  	private boolean bordered = false;
40  
41  	public Context() {
42  	}
43  	
44  	public Context(List<Contained> contents, boolean bordered, Label label, Direction layoutDirection) {
45  		super(createID(), contents==null ? new ArrayList<Contained>() : contents, layoutDirection, label);	
46  		this.bordered = bordered;
47  	}
48  	
49  	public Context(String id, List<Contained> contents, boolean bordered, Label label, Direction layoutDirection) {
50  		super(id, contents==null ? new ArrayList<Contained>() : contents, layoutDirection, label);
51  		this.bordered = bordered;
52  	}
53  	
54  	@Deprecated
55  	public Context(String id, List<Contained> contents, boolean bordered, Direction layoutDirection, String label) {
56  		super(id, contents==null ? new ArrayList<Contained>() : contents, layoutDirection, label != null ? new TextLine(label) : null);
57  		this.bordered = bordered;
58  	}
59  	
60  	@Deprecated
61  	public Context(String id, List<Contained> contents, boolean bordered) {
62  		super(id, contents, null, null);
63  		this.bordered = bordered;
64  	}
65  	
66  	
67  
68  	public boolean isBordered() {
69  		return bordered;
70  	}
71  
72  	public void setBordered(boolean bordered) {
73  		this.bordered = bordered;
74  	}
75  
76  	public Container getContainer() {
77  		return container;
78  	}
79  
80  	public void setContainer(Container c) {
81  		this.container =  c;
82  	}
83  	
84  	
85  }