コード例 #1
0
        /// <summary>
        /// Initialize state, including fChars array, direction, and
        /// fBidi.
        /// </summary>
        private void InitAll(AttributedCharacterIterator text)
        {
            FStart = text.BeginIndex;

            // extract chars
            FChars = new char[text.EndIndex - FStart];

            int n = 0;

            for (char c = text.First(); c != java.text.CharacterIterator_Fields.DONE; c = text.Next())
            {
                FChars[n++] = c;
            }

            text.First();

            FBidi = new Bidi(text);
            if (FBidi.LeftToRight)
            {
                FBidi = null;
            }

            text.First();
//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
//ORIGINAL LINE: java.util.Map<? extends java.text.AttributedCharacterIterator_Attribute, ?> paragraphAttrs = text.getAttributes();
            IDictionary <?, ?> paragraphAttrs = text.Attributes;
            NumericShaper      shaper         = AttributeValues.getNumericShaping(paragraphAttrs);

            if (shaper != null)
            {
                shaper.Shape(FChars, 0, FChars.Length);
            }

            FParagraph = new StyledParagraph(text, FChars);

            {
                // set paragraph attributes
                // If there's an embedded graphic at the start of the
                // paragraph, look for the first non-graphic character
                // and use it and its font to initialize the paragraph.
                // If not, use the first graphic to initialize.
                FJustifyRatio = AttributeValues.getJustification(paragraphAttrs);

                bool haveFont = TextLine.AdvanceToFirstFont(text);

                if (haveFont)
                {
                    Font        defaultFont = TextLine.GetFontAtCurrentPos(text);
                    int         charsStart  = text.Index - text.BeginIndex;
                    LineMetrics lm          = defaultFont.GetLineMetrics(FChars, charsStart, charsStart + 1, FFrc);
                    FBaseline        = (sbyte)lm.BaselineIndex;
                    FBaselineOffsets = lm.BaselineOffsets;
                }
                else
                {
                    // hmmm what to do here?  Just try to supply reasonable
                    // values I guess.

                    GraphicAttribute graphic = (GraphicAttribute)paragraphAttrs[TextAttribute.CHAR_REPLACEMENT];
                    FBaseline = TextLayout.GetBaselineFromGraphic(graphic);
//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
//ORIGINAL LINE: java.util.Hashtable<java.text.AttributedCharacterIterator_Attribute, ?> fmap = new java.util.Hashtable<>(5, (float)0.9);
                    Dictionary <AttributedCharacterIterator_Attribute, ?> fmap = new Dictionary <AttributedCharacterIterator_Attribute, ?>(5, (float)0.9);
                    Font        dummyFont = new Font(fmap);
                    LineMetrics lm        = dummyFont.GetLineMetrics(" ", 0, 1, FFrc);
                    FBaselineOffsets = lm.BaselineOffsets;
                }
                FBaselineOffsets = TextLine.GetNormalizedOffsets(FBaselineOffsets, FBaseline);
            }

            InvalidateComponents();
        }