001: package visualdebugger.draw2d;
002:
003: import java.util.Iterator;
004: import java.util.LinkedList;
005:
006: import org.eclipse.draw2d.Connection;
007: import org.eclipse.draw2d.IFigure;
008: import org.eclipse.draw2d.geometry.Transposer;
009:
010: public class TreeRoot extends TreeBranch {
011:
012: private int major = 100;
013: private Transposer transposer = new Transposer();
014: private int minor = 100;
015: private LinkedList labels = new LinkedList();
016:
017: public void setHorizontal(boolean value) {
018: transposer.setEnabled(!value);
019: invalidateTree();
020: revalidate();
021: }
022:
023: /**
024: * @param title
025: */
026: public TreeRoot(IFigure title) {
027: super (title, null);
028: }
029:
030: public int getMajorSpacing() {
031: return major;
032: }
033:
034: public void addLabel(Connection con) {
035: labels.add(con);
036: add(con);
037: }
038:
039: public void removeLabels() {
040: Iterator it = labels.iterator();
041: while (it.hasNext()) {
042: remove((Connection) it.next());
043: }
044: labels.clear();
045: }
046:
047: public boolean containsPoint(int x, int y) {
048: if (node.containsPoint(x, y) || contents.containsPoint(x, y))
049: return true;
050: Iterator it = labels.iterator();
051: while (it.hasNext()) {
052: if (((Connection) it.next()).containsPoint(x, y))
053: return true;
054: }
055:
056: return false;
057: }
058:
059: /**
060: * @return
061: */
062: public int getMinorSpacing() {
063: return minor;
064: }
065:
066: public TreeRoot getRoot() {
067: return this ;
068: }
069:
070: /**
071: * sets the space (in pixels) between this branch's node and its subtrees.
072: */
073: public void setMajorSpacing(int value) {
074: this .major = value;
075: invalidateTree();
076: revalidate();
077: }
078:
079: public Transposer getTransposer() {
080: return transposer;
081: }
082:
083: public boolean isHorizontal() {
084: return !transposer.isEnabled();
085: }
086:
087: /**
088: * @param i
089: */
090: public void setMinorSpacing(int i) {
091: minor = i;
092: invalidateTree();
093: revalidate();
094: }
095:
096: /**
097: * @see org.eclipse.draw2d.Figure#validate()
098: */
099:
100: public void validate() {
101: if (isValid())
102: return;
103: setRowHeights(getPreferredRowHeights(), 0);
104: super.validate();
105: }
106:
107: }
|