chemaxon.struc
Class MDocument

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

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

Marvin document. Stores molecules and graphics objects. This class is under development, use it at your own risk!

Since:
3.1.4
Version:
3.4, 01/05/2004
Author:
Peter Csizmadia
See Also:
Serialized Form

Field Summary
protected  chemaxon.struc.graphics.MChemicalStruct mainMChemicalStruct
           
protected  MObject objectContainingSelection
           
protected  java.util.Vector objects
           
 
Constructor Summary
MDocument(MDocument doc)
          Copy constructor.
MDocument(MoleculeGraph m)
          Creates a document for the specified molecule graph.
 
Method Summary
 void addObject(MObject o)
          Adds an object to the document.
 DPoint3 calcCenter()
          Calculates the geometrical center.
 void clear()
          Clears the document.
 java.lang.Object clone()
          Creates a clone.
 boolean contains(MObject o)
          Searches an object in the document.
 MObject getDraggedObject()
          Gets the dragged object
 long getEndPosition()
          Gets the end position of this document in the input file.
 MObject getFocus()
          Gets the focused object
 java.lang.String getInputFormat()
          Gets the input file format.
 MoleculeGraph getMainMoleculeGraph()
          Gets the main molecule graph.
 MObject getObject(int i)
          Gets an object
 MObject getObjectContainingSelection()
          Gets the object that contains the selection.
 int getObjectCount()
          Gets the number of objects in this document.
 long getStartPosition()
          Gets the starting position of this document in the input file.
 void highlight(MObject o)
          Highlight an object.
 int indexOf(MObject o)
          Searches an object in the document.
 boolean isEmpty()
           
 boolean isHighlighted(MObject o)
          Is the specified object currently highlighted?
 void moveMainMoleculeGraphToFront()
          Move the main molecule graph to the top of stack.
 void moveObject(MObject o, int i)
          Move an object to another place in the stack.
 void removeNodeFromGraphs(CNode node)
          Removes the specified node from all molecule graphs.
 void removeObject(int i)
          Removes an object from the document.
 void removeObject(MObject o)
          Removes an object from the document.
 void selectAllObjects(boolean s)
          Selects or unselects all objects.
 void setDraggedObject(MObject o)
          Sets the dragged object.
 void setEndPosition(long off)
          Sets the end position of this document in the input file.
 void setFocus(MObject o)
          Focus to the specified object.
 void setInputFormat(java.lang.String format)
          Sets the input file format.
 void setMainMoleculeGraph(MoleculeGraph m)
          Sets the main molecule graph.
 void setObject(MObject o, int i)
          Sets an object
 void setObjectContainingSelection(MObject o)
          Sets the object that contains the selection.
 void setStartPosition(long off)
          Sets the starting position of this document in the input file.
 void transform(CTransform3D t)
           
 void unhighlight(MObject o)
          Unhighlights an object.
 void unhighlightAll()
          Unhighlights all objects.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objects

protected transient java.util.Vector objects

mainMChemicalStruct

protected transient chemaxon.struc.graphics.MChemicalStruct mainMChemicalStruct

objectContainingSelection

protected MObject objectContainingSelection
Constructor Detail

MDocument

public MDocument(MoleculeGraph m)
Creates a document for the specified molecule graph.

Parameters:
m - the main molecule graph

MDocument

public MDocument(MDocument doc)
Copy constructor.

Parameters:
doc - the source
Method Detail

clone

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

Returns:
the clone

removeNodeFromGraphs

public void removeNodeFromGraphs(CNode node)
Removes the specified node from all molecule graphs.

Parameters:
node - the node to remove

selectAllObjects

public void selectAllObjects(boolean s)
Selects or unselects all objects.


getObjectContainingSelection

public MObject getObjectContainingSelection()
Gets the object that contains the selection.

Returns:
the object or null

setObjectContainingSelection

public void setObjectContainingSelection(MObject o)
Sets the object that contains the selection. All other objects's contents are unselected.

Parameters:
o - the object or null

isHighlighted

public boolean isHighlighted(MObject o)
Is the specified object currently highlighted?

Returns:
true if it is highlighted, false otherwise

highlight

public void highlight(MObject o)
Highlight an object.

Parameters:
o - the object to highlight

unhighlight

public void unhighlight(MObject o)
Unhighlights an object.

Parameters:
o - the object to unhighlight

unhighlightAll

public void unhighlightAll()
Unhighlights all objects.


getDraggedObject

public MObject getDraggedObject()
Gets the dragged object

Returns:
the dragged object or null

setDraggedObject

public void setDraggedObject(MObject o)
Sets the dragged object.

Parameters:
o - the object

getFocus

public MObject getFocus()
Gets the focused object

Returns:
the focused object or null

setFocus

public void setFocus(MObject o)
Focus to the specified object.

Parameters:
o - the object

getMainMoleculeGraph

public MoleculeGraph getMainMoleculeGraph()
Gets the main molecule graph.

Returns:
the number of molecule graphs

setMainMoleculeGraph

public void setMainMoleculeGraph(MoleculeGraph m)
Sets the main molecule graph.

Parameters:
m - the molecule graph

indexOf

public int indexOf(MObject o)
Searches an object in the document.

Parameters:
o - the object
Returns:
the object's index if found, -1 otherwise

moveObject

public void moveObject(MObject o,
                       int i)
Move an object to another place in the stack.

Parameters:
o - the object
i - the new position

moveMainMoleculeGraphToFront

public void moveMainMoleculeGraphToFront()
Move the main molecule graph to the top of stack.


contains

public boolean contains(MObject o)
Searches an object in the document.

Parameters:
o - the object
Returns:
true if the document contains the object, false otherwise

addObject

public void addObject(MObject o)
Adds an object to the document.

Parameters:
o - the object

removeObject

public void removeObject(MObject o)
Removes an object from the document.

Parameters:
o - the object

removeObject

public void removeObject(int i)
Removes an object from the document.

Parameters:
i - the object index

getObjectCount

public int getObjectCount()
Gets the number of objects in this document.

Returns:
the number of objects

getObject

public MObject getObject(int i)
Gets an object

Parameters:
i - the line number
Returns:
two-element array containing the two endpoints

setObject

public void setObject(MObject o,
                      int i)
Sets an object

Parameters:
o - the object
i - the index

clear

public void clear()
Clears the document. Removes all objects except the main molecule graph, from which all atoms, bonds and other objects are removed.


isEmpty

public boolean isEmpty()

transform

public void transform(CTransform3D t)

calcCenter

public DPoint3 calcCenter()
Calculates the geometrical center.

Returns:
the center

getStartPosition

public long getStartPosition()
Gets the starting position of this document in the input file.

Returns:
the starting position

setStartPosition

public void setStartPosition(long off)
Sets the starting position of this document in the input file.

Parameters:
off - the starting position

getEndPosition

public long getEndPosition()
Gets the end position of this document in the input file.

Returns:
the end position

setEndPosition

public void setEndPosition(long off)
Sets the end position of this document in the input file.

Parameters:
off - the end position

getInputFormat

public final java.lang.String getInputFormat()
Gets the input file format. Set by the import module if the molecule is from a file.

Returns:
the input file format for the document

setInputFormat

public void setInputFormat(java.lang.String format)
Sets the input file format.

Parameters:
format - the input format