Class TextSegment
java.lang.Object
com.realtime.crossfire.jxclient.gui.log.TextSegment
One segment of a
Line which should be displayed without changing
attributes.-
Constructor Summary
ConstructorsConstructorDescriptionTextSegment(@NotNull String text, @NotNull Font font, boolean bold, boolean italic, boolean underline, @NotNull FontID fontID, @NotNull Color color, @NotNull RectangularShape size, int ascentOffset, int underlineOffset, @NotNull Color selectionColor) Creates a new segment. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendSelection(@NotNull StringBuilder sb, int beginSelection, int endSelection) Appends the selected text to aStringBuilderinstance.voiddraw(@NotNull Graphics2D g, int y, int beginSelection, int endSelection) Draws this segment to aGraphicsinstance.@NotNull Stringformat()Returns a string representation of this text segment.intReturns the height to display the segment.intReturns the absolute position of the first character.@NotNull RectangularShapegetSize()Returns the size of this segment in pixels.@NotNull StringgetText()Returns the text to display.intgetWidth()Returns the width to display the segment.intgetWidth(int chars, @NotNull FontRenderContext context) Returns the display width of a prefix of this segment's text.intgetX()Returns the x-coordinate to display the segment.intgetY()Returns the y-coordinate to display the segment.booleanmatches(boolean bold, boolean italic, boolean underline, @NotNull FontID fontID, @NotNull Color color, @NotNull Color selectionColor) Returns whether this segment matches the given attributes.voidsetExtends(int x, int y, int position) Sets the extends to display the segment.@NotNull StringtoString()voidupdatePosition(int positions) Shifts the position of this line.
-
Constructor Details
-
TextSegment
public TextSegment(@NotNull @NotNull String text, @NotNull @NotNull Font font, boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull Color color, @NotNull @NotNull RectangularShape size, int ascentOffset, int underlineOffset, @NotNull @NotNull Color selectionColor) Creates a new segment.- Parameters:
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
-
-
Method Details
-
getText
Returns the text to display.- Returns:
- the text to display
-
getPosition
public int getPosition()Returns the absolute position of the first character.- Returns:
- the absolute position of the first character
-
setExtends
public void setExtends(int x, int y, int position) Sets the extends to display the segment.- Parameters:
x- the x-coordinatey- the y-coordinateposition- the absolute position of the first character
-
updatePosition
public void updatePosition(int positions) Shifts the position of this line.- Parameters:
positions- the number of positions to shift
-
getX
public int getX()Returns the x-coordinate to display the segment.- Returns:
- the x-coordinate
-
getY
public int getY()Returns the y-coordinate to display the segment.- Returns:
- the y-coordinate
-
getWidth
public int getWidth()Returns the width to display the segment.- Returns:
- the width
-
getWidth
Returns the display width of a prefix of this segment's text.- Parameters:
chars- the number of characters in the prefixcontext- the font render context to use- Returns:
- the width
-
getHeight
public int getHeight()Returns the height to display the segment.- Returns:
- the height
-
draw
Draws this segment to aGraphicsinstance.- Parameters:
g- the graphics to draw toy- the y-coordinate to draw tobeginSelection- the first selected characterendSelection- the first character after the selection
-
getSize
Returns the size of this segment in pixels.- Returns:
- the size
-
matches
public boolean matches(boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull Color color, @NotNull @NotNull Color selectionColor) Returns whether this segment matches the given attributes.- Parameters:
bold- the bold attributeitalic- the italic attributeunderline- the underline attributefontID- the font attributecolor- the color attributeselectionColor- the selection color attribute- Returns:
- whether all attributes do match
-
toString
-
format
Returns a string representation of this text segment.- Returns:
- the string representation
-
appendSelection
public void appendSelection(@NotNull @NotNull StringBuilder sb, int beginSelection, int endSelection) Appends the selected text to aStringBuilderinstance.- Parameters:
sb- the string builder instancebeginSelection- the first selected characterendSelection- the first character after the selection
-