linebreakmeasurer.html

来自「API資料大全」· HTML 代码 · 共 649 行 · 第 1/3 页

HTML
649
字号
             if (layout != null) {                 layouts.addElement(layout);                 penPositions.addElement(new Float(horizontalPos));                 horizontalPos += layout.getAdvance();                 maxAscent = Math.max(maxAscent, layout.getAscent());                 maxDescent = Math.max(maxDescent,                     layout.getDescent() + layout.getLeading());             } else {                 lineComplete = true;             }             lineContainsText = true;             if (measurer.getPosition() == tabLocations[currentTab]+1) {                 currentTab++;             }             if (measurer.getPosition() == styledText.getEndIndex())                 lineComplete = true;             else if (horizontalPos >= tabStops[tabStops.length-1])                 lineComplete = true;             if (!lineComplete) {                 // move to next tab stop                 int j;                 for (j=0; horizontalPos >= tabStops[j]; j++) {}                 horizontalPos = tabStops[j];             }         }         verticalPos += maxAscent;         Enumeration layoutEnum = layouts.elements();         Enumeration positionEnum = penPositions.elements();         // now iterate through layouts and draw them         while (layoutEnum.hasMoreElements()) {             TextLayout nextLayout = (TextLayout) layoutEnum.nextElement();             Float nextPosition = (Float) positionEnum.nextElement();             nextLayout.draw(graphics, nextPosition.floatValue(), verticalPos);         }         verticalPos += maxDescent;     } } </pre> </blockquote><P><DL><DT><B>See Also: </B><DD><A HREF="../../../java/awt/font/TextLayout.html"><CODE>TextLayout</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#LineBreakMeasurer(java.text.AttributedCharacterIterator, java.text.BreakIterator, java.awt.font.FontRenderContext)">LineBreakMeasurer</A></B>(<A HREF="../../../java/text/AttributedCharacterIterator.html">AttributedCharacterIterator</A>&nbsp;text,                  <A HREF="../../../java/text/BreakIterator.html">BreakIterator</A>&nbsp;breakIter,                  <A HREF="../../../java/awt/font/FontRenderContext.html">FontRenderContext</A>&nbsp;frc)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a <code>LineBreakMeasurer</code> for the specified text.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#LineBreakMeasurer(java.text.AttributedCharacterIterator, java.awt.font.FontRenderContext)">LineBreakMeasurer</A></B>(<A HREF="../../../java/text/AttributedCharacterIterator.html">AttributedCharacterIterator</A>&nbsp;text,                  <A HREF="../../../java/awt/font/FontRenderContext.html">FontRenderContext</A>&nbsp;frc)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a <code>LineBreakMeasurer</code> for the specified text.</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#deleteChar(java.text.AttributedCharacterIterator, int)">deleteChar</A></B>(<A HREF="../../../java/text/AttributedCharacterIterator.html">AttributedCharacterIterator</A>&nbsp;newParagraph,           int&nbsp;deletePos)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Updates this <code>LineBreakMeasurer</code> after a single character is deleted from the text, and sets the current position to the beginning of the paragraph.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#getPosition()">getPosition</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the current position of this <code>LineBreakMeasurer</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#insertChar(java.text.AttributedCharacterIterator, int)">insertChar</A></B>(<A HREF="../../../java/text/AttributedCharacterIterator.html">AttributedCharacterIterator</A>&nbsp;newParagraph,           int&nbsp;insertPos)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Updates this <code>LineBreakMeasurer</code> after a single character is inserted into the text, and sets the current position to the beginning of the paragraph.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../java/awt/font/TextLayout.html">TextLayout</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#nextLayout(float)">nextLayout</A></B>(float&nbsp;wrappingWidth)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the next layout, and updates the current position.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../java/awt/font/TextLayout.html">TextLayout</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#nextLayout(float, int, boolean)">nextLayout</A></B>(float&nbsp;wrappingWidth,           int&nbsp;offsetLimit,           boolean&nbsp;requireNextWord)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the next layout, and updates the current position.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#nextOffset(float)">nextOffset</A></B>(float&nbsp;wrappingWidth)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the position at the end of the next layout.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#nextOffset(float, int, boolean)">nextOffset</A></B>(float&nbsp;wrappingWidth,           int&nbsp;offsetLimit,           boolean&nbsp;requireNextWord)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the position at the end of the next layout.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/font/LineBreakMeasurer.html#setPosition(int)">setPosition</A></B>(int&nbsp;newPosition)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the current position of this <code>LineBreakMeasurer</code>.</TD></TR></TABLE>&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE>&nbsp;<P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="LineBreakMeasurer(java.text.AttributedCharacterIterator, java.awt.font.FontRenderContext)"><!-- --></A><H3>LineBreakMeasurer</H3><PRE>public <B>LineBreakMeasurer</B>(<A HREF="../../../java/text/AttributedCharacterIterator.html">AttributedCharacterIterator</A>&nbsp;text,                         <A HREF="../../../java/awt/font/FontRenderContext.html">FontRenderContext</A>&nbsp;frc)</PRE><DL><DD>Constructs a <code>LineBreakMeasurer</code> for the specified text.<DD><DL><DT><B>Parameters:</B><DD><CODE>text</CODE> - the text for which this <code>LineBreakMeasurer</code> produces <code>TextLayout</code> objects.  The text must contain at least one character.  If the text available through  <code>iter</code> changes, further calls to this  <code>LineBreakMeasurer</code> instance are undefined (except, in some cases, when <code>insertChar</code> or  <code>deleteChar</code> are invoked afterward - see below).<DD><CODE>frc</CODE> - contains information about a graphics device which is needed        to measure the text correctly.       Text measurements can vary slightly depending on the       device resolution, and attributes such as antialiasing.  This       parameter does not specify a translation between the       <code>LineBreakMeasurer</code> and user space.<DT><B>See Also: </B><DD><A HREF="../../../java/awt/font/LineBreakMeasurer.html#insertChar(java.text.AttributedCharacterIterator, int)"><CODE>insertChar(java.text.AttributedCharacterIterator, int)</CODE></A>, <A HREF="../../../java/awt/font/LineBreakMeasurer.html#deleteChar(java.text.AttributedCharacterIterator, int)"><CODE>deleteChar(java.text.AttributedCharacterIterator, int)</CODE></A></DL></DD></DL><HR>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?