ru.novosoft.dc.rtf.dom.objects
Class ParagraphSpacing

java.lang.Object
  |
  +--ru.novosoft.dc.rtf.dom.objects.ParagraphSpacing

public final class ParagraphSpacing
extends java.lang.Object
implements java.lang.Cloneable

The paragraph spacing specification class. It contains 3 spacing parameters and 3 flags determining spacing types. Paragraph spacing parameters include a spacing before the paragraph, after the paragraph, and between paragraph lines. All spacings are specified in twips in the internal array. Their indices are described with constants of this class.

Spacings before and after a paragraph can have an "absolute" or "auto" type. If a spacing has an "absolute" type its value is specified by the corresponding spacing parameter. If a spacing has an "auto" type and HTML paragraph auto spacing is turned on, its real value must be ignored and replaced to approximately one-line spacing of 240 twips. Without HTML paragraph auto spacing, the "auto" type is treated as "absolute" type.

The spacing between lines can have an "absolute" or "multiple" type. In the first case, its value is specified by the spacing parameter of the LINE index. In the last case, its value is the multiple for the normal line spacing calculated as the ratio of two spacing parameters indexed as LINE and FONT. In other words, the line spacing multiple is equal to getSpacing(LINE)/getSpacing(FONT). The parameter with the FONT index should be specified in the "multiple" case. In the absolute case, it can be unspecified.

The line spacing could be any integer value. If spacing is equal to zero (this is the default value), the line spacing is automatically determined by the tallest character in the line. If it is a positive value, this size is used only if it is taller than the tallest character (otherwise, the tallest character is used). If it is a negative value, its absolute value is used, even if it is shorter than the tallest character.


Field Summary
static byte AFTER
          The index of spacing after a paragraph.
static byte BEFORE
          The index of spacing before a paragraph.
static byte FONT
          The index of base font size for line-spacing of the multiple kind.
static byte LINE
          The index of line spacing.
 
Constructor Summary
ParagraphSpacing()
           
 
Method Summary
 java.lang.Object clone()
          Creates a deep copy of this object.
 boolean equals(java.lang.Object obj)
          Compare this object with another paragraph spacing and return true if spacings coinside.
 void exportTo(org.w3c.dom.Element elem)
          Export the contents of this object to the specified DOM element.
 int getSpacing(int index)
          Return the value of the spacing of the specified index.
 boolean isAbsolute(int index)
          Return true if the spacing of the specified index has the "absolute" type.
 void setSpacing(int index, int value)
          Set a value in twips for the spacing of the specified index.
 void setSpacingType(int index, boolean absolute)
          Set a type for the spacing of the specified index: the true value of the last parameter means the "absolute" type (default) and the false means another type.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEFORE

public static final byte BEFORE
The index of spacing before a paragraph.

AFTER

public static final byte AFTER
The index of spacing after a paragraph.

LINE

public static final byte LINE
The index of line spacing.

FONT

public static final byte FONT
The index of base font size for line-spacing of the multiple kind.
Constructor Detail

ParagraphSpacing

public ParagraphSpacing()
Method Detail

setSpacing

public final void setSpacing(int index,
                             int value)
Set a value in twips for the spacing of the specified index.

getSpacing

public final int getSpacing(int index)
Return the value of the spacing of the specified index.

setSpacingType

public final void setSpacingType(int index,
                                 boolean absolute)
Set a type for the spacing of the specified index: the true value of the last parameter means the "absolute" type (default) and the false means another type.

isAbsolute

public final boolean isAbsolute(int index)
Return true if the spacing of the specified index has the "absolute" type.

clone

public java.lang.Object clone()
Creates a deep copy of this object.
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compare this object with another paragraph spacing and return true if spacings coinside.
Overrides:
equals in class java.lang.Object

exportTo

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