chemaxon.struc
Class MObject

java.lang.Object
  extended bychemaxon.struc.MObject
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
MPoint

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

Paintable object. This class and its subclasses are under development, use them at your own risk!

Since:
3.3, 10/18/2003
Version:
3.3, 01/06/2004
Author:
Peter Csizmadia
See Also:
Serialized Form

Field Summary
static int PAINT_ANTIALIAS
          Antialias flag.
static int PAINT_FOCUSED
          Input focus on the component (MTextBox).
 
Constructor Summary
protected MObject(java.awt.Color c, java.awt.Color lc, java.awt.Color bg)
          Contructs a paintable object with the specified color.
protected MObject(MObject o)
          Copy constructor.
 
Method Summary
 void addAttributeKeys(java.util.Vector v)
          Adds the attribute names to the specified vector.
 void addCdataAttributeKeys(java.util.Vector v)
          Adds attribute names to the specified vector.
 void addNotify()
          Called when the object is added to a document.
abstract  void calcCenter(DPoint3 p)
          Calculates the geometrical center.
abstract  java.lang.Object clone()
          Creates a clone.
abstract  double distanceFrom(double x, double y)
          Gets the 2D distance from the specified point.
 java.lang.String getAttribute(java.lang.String s)
          Gets the value of an attribute.
 java.awt.Color getBackground()
          Gets the background color of the object.
 java.awt.Color getColor()
          Gets the color of the object.
 java.awt.Color getLineColor()
          Gets the line color of the object.
abstract  MPoint getPoint(int i)
          Gets a point of the object.
abstract  int getPointCount()
          Gets the number of points.
 MPoint getPointRef(int i)
          Gets a point of the object.
 int getPointRefCount()
          Gets the number of point references.
 boolean hasBackground()
          Can the object have a background?
 boolean hasColor()
          Can the object have a color (non-line and non-background)?
 boolean hasLineColor()
          Can the object have a line color?
 boolean isChildOf(MObject o)
          Is this object a children of another one?
 boolean isEmpty()
          An object may become empty if all the children are removed.
 boolean isInternalSelectable()
          Is it a selection only internal object?
 boolean isSelectableNow()
          Is the object selectable now?
 boolean isSelected()
          Is the object selected?
protected static java.awt.Color makeColor(java.lang.String s)
           
protected static java.lang.String makeColorString(java.awt.Color color)
          Makes a string from a Color object.
 void paint(java.awt.Graphics g, CTransform3D t, int f, java.awt.Color c, java.awt.Color selc, java.awt.Color focusc)
          Paints the object.
 void removeChild(MObject o)
          Removes a child object.
 void removeNotify()
          Called when the object is removed from a document.
 void setAttribute(java.lang.String s, java.lang.String v)
          Sets the value of an attribute.
 void setBackground(java.awt.Color c)
          Sets the background color of the object.
 void setColor(java.awt.Color c)
          Sets the color of the object.
 void setLineColor(java.awt.Color c)
          Sets the color of the object.
 void setSelected(boolean s)
          Selects or unselects the object.
abstract  void transform(CTransform3D t)
          Transforms the object.
 void unselectContents()
          Unselects sub-objects.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAINT_ANTIALIAS

public static final int PAINT_ANTIALIAS
Antialias flag.

See Also:
Constant Field Values

PAINT_FOCUSED

public static final int PAINT_FOCUSED
Input focus on the component (MTextBox).

See Also:
Constant Field Values
Constructor Detail

MObject

protected MObject(java.awt.Color c,
                  java.awt.Color lc,
                  java.awt.Color bg)
Contructs a paintable object with the specified color.

Parameters:
lc - the line color or null to use the default
bg - the background color

MObject

protected MObject(MObject o)
Copy constructor.

Method Detail

clone

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

Returns:
the clone

isEmpty

public boolean isEmpty()
An object may become empty if all the children are removed.

Returns:
true if empty, false otherwise

isChildOf

public boolean isChildOf(MObject o)
Is this object a children of another one?

Parameters:
o - a possible parent
Returns:
true if the other object is the parent, false otherwise

