Class TextStyle
- java.lang.Object
-
- org.eclipse.nebula.paperclips.core.text.TextStyle
-
public class TextStyle extends java.lang.ObjectDefines a set of styles that can be applied to text. Instances of this class are immutable.
-
-
Field Summary
Fields Modifier and Type Field Description private intalignmentprivate org.eclipse.swt.graphics.RGBbackgroundprivate org.eclipse.swt.graphics.FontDatafontDataprivate org.eclipse.swt.graphics.RGBforegroundprivate booleanstrikeoutprivate booleanunderline
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextStylealign(int alignment)Returns a copy of this TextStyle, with the alignment changed to the argument.TextStylebackground(int rgb)Returns a copy of this TextStyle, with the background changed to the color described by the argument.TextStylebackground(int red, int green, int blue)Returns a copy of this TextStyle, with the background changed to the color described by the arguments.TextStylebackground(org.eclipse.swt.graphics.RGB background)Returns a copy of this TextStyle, with the background changed to the argument.TextPrintcreate(java.lang.String text)Returns a TextPrint of the given text in this text stylebooleanequals(java.lang.Object obj)TextStylefont(java.lang.String name, int height, int style)Returns a copy of this TextStyle, with the font changed to the font described by the arguments.TextStylefont(org.eclipse.swt.graphics.FontData fontData)Returns a copy of this TextStyle, with the font changed to the argument.TextStylefontHeight(int height)Returns a copy of this TextStyle, with the font height changed to the argument.TextStylefontName(java.lang.String name)Returns a copy of this TextStyle, with the font name changed to the argument.TextStylefontStyle(int style)Returns a copy of this TextStyle, with the font style changed to the argument.TextStyleforeground(int rgb)Returns a copy of this TextStyle, with the foreground changed to the color described by the argument.TextStyleforeground(int red, int green, int blue)Returns a copy of this TextStyle, with the foreground changed to the color described by the arguments.TextStyleforeground(org.eclipse.swt.graphics.RGB foreground)Returns a copy of this TextStyle, with the foreground changed to the argument.intgetAlignment()Returns the text alignment.org.eclipse.swt.graphics.RGBgetBackground()Returns the text background color.org.eclipse.swt.graphics.FontDatagetFontData()Returns the font applied to the text.org.eclipse.swt.graphics.RGBgetForeground()Returns the text foreground color.booleangetStrikeout()Returns the strikeout flag.booleangetUnderline()Returns the underline flag.inthashCode()private TextStyleinternalBackground(org.eclipse.swt.graphics.RGB background)private TextStyleinternalFont(org.eclipse.swt.graphics.FontData fontData)private TextStyleinternalForeground(org.eclipse.swt.graphics.RGB foreground)TextStylestrikeout()Returns a copy of this TextStyle, with the strikeout flag set to true.TextStylestrikeout(boolean strikeout)Returns a copy of this TextStyle, with the strikeout flag set to the argument.TextStyleunderline()Returns a copy of this TextStyle, with the underline flag set to true.TextStyleunderline(boolean underline)Returns a copy of this TextStyle, with the underline flag set to the argument.
-
-
-
Constructor Detail
-
TextStyle
public TextStyle()
Constructs a new TextStyle with default font (device-dependent), black foreground, transparent background, default alignment, and the strikeout and underline flags set to false.
-
TextStyle
private TextStyle(TextStyle that)
-
-
Method Detail
-
internalFont
private TextStyle internalFont(org.eclipse.swt.graphics.FontData fontData)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
font
public TextStyle font(java.lang.String name, int height, int style)
Returns a copy of this TextStyle, with the font changed to the font described by the arguments. This method is equivalent to calling font( new FontData( name, height, style ) ).- Parameters:
name- the name of the font (must not be null)height- the font height in pointsstyle- a bit or combination of NORMAL, BOLD, ITALIC- Returns:
- a copy of this TextStyle, with the font changed to the font described by the arguments.
-
font
public TextStyle font(org.eclipse.swt.graphics.FontData fontData)
Returns a copy of this TextStyle, with the font changed to the argument.- Parameters:
fontData- the new font. A null value causes the font to be inherited from the enclosing elements of the document.- Returns:
- a copy of this TextStyle, with the font changed to the argument.
-
fontName
public TextStyle fontName(java.lang.String name)
Returns a copy of this TextStyle, with the font name changed to the argument.- Parameters:
name- the new font name (must not be null)- Returns:
- a copy of this TextStyle, with the font name changed to the argument.
-
fontHeight
public TextStyle fontHeight(int height)
Returns a copy of this TextStyle, with the font height changed to the argument.- Parameters:
height- the new font height in points- Returns:
- a copy of this TextStyle, with the font height changed to the argument.
-
fontStyle
public TextStyle fontStyle(int style)
Returns a copy of this TextStyle, with the font style changed to the argument.- Parameters:
style- a bit or combination of NORMAL, BOLD, ITALIC- Returns:
- a copy of this TextStyle, with the font style changed to the argument.
-
internalForeground
private TextStyle internalForeground(org.eclipse.swt.graphics.RGB foreground)
-
foreground
public TextStyle foreground(org.eclipse.swt.graphics.RGB foreground)
Returns a copy of this TextStyle, with the foreground changed to the argument.- Parameters:
foreground- the new foreground. A null value causes the foreground to be inherited from the enclosing elements of the document.- Returns:
- a copy of this TextStyle, with the foreground changed to the argument.
-
foreground
public TextStyle foreground(int red, int green, int blue)
Returns a copy of this TextStyle, with the foreground changed to the color described by the arguments. This method is equivalent to calling foreground(new RGB(red, green, blue)).- Parameters:
red- the red component of the new foreground colorgreen- the green component of the new foreground colorblue- the blue component of the new foreground color- Returns:
- a copy of this TextStyle, with the foreground changed to the color described by the arguments.
-
foreground
public TextStyle foreground(int rgb)
Returns a copy of this TextStyle, with the foreground changed to the color described by the argument.- Parameters:
rgb- an integer containing the red, green and blue components in the 0xFF0000, 0x00FF00, and 0x0000FF positions, respectively.- Returns:
- a copy of this TextStyle, with the foreground changed to the color described by the argument.
-
internalBackground
private TextStyle internalBackground(org.eclipse.swt.graphics.RGB background)
-
background
public TextStyle background(org.eclipse.swt.graphics.RGB background)
Returns a copy of this TextStyle, with the background changed to the argument.- Parameters:
background- the new background. A null value causes the text background to be transparent.- Returns:
- a copy of this TextStyle, with the background changed to the argument.
-
background
public TextStyle background(int red, int green, int blue)
Returns a copy of this TextStyle, with the background changed to the color described by the arguments. This method is equivalent to calling background(new RGB(red, green, blue)- Parameters:
red- the red component of the new background colorgreen- the green component of the new background colorblue- the blue component of the new background color- Returns:
- a copy of this TextStyle, with the background changed to the color described by the arguments.
-
background
public TextStyle background(int rgb)
Returns a copy of this TextStyle, with the background changed to the color described by the argument.- Parameters:
rgb- an integer containing the red, green and blue components in the 0xFF0000, 0x00FF00, and 0x0000FF positions, respectively.- Returns:
- a copy of this TextStyle, with the background changed to the color described by the argument.
-
align
public TextStyle align(int alignment)
Returns a copy of this TextStyle, with the alignment changed to the argument.- Parameters:
alignment- the new alignment. Must be one of SWT.LEFT, SWT.CENTER, or SWT.RIGHT. Invalid values will be changed to SWT.LEFT.- Returns:
- a copy of this TextStyle, with the alignment changed to the argument.
-
underline
public TextStyle underline()
Returns a copy of this TextStyle, with the underline flag set to true.- Returns:
- a copy of this TextStyle, with the underline flag set to true.
-
underline
public TextStyle underline(boolean underline)
Returns a copy of this TextStyle, with the underline flag set to the argument.- Parameters:
underline- the new underline flag.- Returns:
- a copy of this TextStyle, with the underline flag set to the argument.
-
strikeout
public TextStyle strikeout()
Returns a copy of this TextStyle, with the strikeout flag set to true.- Returns:
- a copy of this TextStyle, with the strikeout flag set to true.
-
strikeout
public TextStyle strikeout(boolean strikeout)
Returns a copy of this TextStyle, with the strikeout flag set to the argument.- Parameters:
strikeout- the new strikeout flag.- Returns:
- a copy of this TextStyle, with the strikeout flag set to the argument.
-
getFontData
public org.eclipse.swt.graphics.FontData getFontData()
Returns the font applied to the text.- Returns:
- the font applied to the text.
-
getForeground
public org.eclipse.swt.graphics.RGB getForeground()
Returns the text foreground color. A null value indicates that the foreground color will be inherited from the enclosing elements of the document.- Returns:
- the text foreground color.
-
getBackground
public org.eclipse.swt.graphics.RGB getBackground()
Returns the text background color. A null value indicates that the background will be transparent.- Returns:
- the text background color. A null value indicates that the background will be transparent.
-
getAlignment
public int getAlignment()
Returns the text alignment. Possible values include SWT.LEFT, SWT.CENTER, or SWT.RIGHT.- Returns:
- the text alignment.
-
getUnderline
public boolean getUnderline()
Returns the underline flag.- Returns:
- the underline flag.
-
getStrikeout
public boolean getStrikeout()
Returns the strikeout flag.- Returns:
- the strikeout flag.
-
create
public TextPrint create(java.lang.String text)
Returns a TextPrint of the given text in this text style- Parameters:
text- the text- Returns:
- a TextPrint of the given text in this text style
-
-