Beispiel #1
0
        public LineBreaking.IUnjustifiedLine <Printing.IPrintableLine> CreateLine(LineBreaking.ILineConstraint constraint, InlineStyle style, LineBreaking.IBreakPoint from, LineBreaking.IBreakPoint to, out InlineStyle newStyle)
        {
            IInterletter     fromAsJapaneseInterletterspace;
            IInterletter     toAsJapaneseInterletterspace;
            StartOfParagraph fromAsStart;
            EndOfParagraph   toAsEnd;

            fromAsJapaneseInterletterspace = from as IInterletter;
            toAsJapaneseInterletterspace   = to as IInterletter;
            if (fromAsJapaneseInterletterspace != null)
            {
                if (toAsJapaneseInterletterspace != null)
                {
                    return(CreateLine(constraint, fromAsJapaneseInterletterspace, toAsJapaneseInterletterspace, style, out newStyle));
                }
                else
                {
                    toAsEnd = to as EndOfParagraph;
                    if (toAsEnd != null)
                    {
                        return(CreateLine(constraint, fromAsJapaneseInterletterspace, toAsEnd, style, out newStyle));
                    }
                    else
                    {
                        throw new ArgumentException("type error", "to");
                    }
                }
            }
            else
            {
                fromAsStart = from as StartOfParagraph;
                if (fromAsStart != null)
                {
                    if (toAsJapaneseInterletterspace != null)
                    {
                        return(CreateLine(constraint, fromAsStart, toAsJapaneseInterletterspace, style, out newStyle));
                    }
                    else
                    {
                        toAsEnd = to as EndOfParagraph;
                        if (toAsEnd != null)
                        {
                            return(CreateLine(constraint, fromAsStart, toAsEnd, style, out newStyle));
                        }
                        else
                        {
                            throw new ArgumentException("type error", "to");
                        }
                    }
                }
                else
                {
                    throw new ArgumentException("type error", "start");
                }
            }
        }
Beispiel #2
0
        private LineBreaking.IUnjustifiedLine <Printing.IPrintableLine> CreateLine(LineBreaking.ILineConstraint constraint, StartOfParagraph from, IInterletter to, InlineStyle style, out InlineStyle newStyle)
        {
            var toIndex = Array.IndexOf(_objectList, to);

            if (toIndex == -1)
            {
                throw new ArgumentException("to");
            }
            return(InlineLayoutEngine.Solve(constraint, from.Glue, _objectList.Take(toIndex), to.GlueBeforeBreak, PenaltyValue(to), _heading, style, out newStyle));
        }
Beispiel #3
0
        private LineBreaking.IUnjustifiedLine <Printing.IPrintableLine> CreateLine(LineBreaking.ILineConstraint constraint, IInterletter from, EndOfParagraph to, InlineStyle style, out InlineStyle newStyle)
        {
            var fromIndex = Array.IndexOf(_objectList, from);

            if (fromIndex == -1)
            {
                throw new ArgumentException("from");
            }
            return(InlineLayoutEngine.Solve(
                       constraint,
                       new GlueProperty(from.IndentAfterBreak, 0, 0),
                       _objectList.Skip(fromIndex + 1), to.Glue, PenaltyValue(to), _heading, style, out newStyle));
        }
Beispiel #4
0
        public static UnjustifiedLine Solve(
            LineBreaking.ILineConstraint constraint,
            GlueProperty startGlue,
            IEnumerable <IFormatObject> objectList,
            GlueProperty endGlue,
            float penaltyValue,
            Heading heading,
            InlineStyle style,
            out InlineStyle newStyle)
        {
            IFragment[] fragments          = ConvertToFragments(ref startGlue, objectList, ref endGlue, style, out newStyle);
            var         rubyLayoutedBuffer = LayoutRubyInLine(constraint, fragments, endGlue.Length);

            return(new UnjustifiedLine(rubyLayoutedBuffer, penaltyValue, heading));
        }
Beispiel #5
0
        private static IFragment[] LayoutRubyInLine(
            LineBreaking.ILineConstraint constraint, IFragment[] fragmentList, float endSpaceLength)
        {
            //TODO: constraint を考慮して最適なものを選ぶ
            IFragment[] layouted = new IFragment[fragmentList.Length];
            var         n        = fragmentList.Length;

            for (int i = 0; i < n; ++i)
            {
                IFragment current = fragmentList[i];
                IAdjacentableToFragment before = (i > 0 ? fragmentList[i - 1] : DenyRubyHanging.theInstance);
                IAdjacentableToFragment after  = (i < n - 1 ? fragmentList[i + 1] : DenyRubyHanging.theInstance);
                layouted[i] = current.LayoutRuby(before, after);
            }
            return(layouted);
        }
Beispiel #6
0
        LineBreaking.IUnjustifiedLine <Printing.IPrintableLine> LineBreaking.IParagraphModel <Printing.IPrintableLine, InlineStyle> .CreateLine(LineBreaking.ILineConstraint constraint, LineBreaking.IBreakPoint from, LineBreaking.IBreakPoint to, InlineStyle style, out InlineStyle newStyle)
        {
            var factory = new UnjustifiedLineBuilder(_objectList, _heading);

            return(factory.CreateLine(constraint, style, from, to, out newStyle));
        }
Beispiel #7
0
 private LineBreaking.IUnjustifiedLine <Printing.IPrintableLine> CreateLine(LineBreaking.ILineConstraint constraint, StartOfParagraph from, EndOfParagraph to, InlineStyle style, out InlineStyle newStyle)
 {
     return(InlineLayoutEngine.Solve(constraint, from.Glue, _objectList, to.Glue, PenaltyValue(to), _heading, style, out newStyle));
 }