removeChild

public void removeChild(MObject o)
Removes a child object.

Parameters:
o - the child

isInternalSelectable

public boolean isInternalSelectable()
Is it a selection only internal object?

Returns:
true if the object is selectable but only exists as part of a real object, false otherwise

isSelectableNow

public boolean isSelectableNow()
Is the object selectable now?

Returns:
true for ordinary objects, false for some internal selectables

addNotify

public void addNotify()
Called when the object is added to a document.


removeNotify

public void removeNotify()
Called when the object is removed from a document.


getPointCount

public abstract int getPointCount()
Gets the number of points.

Returns:
the number of points

getPoint

public abstract MPoint getPoint(int i)
Gets a point of the object.

Parameters:
i - the point index
Returns:
the point's clone

getPointRefCount

public int getPointRefCount()
Gets the number of point references.

Returns:
the number of point references.

getPointRef

public MPoint getPointRef(int i)
Gets a point of the object.

Parameters:
i - the point index
Returns:
the point's reference

addAttributeKeys

public void addAttributeKeys(java.util.Vector v)
Adds the attribute names to the specified vector. CDATA attributes are not added.

Parameters:
v - the vector

addCdataAttributeKeys

public void addCdataAttributeKeys(java.util.Vector v)
Adds attribute names to the specified vector. Only CDATA attributes are added.

Parameters:
v - the vector

getAttribute

public java.lang.String getAttribute(java.lang.String s)
Gets the value of an attribute.

Parameters:
s - the attribute name
Returns:
the value or null

setAttribute

public void setAttribute(java.lang.String s,
                         java.lang.String v)
Sets the value of an attribute.

Parameters:
s - the attribute name
v - the attribute value

transform

public abstract void transform(CTransform3D t)
Transforms the object.

Parameters:
t - the transformation matrix

calcCenter

public abstract void calcCenter(DPoint3 p)
Calculates the geometrical center.

Parameters:
p - store the coordinates here

distanceFrom

public abstract double distanceFrom(double x,
                                    double y)
Gets the 2D distance from the specified point.

Parameters:
x - the x coordinate
y - the y coordinate

paint

public void paint(java.awt.Graphics g,
                  CTransform3D t,
                  int f,
                  java.awt.Color c,
                  java.awt.Color selc,
                  java.awt.Color focusc)
Paints the object.

Parameters:
g - the graphics context
t - the transformation matrix
f - flags
c - the color to use or null
selc - the selection color
focusc - the focus color

isSelected

public boolean isSelected()
Is the object selected?

Returns:
true if selected, false otherwise

setSelected

public void setSelected(boolean s)
Selects or unselects the object.

Parameters:
s - use true to select, false to unselect

unselectContents

public void unselectContents()
Unselects sub-objects.


getColor

public java.awt.Color getColor()
Gets the color of the object.

Returns:
the color or null

setColor

public void setColor(java.awt.Color c)
Sets the color of the object.

Parameters:
c - the color or null to use the default

getLineColor

public java.awt.Color getLineColor()
Gets the line color of the object.

Returns:
the color or null if there are no lines

setLineColor

public void setLineColor(java.awt.Color c)
Sets the color of the object.

Parameters:
c - the color or null

hasColor

public boolean hasColor()
Can the object have a color (non-line and non-background)?

Returns:
true if it can have a color, false otherwise

hasLineColor

public boolean hasLineColor()
Can the object have a line color?

Returns:
true if it can have a line color, false otherwise

hasBackground

public boolean hasBackground()
Can the object have a background?

Returns:
true if it has a background, false otherwise

getBackground

public java.awt.Color getBackground()
Gets the background color of the object.

Returns:
the color

setBackground

public void setBackground(java.awt.Color c)
Sets the background color of the object.

Parameters:
c - the color

makeColor

protected static java.awt.Color makeColor(java.lang.String s)

makeColorString

protected static java.lang.String makeColorString(java.awt.Color color)
Makes a string from a Color object.

Parameters:
color - the Color object
Returns:
the hexadecimal string representation