org.foray.text.line.solitary
Class SolitaryLineBreaker

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

public class SolitaryLineBreaker
extends EagerLineBreaker

An "eager" line-breaking implementaton which considers only the current line in the line-breaking computation (hence the name "solitary"). It look neither forward nor backward in its computation, but merely attempts to find the best break that it can for the current line.


Field Summary
protected static byte CONNECTOR
          Possible value for previousCharacter, indicating that the previous character was an interword connectors, like whitespace or a hyphen.
protected static byte NOTHING
          Possible value for previousCharacter, indicating that there was no previous character.
protected static byte TEXT
          Possible value for previousCharacter, indicating that the previous character was text within a "word".
 
Constructor Summary
SolitaryLineBreaker(TextServer4a server, org.axsl.text.line.LineBreakControl control, org.axsl.text.line.LineBreakHandler handler, org.axsl.font.FontConsumer fontConsumer)
          Constructor.
 
Method Summary
protected  int processLineText(org.axsl.text.line.LineText lineText, int start, int end)
          Processes a line-text item.
 int tryHyphenation()
          Extracts a word for hyphenation and calls the hyphenation package.
 
Methods inherited from class org.foray.text.line.EagerLineBreaker
addLineContent, getCurrentLine, getLineContent, lineReceivingContent, overflowMessage, processInput, processLineContent, processLineNonText, setCurrentLine
 
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
 

Field Detail

NOTHING

protected static final byte NOTHING
Possible value for previousCharacter, indicating that there was no previous character.

See Also:
Constant Field Values

CONNECTOR

protected static final byte CONNECTOR
Possible value for previousCharacter, indicating that the previous character was an interword connectors, like whitespace or a hyphen.

See Also:
Constant Field Values

TEXT

protected static final byte TEXT
Possible value for previousCharacter, indicating that the previous character was text within a "word".

See Also:
Constant Field Values
Constructor Detail

SolitaryLineBreaker

public SolitaryLineBreaker(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

processLineText

protected int processLineText(org.axsl.text.line.LineText lineText,
                              int start,
                              int end)
                       throws org.axsl.text.TextException
Description copied from class: EagerLineBreaker
Processes a line-text item.

Specified by:
processLineText in class EagerLineBreaker
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.

tryHyphenation

public int tryHyphenation()
                   throws org.axsl.text.TextException
Extracts a word for hyphenation and calls the hyphenation package. Handles quotation marks at the beginning of words, but not in an internationalized way.

Returns:
The index to the last element in the current line that has been processed.
Throws:
org.axsl.text.TextException - For errors during the hyphenation.


Copyright © 2017. All rights reserved.