org.foray.text.line
Class EagerLineBreaker

java.lang.Object
  extended by org.foray.text.line.LineBreaker
      extended by org.foray.text.line.EagerLineBreaker
All Implemented Interfaces:
org.axsl.text.line.EagerLineBreaker, org.axsl.text.line.LineBreaker
Direct Known Subclasses:
SolitaryLineBreaker

public abstract class EagerLineBreaker
extends LineBreaker
implements org.axsl.text.line.EagerLineBreaker

Abstract superclass for LineBreakers that act in an "eager" manner. Much of the usefulness of this class comes from its ability to adapt an eager line-breaking system to be used by patient clients.


Constructor Summary
EagerLineBreaker(TextServer4a server, org.axsl.text.line.LineBreakControl control, org.axsl.text.line.LineBreakHandler handler, org.axsl.font.FontConsumer fontConsumer)
          Constructor.
 
Method Summary
 int addLineContent(org.axsl.text.line.LineContent content, int start, int end, org.axsl.text.line.LineOutput output)
          Add new line-content for processing.
 org.axsl.text.line.LineOutput getCurrentLine()
          Returns the current line-output item.
 org.axsl.text.line.LineContent getLineContent()
          Returns the current line content.
protected  org.axsl.text.line.LineOutput lineReceivingContent()
          Return the current line-output.
protected  void overflowMessage()
          Writes a standard overflow message to the logger.
protected  int processInput(org.axsl.text.line.LineContent lineContent, int start, int end)
          Run a piece of content through the line-breaking system.
 int processLineContent(org.axsl.text.line.LineContent contentItem, int start, int end, org.axsl.text.line.LineOutput output)
           
protected  int processLineNonText(org.axsl.text.line.LineNonText nonTextItem)
          Standard processing of non-text items for eager line breaking systems.
protected abstract  int processLineText(org.axsl.text.line.LineText lineText, int start, int end)
          Processes a line-text item.
 void setCurrentLine(org.axsl.text.line.LineOutput line)
          Sets the current line-output item.
 
Methods inherited from class org.foray.text.line.LineBreaker
allowsLineBreak, canBreakMidWord, charWidth, forcesLineBreak, getCharWidth, getFontConsumer, getHandler, getHyphenWidth, getLineBreakControl, getLogger, getTextServer, getWordWidth, isInLowerCase, isLowerCase, isNonBreakingSpace, isSpace, isUpperCase, isWhitespace, isZeroWidthSpace, setInLowerCase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EagerLineBreaker

public EagerLineBreaker(TextServer4a server,
                        org.axsl.text.line.LineBreakControl control,
                        org.axsl.text.line.LineBreakHandler handler,
                        org.axsl.font.FontConsumer fontConsumer)
Constructor.

Parameters:
server - The "parent" TextServer.
control - The client object that provides process-time information, specifically by providing line length information.
handler - The client object that is responsible for taking the results of the line-breaking work and doing something with it.
fontConsumer - Provides the line-breaking system with the FontConsumer instance that should be used for interfacing with the Font subsystem.
Method Detail

processInput

protected int processInput(org.axsl.text.line.LineContent lineContent,
                           int start,
                           int end)
                    throws org.axsl.text.TextException
Run a piece of content through the line-breaking system.

Parameters:
lineContent - The line content to be processed.
start - The staring index in the line content to be processed.
end - The ending index in the line content to be processed.
Returns:
The index in the line to the last character processed.
Throws:
org.axsl.text.TextException - For errors during line-breaking.

processLineNonText

protected int processLineNonText(org.axsl.text.line.LineNonText nonTextItem)
                          throws org.axsl.text.TextException
Standard processing of non-text items for eager line breaking systems.

Parameters:
nonTextItem - The non-text item that should be added to the current line.
Returns:
If the item was successfully added to the current line, returns 1, or returns 0 if there is not enough room on the line for it.
Throws:
org.axsl.text.TextException - For errors during processing.

processLineText

protected abstract int processLineText(org.axsl.text.line.LineText lineText,
                                       int start,
                                       int end)
                                throws org.axsl.text.TextException
Processes a line-text item.

Parameters:
lineText - The line-text item to be processed.
start - The index to the first character in the line-text item that should be processed.
end - The index to the last character in the line-text item that should be processed.
Returns:
The index to the last character in the line-text item that was actually processed.
Throws:
org.axsl.text.TextException - For errors during line-breaking.

addLineContent

public int addLineContent(org.axsl.text.line.LineContent content,
                          int start,
                          int end,
                          org.axsl.text.line.LineOutput output)
                   throws org.axsl.text.TextException
Add new line-content for processing.

Parameters:
content - The line-content to be processed.
start - The index to the first element in the line-content to be processed.
end - The index to the last element in the line-content to be processed.
output - The line-output onto which the text should be placed.
Returns:
The index to the last element in the line-content that was actually processed.
Throws:
org.axsl.text.TextException - For errors during text processing.

lineReceivingContent

protected org.axsl.text.line.LineOutput lineReceivingContent()
Return the current line-output.

Returns:
The current line-output.

processLineContent

public int processLineContent(org.axsl.text.line.LineContent contentItem,
                              int start,
                              int end,
                              org.axsl.text.line.LineOutput output)
                       throws org.axsl.text.TextException
Specified by:
processLineContent in interface org.axsl.text.line.EagerLineBreaker
Throws:
org.axsl.text.TextException

setCurrentLine

public void setCurrentLine(org.axsl.text.line.LineOutput line)
Sets the current line-output item.

Parameters:
line - The new line-output item.

getCurrentLine

public org.axsl.text.line.LineOutput getCurrentLine()
Returns the current line-output item.

Returns:
The current line-output item.

getLineContent

public org.axsl.text.line.LineContent getLineContent()
Returns the current line content.

Returns:
The current line content.

overflowMessage

protected void overflowMessage()
Writes a standard overflow message to the logger.



Copyright © 2017. All rights reserved.