public class TextSegment
extends java.lang.Object
Line
which should be displayed without changing
attributes.Constructor and Description |
---|
TextSegment(@NotNull java.lang.String text,
@NotNull java.awt.Font font,
boolean bold,
boolean italic,
boolean underline,
@NotNull FontID fontID,
@NotNull java.awt.Color color,
@NotNull java.awt.geom.RectangularShape size,
int ascentOffset,
int underlineOffset,
@NotNull java.awt.Color selectionColor)
Creates a new segment.
|
Modifier and Type | Method and Description |
---|---|
void |
appendSelection(@NotNull java.lang.StringBuilder sb,
int beginSelection,
int endSelection)
Appends the selected text to a
StringBuilder instance. |
void |
draw(@NotNull java.awt.Graphics2D g,
int y,
int beginSelection,
int endSelection)
Draws this segment to a
Graphics instance. |
@NotNull java.lang.String |
format()
Returns a string representation of this text segment.
|
int |
getHeight()
Returns the height to display the segment.
|
int |
getPosition()
Returns the absolute position of the first character.
|
@NotNull java.awt.geom.RectangularShape |
getSize()
Returns the size of this segment in pixels.
|
@NotNull java.lang.String |
getText()
Returns the text to display.
|
int |
getWidth()
Returns the width to display the segment.
|
int |
getWidth(int chars,
@NotNull java.awt.font.FontRenderContext context)
Returns the display width of a prefix of this segment's text.
|
int |
getX()
Returns the x-coordinate to display the segment.
|
int |
getY()
Returns the y-coordinate to display the segment.
|
boolean |
matches(boolean bold,
boolean italic,
boolean underline,
@NotNull FontID fontID,
@NotNull java.awt.Color color,
@NotNull java.awt.Color selectionColor)
Returns whether this segment matches the given attributes.
|
void |
setExtends(int x,
int y,
int position)
Sets the extends to display the segment.
|
@NotNull java.lang.String |
toString() |
void |
updatePosition(int positions)
Shifts the position of this line.
|
public TextSegment(@NotNull @NotNull java.lang.String text, @NotNull @NotNull java.awt.Font font, boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull java.awt.Color color, @NotNull @NotNull java.awt.geom.RectangularShape size, int ascentOffset, int underlineOffset, @NotNull @NotNull java.awt.Color selectionColor)
text
- the text to displayfont
- the font of the textbold
- whether bold face is enableditalic
- whether italic face is enabledunderline
- whether underlining is enabledfontID
- the font to usecolor
- the color to usesize
- the size of this segment in pixelsascentOffset
- the distance of the ascent from the top of the
segmentunderlineOffset
- the distance of the underline from the top of the
segmentselectionColor
- the selection color to use@NotNull public @NotNull java.lang.String getText()
public int getPosition()
public void setExtends(int x, int y, int position)
x
- the x-coordinatey
- the y-coordinateposition
- the absolute position of the first characterpublic void updatePosition(int positions)
positions
- the number of positions to shiftpublic int getX()
public int getY()
public int getWidth()
public int getWidth(int chars, @NotNull @NotNull java.awt.font.FontRenderContext context)
chars
- the number of characters in the prefixcontext
- the font render context to usepublic int getHeight()
public void draw(@NotNull @NotNull java.awt.Graphics2D g, int y, int beginSelection, int endSelection)
Graphics
instance.g
- the graphics to draw toy
- the y-coordinate to draw tobeginSelection
- the first selected characterendSelection
- the first character after the selection@NotNull public @NotNull java.awt.geom.RectangularShape getSize()
public boolean matches(boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull java.awt.Color color, @NotNull @NotNull java.awt.Color selectionColor)
bold
- the bold attributeitalic
- the italic attributeunderline
- the underline attributefontID
- the font attributecolor
- the color attributeselectionColor
- the selection color attribute@NotNull public @NotNull java.lang.String toString()
toString
in class java.lang.Object
@NotNull public @NotNull java.lang.String format()
public void appendSelection(@NotNull @NotNull java.lang.StringBuilder sb, int beginSelection, int endSelection)
StringBuilder
instance.sb
- the string builder instancebeginSelection
- the first selected characterendSelection
- the first character after the selection