JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page
Class JCTextStyle

java.lang.Object
  |
  +--com.klg.jclass.page.JCTextStyle
All Implemented Interfaces:
Cloneable

public class JCTextStyle
extends Object
implements Cloneable

JCTextStyle specifies all attributes controlling the appearance of text in JClass PageLayout.


Field Summary
protected  int alignment
          Horizontal alignment of text to the frame/column edge.
static int ALIGNMENT_CENTER
          Text is aligned to the center of the current column.
static int ALIGNMENT_JUSTIFY
          Text is aligned to both the left and right margins of the current column.
static int ALIGNMENT_LEFT
          Text is aligned to the left margin of the current column.
static int ALIGNMENT_NONE
          No horizontal text alignment is performed.
static int ALIGNMENT_RIGHT
          Text is aligned to the right margin of the current column.
protected  int baselineOffset
          Text position relative to the baseline (for super-/subscript).
static com.klg.jclass.page.JCTextStyle BOLD
          Bold text style.
static com.klg.jclass.page.JCTextStyle BOLD_ITALIC
          Bold/italic text style.
static com.klg.jclass.page.JCTextStyle CODE
          A text style designed for printing code samples.
static com.klg.jclass.page.JCTextStyle CODE_INDENTED
          An indented text style designed for printing code samples.
protected  Color color
          Color the text is to be drawn in.
static com.klg.jclass.page.JCTextStyle DEFAULT_HEADER
          A default text style for headers.
static com.klg.jclass.page.JCTextStyle DEFAULT_TEXT
          A default (standard, unornamented) text style.
protected  Font font
          The particular font to use to render the text.
protected  String fontFamily
          The font family to which this font belongs.
protected  int fontStyle
          The style (Regular, Bold, Italic) to be used in drawing the text.
static com.klg.jclass.page.JCTextStyle HEADING
          A heading text style.
static com.klg.jclass.page.JCTextStyle HEADING_BOLD
          A bold heading text style.
static com.klg.jclass.page.JCTextStyle HEADING1
          A major (top-level) heading text style.
static com.klg.jclass.page.JCTextStyle HEADING2
          A secondary (second-level) heading text style.
static com.klg.jclass.page.JCTextStyle HEADING3
          Level three heading text style.
static com.klg.jclass.page.JCTextStyle HEADING4
          Level four heading text style.
static com.klg.jclass.page.JCTextStyle HEADING5
          Level five heading text style.
static com.klg.jclass.page.JCTextStyle HEADING6
          Level six heading text style.
static com.klg.jclass.page.JCTextStyle HEADING7
          Level seven heading text style.
protected  boolean immutable
          Flag identifying if the style may be modified.
protected  Map immutableTextStyles
           
static com.klg.jclass.page.JCTextStyle INDENTED
          A text style indented from the column margins.
protected  JCUnit.Measure indentLeft
          Amount of white space to leave as indentation from the left margin.
protected  JCUnit.Measure indentParagraph
          The indentation from the left margin for the first line of a paragraph.
protected  JCUnit.Measure indentRight
          Amount of white space to leave as indentation from the right margin.
protected static TreeMap instanceCollection
          A list containing references to all named style instances.
static com.klg.jclass.page.JCTextStyle ITALIC
          Italic text style.
static int LINEMODE_NONE
          No underlining is done.
static int LINEMODE_UNDERLINE
          A single underline is drawn.
protected  double lineSpacing
          Spacing to leave between lines of text (multiple of line height).
protected  String name
          The unique name of the style.
static com.klg.jclass.page.JCTextStyle NORMAL
          Normal (upright, medium weight) text style.
static int OFFSET_NONE
          The text is placed on the text baseline.
static int OFFSET_SUBSCRIPT
          The text is placed below the text baseline as a subscript.
static int OFFSET_SUPERSCRIPT
          The text is placed above the text baseline as a superscript.
protected  double paragraphSpacing
          Spacing to leave between paragraphs (multiple of line height).
static com.klg.jclass.page.JCTextStyle PLAIN
          Plain (== Normal) text style.
protected  double pointSize
          The point size of the standard text described by this style.
protected static int styleCount
          Count of the number of instances of the class.
protected  double subscriptRatio
          The point size reduction factor to super-/subscript size.
protected  List tabList
          All the tabs (in order) maintained by the style.
protected static String UNAMED_STYLE_PREFIX
           
protected  int underline
          Underlining mode (enumerated type).
static com.klg.jclass.page.JCTextStyle WHITE_BOLD
          White, Bold text style.
 
Constructor Summary
JCTextStyle()
          Creates a text style with a default name and values.
JCTextStyle(String name)
          Creates a text style with the given name and default values.
JCTextStyle(String name, JCUnit.Measure indent_left, JCUnit.Measure indent_right, JCUnit.Measure indent_paragraph, Color color, List tablist, String font_family, int font_style, double point_size, int underline, int alignment, double subscript_ratio, int baseline_offset, double line_spacing, double paragraph_spacing, boolean immutable)
          Creates a text style with the given name and values.
 
Method Summary
 void addTab(int alignment, JCUnit.Measure position)
          Sets a tab stop in this style.
 void addTab(com.klg.jclass.page.JCTab tab)
          Sets the given tab as a tab stop in this style.
 Object clone()
          Returns a style which is a copy of this one.
 void deleteTab(JCUnit.Measure position)
          Removes the tab at a given position.
 void deleteTabs()
          Removes all tabs from this style.
 boolean equals(Object o)
          Text styles with the same properties are considered equal regardless of their names.
 int getAlignment()
          Gets the text alignment mode within a paragraph.
 int getBaselineOffset()
          Gets the offset from the normal baseline of the text.
 Color getColor()
          Gets the color which is used to paint the text.
 Font getFont()
          Gets the font which is used for rendering text.
 String getFontFamily()
          Gets the font family to which this the font belongs.
 int getFontStyle()
          Gets the writing style (italic, bold) of the font.
 com.klg.jclass.page.JCTextStyle getImmutable()
          Returns this object if it is already immutable; otherwise, checks to see if a style with the same properties already exists in the immutable cache and returns it.
 JCUnit.Measure getLeftIndent()
          Gets the amount of space to move text in from the left margin.
 double getLineSpacing()
          Gets the line spacing as a factor of the text height.
 String getName()
          Gets the name of the style.
 JCUnit.Measure getParagraphIndent()
          Gets the amount of space to indent the first line of a paragraph.
 double getParagraphSpacing()
          Gets the paragraph spacing as a factor of the text height.
 double getPointSize()
          Gets the style's defined point size.
 JCUnit.Measure getRightIndent()
          Gets the amount of space to move text in from the right margin.
static Map getStyleList()
          Returns the entire style Map.
static Iterator getStyles()
          Provides an iterator over all immutable styles.
 double getSubscriptRatio()
          Gets the ratio of sub-/superscript text to normal text.
 List getTabs()
          Gets the list of tabs from the style.
 int getUnderlining()
          Gets the underlining mode this style is applying.
 int hashCode()
          Creates a hash that generates the same value depending on the property values.
 boolean isMutable()
          Determines if the style can be modified.
 void makeImmutable()
          Sets the style to immutable so it can no longer be modified.
 void setAlignment(int alignment)
          Sets the text alignment mode within a paragraph.
 void setBaselineOffset(int baseline_offset)
          Sets the position of the text relative to the normal baseline.
 void setColor(Color color)
          Sets the color to be used to paint the text.
 void setFont(Font font)
          Sets the font which is used for rendering text.
 void setFontFamily(String font_family)
          Sets the font family from which fonts and styles are selected.
 void setFontStyle(int font_style)
          Sets the writing style (italic, bold) of the font.
 void setLeftIndent(JCUnit.Measure indent_width)
          Specifies the amount of space between the left margin and the start of text.
 void setLineSpacing(double spacing)
          Sets the line spacing (top of line to top) as a multiple of text height.
 void setName(String name)
          Sets a name for the style.
 void setParagraphIndent(JCUnit.Measure indent_width)
          Specifies the amount of space before the first line of text in a paragraph.
 void setParagraphSpacing(double spacing)
          Sets the paragraph spacing (line spacing betweeen paragraphs).
 void setPointSize(double point_size)
          Sets the point size of text using this style.
 void setRightIndent(JCUnit.Measure indent_width)
          Specifies the amount of space between the right margin and the start of text.
 void setSubscriptRatio(double subscript_ratio)
          Sets the ratio of sub-/superscript text to normal text.
 void setTabs(int alignment, JCUnit.Measure spacing, int count)
          Sets a list of regularly-spaced tabs with a common alignment.
 void setTabs(int alignment, JCUnit.Measure first, JCUnit.Measure spacing, int count)
          Sets a list of regularly-spaced tabs with a common alignment.
 void setTabs(int alignment, List positions)
          Sets a list of tabs with a common alignment.
 void setUnderlining(int underline)
          Sets the underlining mode this style is applying.
static com.klg.jclass.page.JCTextStyle stringToStyle(String name)
          Returns the style which matches the given name.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINEMODE_NONE

public static final int LINEMODE_NONE
No underlining is done.

See Also:
Constant Field Values

LINEMODE_UNDERLINE

public static final int LINEMODE_UNDERLINE
A single underline is drawn.

See Also:
Constant Field Values

OFFSET_NONE

public static final int OFFSET_NONE
The text is placed on the text baseline.

See Also:
Constant Field Values

OFFSET_SUBSCRIPT

public static final int OFFSET_SUBSCRIPT
The text is placed below the text baseline as a subscript.

See Also:
Constant Field Values

OFFSET_SUPERSCRIPT

public static final int OFFSET_SUPERSCRIPT
The text is placed above the text baseline as a superscript.

See Also:
Constant Field Values

ALIGNMENT_NONE

public static final int ALIGNMENT_NONE
No horizontal text alignment is performed.

See Also:
Constant Field Values

ALIGNMENT_LEFT

public static final int ALIGNMENT_LEFT
Text is aligned to the left margin of the current column.

See Also:
Constant Field Values

ALIGNMENT_RIGHT

public static final int ALIGNMENT_RIGHT
Text is aligned to the right margin of the current column.

See Also:
Constant Field Values

ALIGNMENT_CENTER

public static final int ALIGNMENT_CENTER
Text is aligned to the center of the current column.

See Also:
Constant Field Values

ALIGNMENT_JUSTIFY

public static final int ALIGNMENT_JUSTIFY
Text is aligned to both the left and right margins of the current column.

See Also:
Constant Field Values

name

protected String name
The unique name of the style.


color

protected Color color
Color the text is to be drawn in.


underline

protected int underline
Underlining mode (enumerated type).


font

protected Font font
The particular font to use to render the text.


fontFamily

protected String fontFamily
The font family to which this font belongs.


fontStyle

protected int fontStyle
The style (Regular, Bold, Italic) to be used in drawing the text.


pointSize

protected double pointSize
The point size of the standard text described by this style.


subscriptRatio

protected double subscriptRatio
The point size reduction factor to super-/subscript size.


baselineOffset

protected int baselineOffset
Text position relative to the baseline (for super-/subscript).


alignment

protected int alignment
Horizontal alignment of text to the frame/column edge.


indentLeft

protected JCUnit.Measure indentLeft
Amount of white space to leave as indentation from the left margin.


indentRight

protected JCUnit.Measure indentRight
Amount of white space to leave as indentation from the right margin.


indentParagraph

protected JCUnit.Measure indentParagraph
The indentation from the left margin for the first line of a paragraph.


lineSpacing

protected double lineSpacing
Spacing to leave between lines of text (multiple of line height).


paragraphSpacing

protected double paragraphSpacing
Spacing to leave between paragraphs (multiple of line height).


tabList

protected List tabList
All the tabs (in order) maintained by the style.


immutable

protected boolean immutable
Flag identifying if the style may be modified.


styleCount

protected static int styleCount
Count of the number of instances of the class.


instanceCollection

protected static TreeMap instanceCollection
A list containing references to all named style instances.


immutableTextStyles

protected Map immutableTextStyles

UNAMED_STYLE_PREFIX

protected static final String UNAMED_STYLE_PREFIX
See Also:
Constant Field Values

NORMAL

public static final com.klg.jclass.page.JCTextStyle NORMAL
Normal (upright, medium weight) text style. The value of the name property for this style is Normal.


PLAIN

public static final com.klg.jclass.page.JCTextStyle PLAIN
Plain (== Normal) text style. The value of the name property for this style is Plain.


BOLD

public static final com.klg.jclass.page.JCTextStyle BOLD
Bold text style. The value of the name property for this style is Bold.


BOLD_ITALIC

public static final com.klg.jclass.page.JCTextStyle BOLD_ITALIC
Bold/italic text style. The value of the name property for this style is Bold Italic.


ITALIC

public static final com.klg.jclass.page.JCTextStyle ITALIC
Italic text style. The value of the name property for this style is Italic.


INDENTED

public static final com.klg.jclass.page.JCTextStyle INDENTED
A text style indented from the column margins. The value of the name property for this style is Indented.


CODE

public static final com.klg.jclass.page.JCTextStyle CODE
A text style designed for printing code samples. The value of the name property for this style is Code.


CODE_INDENTED

public static final com.klg.jclass.page.JCTextStyle CODE_INDENTED
An indented text style designed for printing code samples. The value of the name property for this style is CodeIndented.


HEADING

public static final com.klg.jclass.page.JCTextStyle HEADING
A heading text style. The value of the name property for this style is Heading.


HEADING_BOLD

public static final com.klg.jclass.page.JCTextStyle HEADING_BOLD
A bold heading text style. The value of the name property for this style is HeadingBold.


HEADING1

public static final com.klg.jclass.page.JCTextStyle HEADING1
A major (top-level) heading text style. The value of the name property for this style is H1.


HEADING2

public static final com.klg.jclass.page.JCTextStyle HEADING2
A secondary (second-level) heading text style. The value of the name property for this style is H2.


HEADING3

public static final com.klg.jclass.page.JCTextStyle HEADING3
Level three heading text style. The value of the name property for this style is H3.


HEADING4

public static final com.klg.jclass.page.JCTextStyle HEADING4
Level four heading text style. The value of the name property for this style is H4.


HEADING5

public static final com.klg.jclass.page.JCTextStyle HEADING5
Level five heading text style. The value of the name property for this style is H5.


HEADING6

public static final com.klg.jclass.page.JCTextStyle HEADING6
Level six heading text style. The value of the name property for this style is H6.


HEADING7

public static final com.klg.jclass.page.JCTextStyle HEADING7
Level seven heading text style. The value of the name property for this style is H7.


WHITE_BOLD

public static final com.klg.jclass.page.JCTextStyle WHITE_BOLD
White, Bold text style. The value of the name property for this style is WhiteBold.


DEFAULT_TEXT

public static final com.klg.jclass.page.JCTextStyle DEFAULT_TEXT
A default (standard, unornamented) text style. The value of the name property for this style is default text.


DEFAULT_HEADER

public static final com.klg.jclass.page.JCTextStyle DEFAULT_HEADER
A default text style for headers. The value of the name property for this style is default header.

Constructor Detail

JCTextStyle

public JCTextStyle(String name,
                   JCUnit.Measure indent_left,
                   JCUnit.Measure indent_right,
                   JCUnit.Measure indent_paragraph,
                   Color color,
                   List tablist,
                   String font_family,
                   int font_style,
                   double point_size,
                   int underline,
                   int alignment,
                   double subscript_ratio,
                   int baseline_offset,
                   double line_spacing,
                   double paragraph_spacing,
                   boolean immutable)
Creates a text style with the given name and values.

Parameters:
name - the name by which the new style will be known
indent_left - the distance from the left margin to indent text
indent_right - the distance from the right margin to indent text
indent_paragraph - the left indent for the first line of a paragraph
color - the color to draw the text
tablist - a list of tabs defined for the style
font_family - the font family used to draw text
font_style - the style (bold, italic) used to draw the text
point_size - the size of text (in points)
underline - the style of underlining to use
alignment - the horizontal alignment of text in a column
subscript_ratio - the ratio of the size of subscripts to normal text
baseline_offset - the position of the text (super/subscript)
line_spacing - the distance between lines of text
paragraph_spacing - the distance between lines starting a paragraph
immutable - indicates if the style may be changed or not

JCTextStyle

public JCTextStyle()
Creates a text style with a default name and values.


JCTextStyle

public JCTextStyle(String name)
Creates a text style with the given name and default values.

Parameters:
name - the name to give the new text style
Method Detail

getName

public String getName()
Gets the name of the style.

Returns:
the name used to refer to the style

setName

public void setName(String name)
Sets a name for the style.

Parameters:
name - the new name for the style

getColor

public Color getColor()
Gets the color which is used to paint the text.

Returns:
color assigned to the text

setColor

public void setColor(Color color)
Sets the color to be used to paint the text.

Parameters:
color - color object to assign to the text

getUnderlining

public int getUnderlining()
Gets the underlining mode this style is applying.

Returns:
type of underlining that will be performed

setUnderlining

public void setUnderlining(int underline)
Sets the underlining mode this style is applying.

Parameters:
underline - type of underlining to be performed

getPointSize

public double getPointSize()
Gets the style's defined point size.

Returns:
the point size being applied to text using this style

setPointSize

public void setPointSize(double point_size)
Sets the point size of text using this style.

Parameters:
point_size - the point size to be applied to text using this style

getFont

public Font getFont()
Gets the font which is used for rendering text.

Returns:
the font the style will use to lay out text

setFont

public void setFont(Font font)
Sets the font which is used for rendering text.

Parameters:
font - the font to use for displaying text

getFontFamily

public String getFontFamily()
Gets the font family to which this the font belongs.

Returns:
the font family the font is taken from

setFontFamily

public void setFontFamily(String font_family)
Sets the font family from which fonts and styles are selected.

Parameters:
font_family - the font family that contains the desired font

getFontStyle

public int getFontStyle()
Gets the writing style (italic, bold) of the font.

Returns:
style the font is drawn in

setFontStyle

public void setFontStyle(int font_style)
Sets the writing style (italic, bold) of the font.

Parameters:
font_style - style (angle, weight) used to draw the font Valid arguments are java.awt.Font.PLAIN, java.awt.Font.BOLD, java.awt.Font.ITALIC, and java.awt.Font.BOLD | java.awt.Font.ITALIC>

getBaselineOffset

public int getBaselineOffset()
Gets the offset from the normal baseline of the text.

Returns:
position of the text relative to the normal text baseline

setBaselineOffset

public void setBaselineOffset(int baseline_offset)
Sets the position of the text relative to the normal baseline.

Parameters:
baseline_offset - position of text (superscript/subscript) relative to the normal baseline of the text

getAlignment

public int getAlignment()
Gets the text alignment mode within a paragraph. Valid values are: JCTextStyle.ALIGNMENT_NONE, JCTextStyle.ALIGNMENT_LEFT, JCTextStyle.ALIGNMENT_RIGHT, JCTextStyle.ALIGNMENT_CENTER, and JCTextStyle.ALIGNMENT_JUSTIFY.

Returns:
alignment of lines of text in a paragraph

setAlignment

public void setAlignment(int alignment)
Sets the text alignment mode within a paragraph. Valid values are: JCTextStyle.ALIGNMENT_NONE, JCTextStyle.ALIGNMENT_LEFT, JCTextStyle.ALIGNMENT_RIGHT, JCTextStyle.ALIGNMENT_CENTER, and JCTextStyle.ALIGNMENT_JUSTIFY.

Parameters:
alignment - alignment of lines of text in a paragraph

getLeftIndent

public JCUnit.Measure getLeftIndent()
Gets the amount of space to move text in from the left margin.

Returns:
text indentation space on the left

setLeftIndent

public void setLeftIndent(JCUnit.Measure indent_width)
Specifies the amount of space between the left margin and the start of text.

Parameters:
indent_width - space to indent text on the left side

getRightIndent

public JCUnit.Measure getRightIndent()
Gets the amount of space to move text in from the right margin.

Returns:
text indentation space on the right

setRightIndent

public void setRightIndent(JCUnit.Measure indent_width)
Specifies the amount of space between the right margin and the start of text.

Parameters:
indent_width - space to indent text on the right side

getParagraphIndent

public JCUnit.Measure getParagraphIndent()
Gets the amount of space to indent the first line of a paragraph.

Returns:
text indentation space on the left of the first paragraph line

setParagraphIndent

public void setParagraphIndent(JCUnit.Measure indent_width)
Specifies the amount of space before the first line of text in a paragraph.

Parameters:
indent_width - space to indent text for the beginning of a paragraph

getLineSpacing

public double getLineSpacing()
Gets the line spacing as a factor of the text height.

Returns:
number of times to advance the line based on the text height

setLineSpacing

public void setLineSpacing(double spacing)
Sets the line spacing (top of line to top) as a multiple of text height.

Parameters:
spacing - the multiple of the text height to advance between lines

getParagraphSpacing

public double getParagraphSpacing()
Gets the paragraph spacing as a factor of the text height.

Returns:
factor to advance the between paragraphs based on the text height

setParagraphSpacing

public void setParagraphSpacing(double spacing)
Sets the paragraph spacing (line spacing betweeen paragraphs).

Parameters:
spacing - text height multiplier for inter-paragraph line spacing

getTabs

public List getTabs()
Gets the list of tabs from the style.

Returns:
the style's list of tabs

addTab

public void addTab(com.klg.jclass.page.JCTab tab)
Sets the given tab as a tab stop in this style.

Parameters:
tab - the tab object to add to this style's list of tabs

addTab

public void addTab(int alignment,
                   JCUnit.Measure position)
Sets a tab stop in this style.

Parameters:
alignment - the behavior of flowed objects aligning to the new tab
position - the horizontal location of the tab across the line

setTabs

public void setTabs(int alignment,
                    List positions)
Sets a list of tabs with a common alignment.

Parameters:
alignment - the alignment of flowed objects to the tab locations
positions - a List of positions for the tabs

setTabs

public void setTabs(int alignment,
                    JCUnit.Measure spacing,
                    int count)
Sets a list of regularly-spaced tabs with a common alignment.

Parameters:
alignment - the alignment of flowed objects to the tab locations
spacing - the spacing between tabs
count - the number of tabs to be added

setTabs

public void setTabs(int alignment,
                    JCUnit.Measure first,
                    JCUnit.Measure spacing,
                    int count)
Sets a list of regularly-spaced tabs with a common alignment.

Parameters:
alignment - the alignment of flowed objects to the tab locations
first - the location of the first tab on the line
spacing - the spacing between tabs
count - the number of tabs to be added

deleteTabs

public void deleteTabs()
Removes all tabs from this style.


deleteTab

public void deleteTab(JCUnit.Measure position)
Removes the tab at a given position.

Parameters:
position - the location of the tab which is to be cleared

getSubscriptRatio

public double getSubscriptRatio()
Gets the ratio of sub-/superscript text to normal text.

Returns:
factor used to compute sub-/superscript text size from the font size

setSubscriptRatio

public void setSubscriptRatio(double subscript_ratio)
Sets the ratio of sub-/superscript text to normal text.

Parameters:
subscript_ratio - the scaling factor to derive subscript text size

isMutable

public boolean isMutable()
Determines if the style can be modified.

Returns:
true or false, depending whether or not the style can be modified

makeImmutable

public void makeImmutable()
Sets the style to immutable so it can no longer be modified.


clone

public Object clone()
Returns a style which is a copy of this one.

Overrides:
clone in class Object
Returns:
a new style with all significant fields copied

getStyles

public static Iterator getStyles()
Provides an iterator over all immutable styles.

Returns:
an iterator over the style class's underlying SortedMap

getStyleList

public static Map getStyleList()
Returns the entire style Map.

Returns:
a Map interface to the styles

stringToStyle

public static com.klg.jclass.page.JCTextStyle stringToStyle(String name)
Returns the style which matches the given name.

Parameters:
name - the name of an existing style
Returns:
the style object which has that name

hashCode

public int hashCode()
Creates a hash that generates the same value depending on the property values.

Overrides:
hashCode in class Object
Returns:

equals

public boolean equals(Object o)
Text styles with the same properties are considered equal regardless of their names.

Overrides:
equals in class Object
Parameters:
o -
Returns:

getImmutable

public com.klg.jclass.page.JCTextStyle getImmutable()
Returns this object if it is already immutable; otherwise, checks to see if a style with the same properties already exists in the immutable cache and returns it. If there is no cached style, then this style is cloned, making it immutable, stored in the cache, and returned.

Returns:

Copyright © 2004 Quest Software Inc..
All rights reserved.