Package org.eclipse.swt.graphics
Class TextStyle
- java.lang.Object
-
- org.eclipse.swt.graphics.TextStyle
-
- Direct Known Subclasses:
StyleRange
public class TextStyle extends Object
TextStyle
defines a set of styles that can be applied to a range of text.The hashCode() method in this class uses the values of the public fields to compute the hash value. When storing instances of the class in hashed collections, do not modify these fields after the object has been inserted.
Application code does not need to explicitly release the resources managed by each instance when those instances are no longer required, and thus no
dispose()
method is provided.- Since:
- 3.0
- See Also:
TextLayout
,Font
,Color
, TextLayout, TextStyle snippets, Sample code and further information
-
-
Field Summary
Fields Modifier and Type Field Description Color
background
the background of the styleColor
borderColor
the border color of the styleint
borderStyle
the border style.Object
data
the data.Font
font
the font of the styleColor
foreground
the foreground of the styleGlyphMetrics
metrics
the GlyphMetrics of the styleint
rise
the baseline rise of the style.boolean
strikeout
the strikeout flag of the styleColor
strikeoutColor
the strikeout color of the styleboolean
underline
the underline flag of the style.Color
underlineColor
the underline color of the styleint
underlineStyle
the underline style.
-
Constructor Summary
Constructors Constructor Description TextStyle()
Create an empty text style.TextStyle(Font font, Color foreground, Color background)
Create a new text style with the specified font, foreground and background.TextStyle(TextStyle style)
Create a new text style from an existing text style.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.int
hashCode()
Returns an integer hash code for the receiver.String
toString()
Returns a string containing a concise, human-readable description of the receiver.
-
-
-
Field Detail
-
font
public Font font
the font of the style
-
foreground
public Color foreground
the foreground of the style
-
background
public Color background
the background of the style
-
underline
public boolean underline
the underline flag of the style. The default underline style isSWT.UNDERLINE_SINGLE
.- Since:
- 3.1
-
underlineColor
public Color underlineColor
the underline color of the style- Since:
- 3.4
-
underlineStyle
public int underlineStyle
the underline style. This style is ignored whenunderline
is false.This value should be one of
SWT.UNDERLINE_SINGLE
,SWT.UNDERLINE_DOUBLE
,SWT.UNDERLINE_ERROR
,SWT.UNDERLINE_SQUIGGLE
, orSWT.UNDERLINE_LINK
.- Since:
- 3.4
- See Also:
SWT.UNDERLINE_SINGLE
,SWT.UNDERLINE_DOUBLE
,SWT.UNDERLINE_ERROR
,SWT.UNDERLINE_SQUIGGLE
,SWT.UNDERLINE_LINK
-
strikeout
public boolean strikeout
the strikeout flag of the style- Since:
- 3.1
-
strikeoutColor
public Color strikeoutColor
the strikeout color of the style- Since:
- 3.4
-
borderStyle
public int borderStyle
the border style. The default border style isSWT.NONE
.This value should be one of
SWT.BORDER_SOLID
,SWT.BORDER_DASH
,SWT.BORDER_DOT
orSWT.NONE
.- Since:
- 3.4
- See Also:
SWT.BORDER_SOLID
,SWT.BORDER_DASH
,SWT.BORDER_DOT
,SWT.NONE
-
borderColor
public Color borderColor
the border color of the style- Since:
- 3.4
-
metrics
public GlyphMetrics metrics
the GlyphMetrics of the style- Since:
- 3.2
-
rise
public int rise
the baseline rise of the style.- Since:
- 3.2
-
data
public Object data
the data. An user data field. It can be used to hold the HREF when the range is used as a link or the embed object when the range is used withGlyphMetrics
.- Since:
- 3.5
-
-
Constructor Detail
-
TextStyle
public TextStyle()
Create an empty text style.- Since:
- 3.4
-
TextStyle
public TextStyle(Font font, Color foreground, Color background)
Create a new text style with the specified font, foreground and background.- Parameters:
font
- the font of the style,null
if noneforeground
- the foreground color of the style,null
if nonebackground
- the background color of the style,null
if none
-
TextStyle
public TextStyle(TextStyle style)
Create a new text style from an existing text style.- Parameters:
style
- the style to copy- Since:
- 3.4
-
-
Method Detail
-
equals
public boolean equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.- Overrides:
equals
in classObject
- Parameters:
object
- the object to compare with this object- Returns:
true
if the object is the same as this object andfalse
otherwise- See Also:
hashCode()
-
hashCode
public int hashCode()
Returns an integer hash code for the receiver. Any two objects that returntrue
when passed toequals
must return the same value for this method.- Overrides:
hashCode
in classObject
- Returns:
- the receiver's hash
- See Also:
equals(Object)
-
-