Ejemplo n.º 1
0
        private ActiveNode TryBreakHere(
            IParagraphModel <TLine, TState> paragraph, IFrameModel frame,
            IBreakPoint breakPoint, ActiveNode prevNode,
            out bool doDeactivate)
        {
            var nextLineNumber = prevNode.LineNumber + 1;
            var suitableLength = frame.LengthOf(nextLineNumber);
            var constraint     = new LineConstraint {
                SuitableLength = suitableLength
            };
            var    newStyle = new TState();
            var    line     = paragraph.CreateLine(constraint, prevNode.Point, breakPoint, prevNode.Style, out newStyle);
            double ratio    = _evaluator.ComputeAdjustmentRatio(line, suitableLength);

            doDeactivate = (ratio < -1 || _evaluator.IsForcedBreakPoint(breakPoint));

            if (-1 <= ratio && ratio <= _tolerance)
            {
                var fitnessClass     = _evaluator.ComputeFitnessClass(ratio);
                var prevIsFlagged    = prevNode.Point.IsFlagged;
                var prevFitnessClass = prevNode.FitnessClass;
                var demerits         = _evaluator.ComputeDemerits(breakPoint, ratio, fitnessClass, prevIsFlagged, prevFitnessClass);
                return(ActiveNode.CreateBreakNode(breakPoint, line, fitnessClass, newStyle, ratio, demerits, prevNode));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        private static IUnjustifiedLine <TLine> ForceLayoutInOneLine(IParagraphModel <TLine, TState> paragraph, IFrameModel frame)
        {
            var length     = frame.LengthOf(1);
            var constraint = new LineConstraint {
                SuitableLength = length
            };
            var style           = new TState();
            var ignore          = new TState();
            var unjustifiedLine = paragraph.CreateLine(constraint, paragraph.StartPoint, paragraph.EndPoint, style, out ignore);

            return(unjustifiedLine);
        }