chemaxon.struc.graphics
Class MTextAttributes

java.lang.Object
  extended by chemaxon.struc.graphics.MTextAttributes
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class MTextAttributes
extends java.lang.Object
implements java.io.Externalizable

Text attributes. This class is immutable (constant), attributes can only be set by the constructors.

Since:
Marvin 4.1, 10/05/2005
Version:
5.0, 03/23/2007
Author:
Peter Csizmadia
See Also:
Serialized Form

Field Summary
static int A_ALL
          All identifiers.
static int A_BOLD
          Identifier of the font's bold subattribute.
static int A_DX
          Identifier of the x shift attribute.
static int A_DY
          Identifier of the y shift attribute.
static int A_FONT
          Identifier of the font attribute.
static int A_FONT_BITS
          All font bits.
static int A_FONTFAMILY
          Identifier of the font family subattribute.
static int A_FONTSIZE
          Identifier of the font size subattribute.
static int A_FOREGROUND
          Identifier of the color attribute.
static int A_ITALIC
          Identifier of the font's italic subattribute.
static int A_SCALE
          Identifier of the font scale attribute.
static int A_SUBLEVEL
          Identifier of the subscript/superscript level attribute.
static MTextAttributes DEFAULT
          Default attributes object.
static double DEFAULT_SUPERSCRIPT_DELTAY
          Default value of the y shift attribute in superscripts
static double DEFAULT_SUPERSCRIPT_SCALE
          Default value of the font scale attribute in superscripts
static int DEFAULT_SUPERSCRIPT_SUBLEVEL
          Default value of the superscript level attribute in superscripts
 
Constructor Summary
MTextAttributes(int set, int subl, java.awt.Color c, MFont ft, double scale, double dx, double dy)
          Constructs a attributes object.
 
Method Summary
 MTextAttributes createCompatible(MTextAttributes newCommon, MTextAttributes origCommon, MFont deffnt, chemaxon.struc.graphics.MTextAttributes.MFontCreator ftcreator)
           
 MTextAttributes createNext()
          Creates identical attributes for the next section.
 MTextAttributes decode(java.lang.String str, MFont deffnt, chemaxon.struc.graphics.MTextAttributes.MFontCreator fntcreator)
          Reads attributes of the next section from a string.
 java.lang.String encode(MFont deffnt, MTextAttributes prev)
          Returns the string representation of the attributes.
 boolean equals(MTextAttributes o)
          Tests whether two attributes objects equal or not.
 boolean equals(java.lang.Object o)
          Tests whether two attributes objects equal or not.
 boolean equalsNext(MTextAttributes o)
          Tests whether the attributes of two neighboring sections equal or not.
 MFont getBaseFont()
          Gets the base font.
 MTextAttributes getCompatibleAttributes(MTextAttributes attr, MFont deffnt, chemaxon.struc.graphics.MTextAttributes.MFontCreator ftcreator, int set0)
          Gets the compatible attributes.
 double getDx()
          Gets the x shift.
 double getDy()
          Gets the y shift.
 java.lang.String getFontFamily()
          Gets the font family name.
 java.awt.Color getForeground()
          Gets the foreground color.
 double getScale()
          Gets the relative size of the font compared to the base font.
 int getSet()
          Gets the set of attributes used.
 byte getSubLevel()
          Gets the subscript/superscript level.
 boolean isCompatible(MTextAttributes newCommon, MTextAttributes origCommon, MFont deffnt)
          Tests whether two attribute sets are compatible.
 boolean isDefault()
          Tests whether all attributes have default values.
 boolean isFontDefault(MFont deffnt)
          Tests whether the default font is used.
 boolean isFontRegular()
          Tests whether the default font is used.
 void readExternal(java.io.ObjectInput in)
           
 java.lang.String toString()
          Returns the string representation of the attributes.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final MTextAttributes DEFAULT
Default attributes object.


A_SUBLEVEL

public static final int A_SUBLEVEL
Identifier of the subscript/superscript level attribute.

See Also:
Constant Field Values

A_FOREGROUND

public static final int A_FOREGROUND
Identifier of the color attribute.

See Also:
Constant Field Values

A_FONT

public static final int A_FONT
Identifier of the font attribute.

See Also:
Constant Field Values

A_FONTFAMILY

public static final int A_FONTFAMILY
Identifier of the font family subattribute.

See Also:
Constant Field Values

A_FONTSIZE

public static final int A_FONTSIZE
Identifier of the font size subattribute.

See Also:
Constant Field Values

A_BOLD

public static final int A_BOLD
Identifier of the font's bold subattribute.

See Also:
Constant Field Values

A_ITALIC

public static final int A_ITALIC
Identifier of the font's italic subattribute.

See Also:
Constant Field Values

A_FONT_BITS

public static final int A_FONT_BITS
All font bits.

See Also:
Constant Field Values

A_SCALE

public static final int A_SCALE
Identifier of the font scale attribute.

See Also:
Constant Field Values

A_DX

public static final int A_DX
Identifier of the x shift attribute.

See Also:
Constant Field Values

A_DY

public static final int A_DY
Identifier of the y shift attribute.

See Also:
Constant Field Values

A_ALL

public static final int A_ALL
All identifiers.

See Also:
Constant Field Values

DEFAULT_SUPERSCRIPT_SCALE

public static final double DEFAULT_SUPERSCRIPT_SCALE
Default value of the font scale attribute in superscripts

See Also:
Constant Field Values

DEFAULT_SUPERSCRIPT_DELTAY

public static final double DEFAULT_SUPERSCRIPT_DELTAY
Default value of the y shift attribute in superscripts

See Also:
Constant Field Values

DEFAULT_SUPERSCRIPT_SUBLEVEL

public static final int DEFAULT_SUPERSCRIPT_SUBLEVEL
Default value of the superscript level attribute in superscripts

See Also:
Constant Field Values
Constructor Detail

MTextAttributes

public MTextAttributes(int set,
                       int subl,
                       java.awt.Color c,
                       MFont ft,
                       double scale,
                       double dx,
                       double dy)
Constructs a attributes object.

Parameters:
set - bits corresponding to the attributes set
subl - the subscript/superscript level
c - the color
ft - the font
scale - the font scale
dx - the x shift
dy - the y shift
See Also:
A_SUBLEVEL, A_FOREGROUND, A_FONT, A_FONTFAMILY, A_FONTSIZE, A_BOLD, A_ITALIC, A_SCALE, A_DX, A_DY
Method Detail

getSet

public int getSet()
Gets the set of attributes used.

Returns:
the set
See Also:
A_SUBLEVEL, A_FOREGROUND, A_FONT, A_FONTFAMILY, A_FONTSIZE, A_BOLD, A_ITALIC, A_SCALE, A_DX, A_DY

decode

public MTextAttributes decode(java.lang.String str,
                              MFont deffnt,
                              chemaxon.struc.graphics.MTextAttributes.MFontCreator fntcreator)
                       throws java.lang.IllegalArgumentException
Reads attributes of the next section from a string.

Parameters:
str - the string
deffnt - the default font
fntcreator - the font creator
Throws:
java.lang.IllegalArgumentException

getSubLevel

public byte getSubLevel()
Gets the subscript/superscript level.

Returns:
the subscript/superscript level or 0

getForeground

public java.awt.Color getForeground()
Gets the foreground color.

Returns:
the color

getBaseFont

public MFont getBaseFont()
Gets the base font.

Returns:
the base font or null

getFontFamily

public java.lang.String getFontFamily()
Gets the font family name.

Returns:
the font family name

getScale

public double getScale()
Gets the relative size of the font compared to the base font.

Returns:
the font scale

getDx

public double getDx()
Gets the x shift.

Returns:
the shift

getDy

public double getDy()
Gets the y shift.

Returns:
the shift

isDefault

public boolean isDefault()
Tests whether all attributes have default values.

Returns:
true if all attributes are null or zero, false if there is at least one nondefault property

isFontDefault

public boolean isFontDefault(MFont deffnt)
Tests whether the default font is used.

Parameters:
deffnt - the default font
Returns:
true if the default font is used, false otherwise

isFontRegular

public boolean isFontRegular()
Tests whether the default font is used.

Returns:
true if the default font is used, false otherwise

toString

public java.lang.String toString()
Returns the string representation of the attributes.

Overrides:
toString in class java.lang.Object
Returns:
the string

encode

public java.lang.String encode(MFont deffnt,
                               MTextAttributes prev)
Returns the string representation of the attributes. The returned string is written in the MRV file.

Parameters:
deffnt - the default font
prev - attributes of the previous section or null
Returns:
the string

equalsNext

public boolean equalsNext(MTextAttributes o)
Tests whether the attributes of two neighboring sections equal or not.

Parameters:
o - attributes of the next section
Returns:
true if the attributes equals, false otherwise

equals

public boolean equals(MTextAttributes o)
Tests whether two attributes objects equal or not.

Parameters:
o - other attributes
Returns:
true if the attributes equals, false otherwise

equals

public boolean equals(java.lang.Object o)
Tests whether two attributes objects equal or not.

Overrides:
equals in class java.lang.Object
Parameters:
o - other attributes
Returns:
true if the attributes equals, false otherwise

isCompatible

public boolean isCompatible(MTextAttributes newCommon,
                            MTextAttributes origCommon,
                            MFont deffnt)
Tests whether two attribute sets are compatible.

Parameters:
newCommon - the new common attributes
origCommon - the original common attributes
deffnt - default font
Returns:
true if the attribute sets equal, false otherwise
See Also:
A_SUBLEVEL, A_FOREGROUND, A_FONT, A_FONTFAMILY, A_FONTSIZE, A_BOLD, A_ITALIC, A_SCALE, A_DX, A_DY

getCompatibleAttributes

public MTextAttributes getCompatibleAttributes(MTextAttributes attr,
                                               MFont deffnt,
                                               chemaxon.struc.graphics.MTextAttributes.MFontCreator ftcreator,
                                               int set0)
Gets the compatible attributes.

Parameters:
attr - the other attributes object
deffnt - the default font
ftcreator - the font creator
set0 - the initial set or 0
Returns:
two-element array, first element is the attributes object, second element is an integer specifying the subset of attributes
See Also:
isCompatible(MTextAttributes, MTextAttributes, MFont)

createCompatible

public MTextAttributes createCompatible(MTextAttributes newCommon,
                                        MTextAttributes origCommon,
                                        MFont deffnt,
                                        chemaxon.struc.graphics.MTextAttributes.MFontCreator ftcreator)

createNext

public MTextAttributes createNext()
Creates identical attributes for the next section.

Returns:
the new attributes

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException