chemaxon.struc.graphics
Class MFont

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

public class MFont
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Font wrapper class that does not require an X server.

Since:
Marvin 4.1, 11/29/2005
Version:
4.1, 03/24/2006
Author:
Peter Csizmadia
See Also:
Serialized Form

Field Summary
static int BOLD
          Bold font style.
static int ITALIC
          Italic font style.
static int PLAIN
          Plain font style.
 
Constructor Summary
MFont(java.awt.Font f)
          Create a wrapper for the specified AWT font.
MFont(MFont f)
          Copy constructor.
MFont(java.lang.String str)
          Parses a font from a string.
MFont(java.lang.String family, int style, double size)
          Contructs a font.
 
Method Summary
 java.lang.Object clone()
          Creates a clone.
 MFont cloneMFont()
          Creates a clone.
 boolean equals(java.lang.Object o)
          Tests whether two font objects equal.
 java.awt.Font getAWTFont()
          Gets an AWT font instance.
 java.lang.String getFamily()
          Gets the font family name.
 java.awt.Font getScaledAWTFont(java.lang.Float scale)
          Gets an AWT font instance after scaling.
 double getSizeDouble()
          Gets the font size.
 java.lang.String getString()
          Gets the string representation.
 int getStyle()
          Gets the font style.
 boolean isBold()
          Tests whether the font is bold.
 boolean isItalic()
          Tests whether the font is italic.
static java.lang.String sizeToString(double size)
          Converts an integer or fractional size to a string.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAIN

public static final int PLAIN
Plain font style.

See Also:
Constant Field Values

BOLD

public static final int BOLD
Bold font style.

See Also:
Constant Field Values

ITALIC

public static final int ITALIC
Italic font style.

See Also:
Constant Field Values
Constructor Detail

MFont

public MFont(java.lang.String family,
             int style,
             double size)
Contructs a font.

Parameters:
family - the family
style - the style
size - the size

MFont

public MFont(java.lang.String str)
      throws java.lang.IllegalArgumentException
Parses a font from a string.

Parameters:
str - the string to be converted
Throws:
java.lang.IllegalArgumentException

MFont

public MFont(MFont f)
Copy constructor.

Parameters:
f - the font to copy

MFont

public MFont(java.awt.Font f)
Create a wrapper for the specified AWT font.

Parameters:
f - the AWT font
Method Detail

getFamily

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

Returns:
the font family

getStyle

public int getStyle()
Gets the font style.

Returns:
the font style

getSizeDouble

public double getSizeDouble()
Gets the font size.

Returns:
the font size

isBold

public boolean isBold()
Tests whether the font is bold.

Returns:
true if the font is bold, false otherwise

isItalic

public boolean isItalic()
Tests whether the font is italic.

Returns:
true if the font is italic, false otherwise

getAWTFont

public java.awt.Font getAWTFont()
Gets an AWT font instance.

Returns:
the AWT font

getScaledAWTFont

public java.awt.Font getScaledAWTFont(java.lang.Float scale)
Gets an AWT font instance after scaling.

Parameters:
scale - the scaling factor
Returns:
the AWT font

getString

public java.lang.String getString()
Gets the string representation.

Returns:
the string representation

equals

public boolean equals(java.lang.Object o)
Tests whether two font objects equal.

Overrides:
equals in class java.lang.Object
Returns:
true if they are equal, false otherwise

cloneMFont

public MFont cloneMFont()
Creates a clone.

Returns:
the clone

clone

public java.lang.Object clone()
Creates a clone.

Overrides:
clone in class java.lang.Object
Returns:
the clone

sizeToString

public static java.lang.String sizeToString(double size)
Converts an integer or fractional size to a string.

Returns:
the string