Top Description Fields Constructors Methods
org.eclipse.swt.custom

public Class StyleRange

extends TextStyle
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
org.eclipse.swt.*, org.eclipse.swt.graphics.*

StyleRange defines a set of styles for a specified 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.

See Also
Sample code and further information

Field Summary

Modifier and TypeField and Description
public int
fontStyle

the font style of the range.

public int
length

the length of the range

public int
start

the start offset of the range, zero-based from the document start

Inherited from org.eclipse.swt.graphics.TextStyle:
backgroundborderColorborderStyledatafontforegroundmetricsrisestrikeoutstrikeoutColorunderlineunderlineColorunderlineStyle

Constructor Summary

AccessConstructor and Description
public
StyleRange()

Create a new style range with no styles

public
StyleRange(TextStyle
the text style to copy
style
)

Create a new style range from an existing text style.

public
StyleRange(int
start offset of the style
start
,
int
length of the style
length
,
Color
foreground color of the style, null if none
foreground
,
Color
background color of the style, null if none
background
)

Create a new style range.

public
StyleRange(int
start offset of the style
start
,
int
length of the style
length
,
Color
foreground color of the style, null if none
foreground
,
Color
background color of the style, null if none
background
,
int
font style of the style, may be SWT.NORMAL, SWT.ITALIC or SWT.BOLD
fontStyle
)

Create a new style range.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

a shallow copy of this StyleRange
clone
()

Overrides java.lang.Object.clone.

Returns a new StyleRange with the same values as this StyleRange.
public boolean

Returns:

true if the object is the same as this object and false otherwise
equals
(Object
the object to compare with this object
object
)

Overrides org.eclipse.swt.graphics.TextStyle.equals.

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
public int

Returns:

the receiver's hash
hashCode
()

Overrides org.eclipse.swt.graphics.TextStyle.hashCode.

Returns an integer hash code for the receiver.
public boolean

Returns:

true if the receiver is unstyled, false otherwise.
isUnstyled
()

Returns whether or not the receiver is unstyled (i.e., does not have any style attributes specified).

pack-priv boolean
public boolean

Returns:

true if the objects are similar, false otherwise
similarTo
(StyleRange
the object to compare with this object
style
)

Compares the specified object to this StyleRange and answer if the two are similar.

public String

Returns:

a string representation of the StyleRange
toString
()

Overrides org.eclipse.swt.graphics.TextStyle.toString.

Returns a string containing a concise, human-readable description of the receiver.

Field Detail

fontStyleback to summary
public int fontStyle

the font style of the range. It may be a combination of SWT.NORMAL, SWT.ITALIC or SWT.BOLD

Note

the font style is not used if the font attribute is set

lengthback to summary
public int length

the length of the range

startback to summary
public int start

the start offset of the range, zero-based from the document start

Constructor Detail

StyleRangeback to summary
public StyleRange()

Create a new style range with no styles

Since
3.2
StyleRangeback to summary
public StyleRange(TextStyle style)

Create a new style range from an existing text style.

Parameters
style:TextStyle

the text style to copy

Since
3.4
StyleRangeback to summary
public StyleRange(int start, int length, Color foreground, Color background)

Create a new style range.

Parameters
start:int

start offset of the style

length:int

length of the style

foreground:Color

foreground color of the style, null if none

background:Color

background color of the style, null if none

StyleRangeback to summary
public StyleRange(int start, int length, Color foreground, Color background, int fontStyle)

Create a new style range.

Parameters
start:int

start offset of the style

length:int

length of the style

foreground:Color

foreground color of the style, null if none

background:Color

background color of the style, null if none

fontStyle:int

font style of the style, may be SWT.NORMAL, SWT.ITALIC or SWT.BOLD

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a new StyleRange with the same values as this StyleRange.

Returns:Object

a shallow copy of this StyleRange

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides org.eclipse.swt.graphics.TextStyle.equals.

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Parameters
object:Object

the object to compare with this object

Returns:boolean

true if the object is the same as this object and false otherwise

Annotations
@Override
See Also
hashCode()
hashCodeback to summary
public int hashCode()

Overrides org.eclipse.swt.graphics.TextStyle.hashCode.

Returns an integer hash code for the receiver. Any two objects that return true when passed to equals must return the same value for this method.

Returns:int

the receiver's hash

Annotations
@Override
See Also
equals(Object)
isUnstyledback to summary
public boolean isUnstyled()

Returns whether or not the receiver is unstyled (i.e., does not have any style attributes specified).

Returns:boolean

true if the receiver is unstyled, false otherwise.

isVariableHeightback to summary
pack-priv boolean isVariableHeight()
similarToback to summary
public boolean similarTo(StyleRange style)

Compares the specified object to this StyleRange and answer if the two are similar. The object must be an instance of StyleRange and have the same field values for except for start and length.

Parameters
style:StyleRange

the object to compare with this object

Returns:boolean

true if the objects are similar, false otherwise

toStringback to summary
public String toString()

Overrides org.eclipse.swt.graphics.TextStyle.toString.

Returns a string containing a concise, human-readable description of the receiver.

Returns:String

a string representation of the StyleRange

Annotations
@Override