Beispiel #1
0
        public double ComputeAdjustmentRatio(IUnjustifiedLine <TJustifiedLine> line, double requiredLength)
        {
            double underLength = requiredLength - line.TotalLength;

            if (underLength > 0)
            {
                var stretch = line.TotalStretch;
                if (stretch > 0)
                {
                    return(underLength / stretch);
                }
                else
                {
                    return(Constants.RatioInfinity);
                }
            }
            else if (underLength < 0)
            {
                var shrink = line.TotalShrink;
                if (shrink > 0)
                {
                    return((double)underLength / (double)shrink);
                }
                else
                {
                    return(Constants.RatioInfinity);
                }
            }
            else
            {
                return(0);
            }
        }
Beispiel #2
0
 public static ActiveNode CreateBreakNode(IBreakPoint here, IUnjustifiedLine <TLine> lineBeforeHere, FitnessClass fitnessClass, TState style, double ratio, double demerits, ActiveNode prevNode)
 {
     return(new ActiveNode
     {
         Point = here,
         FitnessClass = fitnessClass,
         Style = style,
         Ratio = ratio,
         TotalDemerits = demerits + prevNode.TotalDemerits,
         LineNumber = prevNode.LineNumber + 1,
         PrevNode = prevNode,
         LineBeforeHere = lineBeforeHere
     });
 }