Gridarta Editor
net.sf.gridarta.textedit.textarea.SyntaxStyle Class Reference

A simple text style class. More...

+ Collaboration diagram for net.sf.gridarta.textedit.textarea.SyntaxStyle:

Public Member Functions

Color getColor ()
 Returns the text color. More...
 
FontMetrics getFontMetrics (final Font font, final Graphics g)
 Returns the font metrics for the styled font. More...
 
boolean isBold ()
 Returns. More...
 
boolean isItalic ()
 Returns. More...
 
boolean isPlain ()
 Returns. More...
 
void setGraphicsFlags (final Graphics gfx, final Font font)
 Sets the text color and font of the specified graphics context to that specified in this style. More...
 
 SyntaxStyle (final Color color, final boolean italic, final boolean bold)
 Creates a new instance. More...
 
String toString ()
 

Private Member Functions

Font getStyledFont (final Font font)
 Returns the specified font, but with the style's bold and italic flags applied. More...
 
void updateStyledFont (final Font font)
 Update lastFont and lastStyledFont for the given font. More...
 

Private Attributes

final boolean bold
 Whether the text should be bold. More...
 
final Color color
 The text color. More...
 
FontMetrics fontMetrics
 The font metrics for lastStyledFont. More...
 
final boolean italic
 Whether the text should be italics. More...
 
Font lastFont
 The base font used to calculate lastStyledFont. More...
 
Font lastStyledFont
 The font lastFont with applied italics and bold settings. More...
 

Detailed Description

A simple text style class.

It can specify the color, italic flag, and bold flag of a run of text.

Author
Slava Pestov
Andreas Kirschbaum

Definition at line 25 of file SyntaxStyle.java.

Constructor & Destructor Documentation

◆ SyntaxStyle()

net.sf.gridarta.textedit.textarea.SyntaxStyle.SyntaxStyle ( final Color  color,
final boolean  italic,
final boolean  bold 
)

Creates a new instance.

Parameters
colorthe text color
italicwhether the text should be italics
boldwhether the text should be bold

Definition at line 67 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.bold, net.sf.gridarta.textedit.textarea.SyntaxStyle.color, and net.sf.gridarta.textedit.textarea.SyntaxStyle.italic.

Member Function Documentation

◆ getColor()

Color net.sf.gridarta.textedit.textarea.SyntaxStyle.getColor ( )

Returns the text color.

Returns
the text color

Definition at line 77 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.color.

◆ getFontMetrics()

FontMetrics net.sf.gridarta.textedit.textarea.SyntaxStyle.getFontMetrics ( final Font  font,
final Graphics  g 
)

Returns the font metrics for the styled font.

Parameters
fontthe styled font
gthe graphics to use
Returns
the font metrics

Definition at line 126 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.fontMetrics, and net.sf.gridarta.textedit.textarea.SyntaxStyle.updateStyledFont().

Referenced by net.sf.gridarta.textedit.textarea.TextAreaPainter.offsetToX2(), and net.sf.gridarta.textedit.textarea.TextAreaPainter.xToOffset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStyledFont()

Font net.sf.gridarta.textedit.textarea.SyntaxStyle.getStyledFont ( final Font  font)
private

Returns the specified font, but with the style's bold and italic flags applied.

Parameters
fontthe specified font
Returns
the
font
with applied flags

Definition at line 111 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.lastStyledFont, and net.sf.gridarta.textedit.textarea.SyntaxStyle.updateStyledFont().

Referenced by net.sf.gridarta.textedit.textarea.SyntaxStyle.setGraphicsFlags().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBold()

boolean net.sf.gridarta.textedit.textarea.SyntaxStyle.isBold ( )

Returns.

true

if boldface is enabled.

Returns
the bold flag

Definition at line 101 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.bold.

◆ isItalic()

boolean net.sf.gridarta.textedit.textarea.SyntaxStyle.isItalic ( )

Returns.

true

if italics is enabled.

Returns
the italics flag

Definition at line 93 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.italic.

◆ isPlain()

boolean net.sf.gridarta.textedit.textarea.SyntaxStyle.isPlain ( )

Returns.

true

if no font styles are enabled.

Returns
whether no font styles are enabled

Definition at line 85 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.italic.

◆ setGraphicsFlags()

void net.sf.gridarta.textedit.textarea.SyntaxStyle.setGraphicsFlags ( final Graphics  gfx,
final Font  font 
)

Sets the text color and font of the specified graphics context to that specified in this style.

Parameters
gfxthe graphics context that should be modified
fontthe font to add the styles to

Definition at line 145 of file SyntaxStyle.java.

References net.sf.gridarta.textedit.textarea.SyntaxStyle.getStyledFont().

Referenced by net.sf.gridarta.textedit.textarea.TextAreaPainter.paintLine(), and net.sf.gridarta.textedit.textarea.SyntaxUtilities.paintSyntaxLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

String net.sf.gridarta.textedit.textarea.SyntaxStyle.toString ( )

Definition at line 166 of file SyntaxStyle.java.

◆ updateStyledFont()

void net.sf.gridarta.textedit.textarea.SyntaxStyle.updateStyledFont ( final Font  font)
private

Update lastFont and lastStyledFont for the given font.

Resets fontMetrics to

null

if the font has changed.

Parameters
fontthe font to use

Definition at line 155 of file SyntaxStyle.java.

Referenced by net.sf.gridarta.textedit.textarea.SyntaxStyle.getFontMetrics(), and net.sf.gridarta.textedit.textarea.SyntaxStyle.getStyledFont().

+ Here is the caller graph for this function:

Member Data Documentation

◆ bold

final boolean net.sf.gridarta.textedit.textarea.SyntaxStyle.bold
private

◆ color

final Color net.sf.gridarta.textedit.textarea.SyntaxStyle.color
private

◆ fontMetrics

FontMetrics net.sf.gridarta.textedit.textarea.SyntaxStyle.fontMetrics
private

The font metrics for lastStyledFont.

May be

null

if not yet known.

Definition at line 59 of file SyntaxStyle.java.

Referenced by net.sf.gridarta.textedit.textarea.SyntaxStyle.getFontMetrics().

◆ italic

final boolean net.sf.gridarta.textedit.textarea.SyntaxStyle.italic
private

◆ lastFont

Font net.sf.gridarta.textedit.textarea.SyntaxStyle.lastFont
private

The base font used to calculate lastStyledFont.

May be

null

if unset.

Definition at line 46 of file SyntaxStyle.java.

◆ lastStyledFont

Font net.sf.gridarta.textedit.textarea.SyntaxStyle.lastStyledFont
private

The font lastFont with applied italics and bold settings.

May be

null

if unset.

Definition at line 52 of file SyntaxStyle.java.

Referenced by net.sf.gridarta.textedit.textarea.SyntaxStyle.getStyledFont().


The documentation for this class was generated from the following file: