ru.novosoft.dc.rtf.dom
Class CharacterContext

java.lang.Object
  |
  +--ru.novosoft.dc.rtf.dom.ShadingContext
        |
        +--ru.novosoft.dc.rtf.dom.CharacterContext

public class CharacterContext
extends ShadingContext
implements CharacterUnderline, CharacterShape

Character formatting context. The following character formatting properties are not implemented here: animation, accent controls, character style, grid controls, text fitting, language controls, left-to-right/right-to-left controls, and associated font and character properties.


Fields inherited from interface ru.novosoft.dc.rtf.dom.objects.CharacterUnderline
CONTINUOUS, DASH, DASH_DOT, DASH_DOT_DOT, DOTTED, DOUBLE, DOUBLE_WAVE, HEAVY_WAVE, LONG_DASH, NONE, THICK, THICK_DASH, THICK_DASH_DOT, THICK_DASH_DOT_DOT, THICK_DOTTED, THICK_LONG_DASH, WAVE, WORDS_ONLY
 
Fields inherited from interface ru.novosoft.dc.rtf.dom.objects.CharacterShape
ALL_CAPS, BOLD, DELETED, DOUBLE_STRIKE, EMBOSS, ENGRAVE, HIDDEN, ITALIC, M_ALL, M_ALL_CAPS, M_BOLD, M_DELETED, M_DOUBLE_STRIKE, M_EMBOSS, M_ENGRAVE, M_HIDDEN, M_ITALIC, M_OUTLINE, M_REVISED, M_SHADOW, M_SMALL_CAPS, M_STRIKE, M_SUBSCRIPT, M_SUPERSCRIPT, M_WEB_HIDDEN, OUTLINE, REVISED, SHADOW, SMALL_CAPS, STRIKE, SUBSCRIPT, SUPERSCRIPT, WEB_HIDDEN
 
Constructor Summary
CharacterContext()
          Construct a character formatting context.
 
Method Summary
 Border border()
          Return the border or null if no border defined.
 int characterShape()
          Return the current character shape (see CharacterShape).
 CharacterSpacing characterSpacing()
          Return the current character spacing object or null if no spacing parameters specified.
 void clearForMerge()
          Clear font, shading, and underline style for further merge another character context with this context (this context is considered as a templated aplied to another context).
 void clearShape(int bitNumber)
          Clear a specified bit in the character shape.
 void clearShapeByMask(int mask)
          Clear bits of the character shape by the specified mask.
 java.lang.Object clone()
          Create a clone of this context.
 Border defineBorder()
          Define a new border and return it.
 void defineSpacing(int index, int value)
          Define a character spacing parameter of the specified index.
 boolean equals(java.lang.Object obj)
          Compare this context with another character context and return true if contexts coinside.
static java.lang.String exportShape(int shape)
          Export a font shape code to string representation.
 void exportTo(org.w3c.dom.Element elem)
          Export the contents of this object to the specified DOM element.
 RTFColor fillColor()
          Return the current fill color which will be either highlight color, or background color, if no highlighting specified, or null, if both highlight and background color do not specified.
 RTFColor getBackgroundColor()
          Return the background color or null if it was not specified.
 RTFFont getFont()
          Return the current font.
 int getFontSize()
          Return the current font size in half-points.
 RTFColor getForegroundColor()
          Return the foreground color or null if it was not specified.
 int getStyle()
          Return the style number.
 RTFColor getUnderlineColor()
          Return the underline color or null if it was not specified.
 int getUnderlineStyle()
          Return the current underline style (CharacterUnderline.NONE means no underlining).
 boolean hasBorder()
          Return true if a border is defined in this context.
 boolean hasHighlighting()
          Return true if a highlight color is specified.
 boolean hasShape(int bitNumber)
          Return true if a specified bit in the character shape is equal to 1.
 void highlight(RTFColor value)
          Set a highlight color (the reset method has no affect on the highlight color).
 void mergeWith(CharacterContext context)
          Add properties defined in context passed in the parameter to this context.
 void reset()
          Restore the character formatting properties to defaults.
 void setBackgroundColor(RTFColor value)
          Set a background color.
 void setFont(RTFFont value)
          Set a font.
 void setFontSize(int value)
          Set a font size in half-points.
 void setForegroundColor(RTFColor value)
          Set a foreground color.
 void setShape(int bitNumber)
          Set a specified bit in the character shape.
 void setShapeByMask(int mask)
          Set bits of the character shape by the specified mask.
 void setStyle(int value)
          Set a style number (222 means no style).
 void setUnderlineColor(RTFColor value)
          Set an underline color.
 void setUnderlineStyle(int value)
          Set an underline style.
 
Methods inherited from class ru.novosoft.dc.rtf.dom.ShadingContext
defineShadingBackground, defineShadingFill, defineShadingStyle, exportTo, shading
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharacterContext

public CharacterContext()
Construct a character formatting context.
Method Detail

setFont

public final void setFont(RTFFont value)
Set a font.

getFont

public final RTFFont getFont()
Return the current font.

setFontSize

public final void setFontSize(int value)
Set a font size in half-points.

getFontSize

public final int getFontSize()
Return the current font size in half-points.

setStyle

public final void setStyle(int value)
Set a style number (222 means no style).

getStyle

public final int getStyle()
Return the style number.

setBackgroundColor

public final void setBackgroundColor(RTFColor value)
Set a background color.

getBackgroundColor

public final RTFColor getBackgroundColor()
Return the background color or null if it was not specified.

setForegroundColor

public final void setForegroundColor(RTFColor value)
Set a foreground color.

getForegroundColor

public final RTFColor getForegroundColor()
Return the foreground color or null if it was not specified.

setUnderlineColor

public final void setUnderlineColor(RTFColor value)
Set an underline color.

getUnderlineColor

public final RTFColor getUnderlineColor()
Return the underline color or null if it was not specified.

setUnderlineStyle

public final void setUnderlineStyle(int value)
Set an underline style.

getUnderlineStyle

public final int getUnderlineStyle()
Return the current underline style (CharacterUnderline.NONE means no underlining).

highlight

public final void highlight(RTFColor value)
Set a highlight color (the reset method has no affect on the highlight color).

hasHighlighting

public final boolean hasHighlighting()
Return true if a highlight color is specified.

fillColor

public final RTFColor fillColor()
Return the current fill color which will be either highlight color, or background color, if no highlighting specified, or null, if both highlight and background color do not specified.

hasBorder

public final boolean hasBorder()
Return true if a border is defined in this context.

defineBorder

public final Border defineBorder()
Define a new border and return it.

border

public final Border border()
Return the border or null if no border defined.

setShapeByMask

public final void setShapeByMask(int mask)
Set bits of the character shape by the specified mask. For example, setShapeByMask(CharacterShape.M_BOLD | CharacterShape.M_ITALIC) sets the bold and italic shape properties.

clearShapeByMask

public final void clearShapeByMask(int mask)
Clear bits of the character shape by the specified mask. For example, clearShapeByMask(CharacterShape.M_ALL) clears all shape properties.

setShape

public final void setShape(int bitNumber)
Set a specified bit in the character shape.

clearShape

public final void clearShape(int bitNumber)
Clear a specified bit in the character shape.

hasShape

public final boolean hasShape(int bitNumber)
Return true if a specified bit in the character shape is equal to 1.

characterShape

public final int characterShape()
Return the current character shape (see CharacterShape).

defineSpacing

public final void defineSpacing(int index,
                                int value)
Define a character spacing parameter of the specified index.

characterSpacing

public final CharacterSpacing characterSpacing()
Return the current character spacing object or null if no spacing parameters specified.

clearForMerge

public void clearForMerge()
Clear font, shading, and underline style for further merge another character context with this context (this context is considered as a templated aplied to another context).

mergeWith

public void mergeWith(CharacterContext context)
Add properties defined in context passed in the parameter to this context. Shape properties are logically added. Highligh property does not applied. To forbid apply of font size or underline style property, set a negative value for it before this call.

reset

public void reset()
Restore the character formatting properties to defaults. The current font does not restored to its default by this method. The restoring of font is provided in the innner encoding processor of FontTableProcessor when the "plain" command is parsed. The highlight color is not removed by this method because it does not belong to the character formatting properties as described in the RTF Specification 1.6 (it always used within an inner group with respect to the "plain" command).
Overrides:
reset in class ShadingContext

clone

public java.lang.Object clone()
Create a clone of this context.
Overrides:
clone in class ShadingContext

equals

public boolean equals(java.lang.Object obj)
Compare this context with another character context and return true if contexts coinside.
Overrides:
equals in class ShadingContext

exportTo

public void exportTo(org.w3c.dom.Element elem)
Export the contents of this object to the specified DOM element.

exportShape

public static java.lang.String exportShape(int shape)
Export a font shape code to string representation.