/// <summary> /// Resolve the given chars into Fonts using FontResolver, then add /// font runs for each. /// </summary> private void addFonts <T1>(char[] chars, IDictionary <T1> attributes, int start, int limit) where T1 : java.text.AttributedCharacterIterator_Attribute { FontResolver resolver = FontResolver.Instance; CodePointIterator iter = CodePointIterator.create(chars, start, limit); for (int runStart = iter.charIndex(); runStart < limit; runStart = iter.charIndex()) { int fontIndex = resolver.nextFontRunIndex(iter); AddFont(resolver.getFont(fontIndex, attributes), runStart); } }
/// <summary> /// Return a StyledParagraph reflecting the insertion of a single character /// into the text. This method will attempt to reuse the given paragraph, /// but may create a new paragraph. </summary> /// <param name="aci"> an iterator over the text. The text should be the same as the /// text used to create (or most recently update) oldParagraph, with /// the exception of inserting a single character at insertPos. </param> /// <param name="chars"> the characters in aci </param> /// <param name="insertPos"> the index of the new character in aci </param> /// <param name="oldParagraph"> a StyledParagraph for the text in aci before the /// insertion </param> public static StyledParagraph InsertChar(AttributedCharacterIterator aci, char[] chars, int insertPos, StyledParagraph oldParagraph) { // If the styles at insertPos match those at insertPos-1, // oldParagraph will be reused. Otherwise we create a new // paragraph. char ch = aci.setIndex(insertPos); int relativePos = System.Math.Max(insertPos - aci.BeginIndex - 1, 0); //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: java.util.Map<? extends java.text.AttributedCharacterIterator_Attribute, ?> attributes = addInputMethodAttrs(aci.getAttributes()); IDictionary <?, ?> attributes = AddInputMethodAttrs(aci.Attributes); Decoration d = Decoration.getDecoration(attributes); if (!oldParagraph.GetDecorationAt(relativePos).Equals(d)) { return(new StyledParagraph(aci, chars)); } Object f = GetGraphicOrFont(attributes); if (f == null) { FontResolver resolver = FontResolver.Instance; int fontIndex = resolver.getFontIndex(ch); f = resolver.getFont(fontIndex, attributes); } if (!oldParagraph.GetFontOrGraphicAt(relativePos).Equals(f)) { return(new StyledParagraph(aci, chars)); } // insert into existing paragraph oldParagraph.Length += 1; if (oldParagraph.Decorations != null) { InsertInto(relativePos, oldParagraph.DecorationStarts, oldParagraph.Decorations.Count); } if (oldParagraph.Fonts != null) { InsertInto(relativePos, oldParagraph.FontStarts, oldParagraph.Fonts.Count); } return(oldParagraph); }