public Columns CalculateColumns() { Columns columns = new Columns(); Column lastColumn = null; Offset lastOffset = Offset.Zero; int count = _members.Count; for (int i = 0; i < count; i++) { Offset thisOffset = this[i].TopOffset; if (thisOffset.IsLessThanOrEqualTo(lastOffset)) { if (lastColumn != null) { lastColumn.SetEnd(i); } Column col = new Column(this, i); columns.Add(col); lastColumn = col; } lastOffset = thisOffset; } lastColumn.SetEnd(count); return columns; }
public void Adjoin(Column column, out Column resetted) { if (_stack.Count == 0) { _stack.Push(column); resetted = null; return; } Column newColumn = column; Column curColumn; for (; ; ) { // 在找到被重置的列之前,堆栈不可能被挖空 // 最糟糕的情况,就是被重置的列正好是最底一列 curColumn = _stack.Peek(); if (curColumn.IsAbove(newColumn)) { resetted = curColumn; _stack.Push(newColumn); return; } if (curColumn.IsParallelTo(newColumn)) { resetted = curColumn; _stack.Pop(); _stack.Push(newColumn); return; } _stack.Pop(); } }
public bool IsParallelTo(Column o) { return this.TopOffset.IsEqualTo(o.TopOffset); }
public void PushResetter(Column resetter) { _resetters.Add(resetter); }
public bool IsAbove(Column o) { return this.TopOffset.IsLessThan(o.TopOffset); }