public class DisplayLine extends LinkedListElement
Modifier and Type | Class and Description |
---|---|
static interface |
DisplayLine.WidthProvider |
Modifier and Type | Field and Description |
---|---|
int |
displayWidth
This is the width that was used when the DisplayLine was created split.
|
static int |
ENDS_WITH_NEWLINE
This indicates that this line actually has a '\n' character at the end.
|
static int |
ENDS_WITH_SPACE
This is not used.
|
static int |
FIRST_WIDTH_ONLY |
int |
flags |
boolean |
invalid
This is used by Controls that use this DisplayLine.
|
int |
lengthOfLine
This is valid immediately after a split.
|
String |
line |
int |
lineIndex
This is the index of the line within the editor/display.
|
int |
numberInSection
Only valid for the first line in a section.
|
static int |
PROVIDES_SPACE_ABOVE_LINE
This indicates that this line is used to provide blank lines above a non-blank line.
|
static int |
PROVIDES_SPACE_BELOW_LINE
This indicates that this line is used to provide blank lines below a non-blank line.
|
static int |
SPLIT_GET_LENGTHS |
static int |
SPLIT_NO_WRAP |
static int |
widest
This is only valid immediately after doing a splitLines() call.
|
int |
width
This is the width of the line.
|
next, prev
Constructor and Description |
---|
DisplayLine() |
Modifier and Type | Method and Description |
---|---|
int |
compareLineLengths(DisplayLine lines)
This compares the lengths of the lines as given in the array.
|
static String |
concatenate(DisplayLine from,
DisplayLine to) |
static String |
concatenate(DisplayLine lines,
int start,
int length) |
int |
countBlankLines(boolean above)
Count how many blank lines are above or below this line.
|
int |
countToSectionEnd()
This returns how many lines are from this line (inclusive) to the end
of this section.
|
int |
findSectionIndex(DisplayLine line)
This finds the index of the section the line is on.
|
static DisplayLine |
getBlankLines(int count,
boolean forAbove)
Get a sequence of blank (empty) lines to be placed either above or below a data line.
|
DisplayLine |
getIndexedSection(int index) |
int |
getPositionInSection(int cursorLine,
int cursorPos)
This returns the position in the section of the specified cursor line and position
in the editor/display.
|
DisplayLine |
getSection(int indexOfThisLine)
Gets the first DisplayLine in the section that this line happens
to be in.
|
String |
getSectionText()
This can only be called on a section start.
|
int |
getWidth(FontMetrics fm,
int options) |
int |
hasSectionChanged(DisplayLine changedLine,
FontMetrics fm,
int width)
This changes the text of a line within a section and then sees if
any lines apart from that line would be changed.
|
int |
hasSectionChanged(DisplayLine changedLine,
FontMetrics fm,
int width,
FormattedTextSpecs fts)
This changes the text of a line within a section and then sees if
any lines apart from that line would be changed.
|
int |
length() |
Dimension |
locate(int characterIndex,
Dimension dest)
This locates the row and column index of a character from the original text in the
list of DisplayLines.
|
Dimension |
positionInSection(int position,
Dimension dest,
boolean onPrev)
This calculates the cursor line and position for the given offset position
from the start of the section.
|
static DisplayLine[] |
replaceLines(DisplayLine[] original,
int start,
DisplayLine[] newLines) |
int |
replaceSection(DisplayLine newSection)
This replaces the section with the provided section (which can actually have more than
one section in it).
|
static DisplayLine |
split(String text,
FontMetrics fm,
int width,
int options) |
static DisplayLine |
split(String text,
FontMetrics fm,
int width,
int options,
FormattedTextSpecs ft) |
static DisplayLine |
split(String text,
FontMetrics fm,
int width,
int options,
FormattedTextSpecs fts,
DisplayLine.WidthProvider wp) |
static DisplayLine[] |
splitLines(String text,
FontMetrics fm,
int width,
int options)
Split the lines.
|
String |
substring(int start,
int end) |
static String[] |
toLines(DisplayLine all) |
String |
toString()
Return a String representation of this object.
|
static String[] |
toStrings(DisplayLine[] lines) |
int |
trueLength() |
addSectionAfter, addSectionBefore, countInRange, countNext, countPrev, getNext, getPrev, removeSection, replaceSection, toArray
public String line
public int flags
public int width
public int lineIndex
public int numberInSection
public int lengthOfLine
public int displayWidth
public boolean invalid
public static final int ENDS_WITH_NEWLINE
public static final int ENDS_WITH_SPACE
public static final int PROVIDES_SPACE_ABOVE_LINE
public static final int PROVIDES_SPACE_BELOW_LINE
public static int widest
public static final int SPLIT_NO_WRAP
public static final int FIRST_WIDTH_ONLY
public static final int SPLIT_GET_LENGTHS
public DisplayLine getSection(int indexOfThisLine)
public int findSectionIndex(DisplayLine line)
public DisplayLine getIndexedSection(int index)
public int countToSectionEnd()
public int compareLineLengths(DisplayLine lines)
public int hasSectionChanged(DisplayLine changedLine, FontMetrics fm, int width, FormattedTextSpecs fts)
public int hasSectionChanged(DisplayLine changedLine, FontMetrics fm, int width)
public int getPositionInSection(int cursorLine, int cursorPos)
public Dimension positionInSection(int position, Dimension dest, boolean onPrev)
public int replaceSection(DisplayLine newSection)
public String getSectionText()
public static String[] toLines(DisplayLine all)
public static DisplayLine[] splitLines(String text, FontMetrics fm, int width, int options)
text
- The text to be split.fm
- The FontMetrics for the Font and surface to be used for display.width
- The width in pixels of the display area.options
- This is a combination of SPLIT_GET_LENGTHS, SPLIT_NO_WRAP and FIRST_WIDTH_ONLYpublic int getWidth(FontMetrics fm, int options)
public static DisplayLine split(String text, FontMetrics fm, int width, int options)
public static DisplayLine split(String text, FontMetrics fm, int width, int options, FormattedTextSpecs ft)
public static DisplayLine split(String text, FontMetrics fm, int width, int options, FormattedTextSpecs fts, DisplayLine.WidthProvider wp)
public String toString()
Object
public int length()
public int trueLength()
public String substring(int start, int end)
public static String concatenate(DisplayLine lines, int start, int length)
public static String concatenate(DisplayLine from, DisplayLine to)
public static DisplayLine[] replaceLines(DisplayLine[] original, int start, DisplayLine[] newLines)
public Dimension locate(int characterIndex, Dimension dest)
characterIndex
- The original index of the character.dest
- a destination Dimension to hold the results. It can be null, in which case
a new one will be allocated and returned.public static DisplayLine getBlankLines(int count, boolean forAbove)
count
- The number of lines to get.forAbove
- if this is true then the lines are meant to be above a data line,
otherwise it is for below a data line.public int countBlankLines(boolean above)
above
- if this is true then you are counting the blank lines above, otherwise
you are counting those below.public static String[] toStrings(DisplayLine[] lines)