Package chemaxon.marvin.view
Class MDocStorage
java.lang.Object
chemaxon.marvin.view.MDocStorage
Sparse dynamic document storage and reader.
- Since:
 - Marvin 4.1, 04/13/2006
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassException indicating that records are not available because the user cancelled file reading.static interfaceDocument production listener.classRequested record is not available in the source. - 
Constructor Summary
ConstructorsConstructorDescriptionConstructs a document storage.MDocStorage(int n) Constructs a document storage. - 
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener if it is not yet added.booleanAromatize or dearomatize molecule in the specified cell.booleanaromatizeAll(boolean v, int method, String[] warn) Aromatize or dearomatize molecules in all cells.booleanclean(int k, String key, int dim, String opts, MProgressMonitor pm, String[] warn) Clean the specified cell.booleancleanAll(int dim, String opts, MProgressMonitor pm, String[] warn) Clean all cells.booleancontractOrExpandSgroups(int k, String key, boolean contr) Contract or expand S-groups in the specified cell.booleancontractOrExpandSgroupsAll(boolean contract) Contract or expand S-groups in all molecules.intcountRecords(MProgressMonitor pmon, int dt, Runnable sizeupdater, int max) Counts the total number of records and sets the size of the document storage.intcountRecordsInFraction(double q, int ncols, MProgressMonitor pmon) Deprecated, for removal: This API element is subject to removal in a future version.voiddoSetSetSeqs(Molecule[] mols, int k, String key) voidSet all stored document entries to null.intGets the maximum number of cached documents.getCachedDoc(int k, String key) Gets the specified document if it is present in the memory.int[]Gets the indices of cached records.Gets the synchronization lock for caching operations.intGets the total capacity.Gets the specified document.getDoc(int k, String key, MProgressMonitor pmon) Gets the specified document.getDocLabel(int k, MDocument doc) Returns the display label for the given document and document index.Gets the document source.intGets the current position in the input.Gets the field accessor.Gets the Global GUI properties.intgetIDBackgroundRGBA(int k) Gets the background color's RGBA value in a record.intgetIDForegroundRGBA(int k) Gets the foreground color's RGBA value in a record.getL(int k, int j) Gets a text label in a record.getMainDoc(int k) Gets the document at the specified position.getMainDoc(int k, MProgressMonitor pmon) Gets the document at the specified position.intGets the maximum molecule dimension.getMolCenter(int k, String key) Gets a molecule center.chemaxon.marvin.paint.internal.MolPaintergetMolPainter(int k, String key) Gets a molecule painter.intGets the offset in the document source.int[]getSelectedAtoms(int k, String key) Gets the selected atom indices.intgetSize()Gets the total number of entries.getT(int k, int j) Gets a text field in a record.booleanhydrogenize(int k, String key, boolean hydr, String[] warn) Hydrogenize molecule in the specified cell.booleanhydrogenizeAll(boolean hydr, String[] warn) Hydrogenize molecules in all cells.booleanisEnabledT(int k, int j) Tests whether a text field is enabled.booleanisFixed(int k) Tests whether a record is fixed.booleanisFractionQuicklyAvailable(double x) Tests whether the specified fraction of the total (estimated) number of records is quickly available.booleanTests whether the document storage is rewindable.booleanTests whether the storage size is final.voidRemoves a listener.voidsetAtomSetSeq(int k, String key, int atom, int seq) Sets the atom set sequence number of an atom.voidsetAtomSetSeq(int k, String key, String str, int setSeq) Sets atom set sequence numbers.voidsetAtomSetSeqs(int k, String key, int[] seqs) Sets atom set sequence numbers.voidsetBondSetSeq(int k, String key, int firstAtomIndex, int secondAtomIndex, int seq) Sets bond set sequence numbers.voidsetBondSetSeq(int k, String key, String str, int setSeq) Sets bond set sequence numbers.voidsetBondSetSeqAll(int k, String key, int seq) Sets all bond set sequence numbers.voidsetBondSetSeqs(int k, String key, List<int[]> seqs) Sets bond set sequence numbers.voidsetCacheCapacity(int max) Sets the maximum number of cached documents.voidsetDocSource(MDocSource dp, int offset, int max) Sets the document source.voidsetEnabledT(int k, int j, boolean l) Set the enabled state of a text field in a record.voidSets the field accessor.voidsetFixed(int k) Sets a document as fixed.booleansetIDBackgroundRGBA(int k, int rgba) Sets the background color's RGBA value in a record.booleansetIDForegroundRGBA(int k, int rgba) Sets the foreground color's RGBA value in a record.voidSets a text label in a record.voidsetListeners(MDocStorage.Listener[] arr) voidsetMolCenter(int k, String key, DPoint3 p) Sets a molecule center.voidsetMolPainter(int k, String key, chemaxon.marvin.paint.internal.MolPainter p) Sets a molecule painter.voidsetSelectedAtoms(int k, String key, int[] sel) Sets the selected atom indices.voidsetSelectedAtoms(int k, String key, String str) Sets the selected atom indices.voidsetSize(int n) Sets the total number of entries.voidSets a text field in a record.voidStore new document and free the oldest accessed if the number of documents is too much to fit in memory.voidstoreMainDoc(MDocument doc, int k) Store new document and free the oldest accessed if the number of documents is too much to fit in memory. 
- 
Constructor Details
- 
MDocStorage
public MDocStorage()Constructs a document storage. - 
MDocStorage
public MDocStorage(int n) Constructs a document storage.- Parameters:
 n- number of documents to store
 
 - 
 - 
Method Details
- 
getDocSource
Gets the document source.- Returns:
 - the document source
 - Since:
 - Marvin 4.1.6, 03/08/2007
 
 - 
setDocSource
Sets the document source.- Parameters:
 dp- the document (molecule) sourceoffset- number of documents to skip in the sourcemax- maximum allowed number of documents or 0 (no restriction)
 - 
getFieldAccessor
Gets the field accessor.- Returns:
 - the field accessor
 - Since:
 - Marvin 5.0, 11/09/2007
 
 - 
setFieldAccessor
Sets the field accessor.- Parameters:
 fa- the field accessor- Since:
 - Marvin 5.0, 11/09/2007
 
 - 
getOffset
public int getOffset()Gets the offset in the document source.- Returns:
 - the first record index
 - Since:
 - Marvin 5.0, 11/18/2007
 
 - 
getDocSourcePosition
public int getDocSourcePosition()Gets the current position in the input.- Returns:
 - the position or -1 if there is no document source
 
 - 
addListener
Adds a listener if it is not yet added.- Parameters:
 l- the listener
 - 
removeListener
Removes a listener.- Parameters:
 l- the listener
 - 
getListeners
 - 
setListeners
 - 
getSize
public int getSize()Gets the total number of entries.- Returns:
 - the total number of entries
 
 - 
setSize
public void setSize(int n) Sets the total number of entries. (Resize the arrays.)- Parameters:
 n- new capacity (maximum number of documents)
 - 
isSizeFinal
public boolean isSizeFinal()Tests whether the storage size is final.- Returns:
 trueis the storage will not grow,falseif it may grow
 - 
getCapacity
public int getCapacity()Gets the total capacity.- Returns:
 - the maximum number of entries (without reallocation)
 
 - 
getCacheCapacity
public int getCacheCapacity()Gets the maximum number of cached documents.- Returns:
 - the cache capacity or 0 if everything is stored
 
 - 
setCacheCapacity
public void setCacheCapacity(int max) Sets the maximum number of cached documents.- Parameters:
 max- maximum number of documents in memory or 0 to store everything
 - 
getCachedDocIndices
public int[] getCachedDocIndices()Gets the indices of cached records.- Returns:
 - array of indices
 
 - 
isRewindable
public boolean isRewindable()Tests whether the document storage is rewindable. It is rewindable if either the document source is rewindable (e.g. a seekable input stream) or all documents are stored permanently in memory after reading (if cache size equals the total capacity).- Returns:
 trueif backward seeking is possible,falseotherwise
 - 
getDoc
public MDocument getDoc(int k, String key) throws MDocStorage.RecordUnavailableException, IOException Gets the specified document.- Parameters:
 k- the record indexkey- the molecule (or document) field name,nullfor the main document (molecule)- Throws:
 MDocStorage.RecordUnavailableException- if the requested record is not available (probably end of file reached too early)IOException- if read error occurred- Since:
 - Marvin 5.2, 02/10/2009
 
 - 
getDoc
public MDocument getDoc(int k, String key, MProgressMonitor pmon) throws MDocStorage.RecordUnavailableException, MDocStorage.CancellationException, IOException Gets the specified document.- Parameters:
 k- the record indexkey- the molecule (or document) field name,nullfor the main document (molecule)pmon- progress monitor ornull- Throws:
 MDocStorage.RecordUnavailableException- if the requested record is not available (probably end of file reached too early)MDocStorage.CancellationException- if the user cancelled the operationIOException- if read error occurred
 - 
getMainDoc
Gets the document at the specified position.- Parameters:
 k- the record index- Returns:
 - the document or null
 - Throws:
 MDocStorage.RecordUnavailableException- if the requested record is not available (probably end of file reached too early)IOException- if read error occurred- Since:
 - Marvin 5.2, 02/10/2009
 
 - 
getMainDoc
public MDocument getMainDoc(int k, MProgressMonitor pmon) throws MDocStorage.RecordUnavailableException, MDocStorage.CancellationException, IOException Gets the document at the specified position.- Parameters:
 k- the record indexpmon- progress monitor ornull- Returns:
 - the document or null
 - Throws:
 MDocStorage.RecordUnavailableException- if the requested record is not available (probably end of file reached too early)MDocStorage.CancellationException- if the user cancelled the operationIOException- if read error occurred
 - 
getDocLabel
Returns the display label for the given document and document index. The default implementation returnsk+1as String, wherekis the document index.- Parameters:
 k- the document indexdoc- the document- Returns:
 - the document label
 - Since:
 - Marvin 5.0
 
 - 
countRecords
public int countRecords(MProgressMonitor pmon, int dt, Runnable sizeupdater, int max) throws IOException Counts the total number of records and sets the size of the document storage.- Parameters:
 pmon- progress monitor ornulldt- time interval in milliseconds for calling size updatesizeupdater- optional runnable to be called if the total number of records changed ornullmax- the maximum record index where counting should stop- Returns:
 - the number of records or -1 if the user canceled the progress monitor
 - Throws:
 IOException- if read error occurred- Since:
 - Marvin 5.2, 01/22/2009
 
 - 
countRecordsInFraction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public int countRecordsInFraction(double q, int ncols, MProgressMonitor pmon) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.Counts the number of records between the start and the specified fraction of the total, estimated number of records.- Parameters:
 q- the fraction, floating point number between 0 and 1ncols- the number of columns (1 if there are no more columns)pmon- progress monitor ornull- Returns:
 - the estimated number of records in the specified fraction or -1 if the user canceled the progress monitor
 - Throws:
 IOException- if read error occurred
 - 
isFractionQuicklyAvailable
public boolean isFractionQuicklyAvailable(double x) Tests whether the specified fraction of the total (estimated) number of records is quickly available. A record is quickly available if its file position is known (because it was previously retrieved or skipped) or it is in the memory (if no document source is present).- Parameters:
 x- the fraction, floating point number between 0 and 1- Returns:
 trueif the specified fraction is quickly available,falseotherwise
 - 
getCacheLock
Gets the synchronization lock for caching operations.- Returns:
 - the lock object
 - Since:
 - Marvin 5.0, 12/04/2007
 
 - 
getMaxDimCached
public int getMaxDimCached()Gets the maximum molecule dimension.- Returns:
 - the maximum dimension
 
 - 
getCachedDoc
Gets the specified document if it is present in the memory.- Parameters:
 k- the record indexkey- the molecule (or document) field name,nullfor the main document (molecule)- Returns:
 - the document or 
null - Since:
 - Marvin 5.0, 11/18/2007
 
 - 
storeDoc
Store new document and free the oldest accessed if the number of documents is too much to fit in memory.- Parameters:
 doc- the new documentk- record index (minus doc source offset)key- the molecule (or document) field name,nullfor the main document (molecule)
 - 
storeMainDoc
Store new document and free the oldest accessed if the number of documents is too much to fit in memory.- Parameters:
 doc- the new documentk- record index (minus doc source offset)
 - 
isFixed
public boolean isFixed(int k) Tests whether a record is fixed.- Parameters:
 k- the record index- Returns:
 trueif the document object will remain in memory until the end of life of this storage object,falseif it can be freed and reloaded dynamically to save memory- Throws:
 IndexOutOfBoundsException- if the specified index is negative.
 - 
setFixed
public void setFixed(int k) Sets a document as fixed. Fixed documents are never freed, they remain in memory until the end of life of this storage object.- Parameters:
 k- the document entry index- Throws:
 IndexOutOfBoundsException- if the specified index is negative or larger than the number of capacity
 - 
getMolPainter
Gets a molecule painter. For internal use only.- Parameters:
 k- the document entry indexkey- the molecule field name,nullfor the main document (molecule)- Returns:
 - the molecule painter or null
 
 - 
setMolPainter
Sets a molecule painter.- Parameters:
 k- the document entry indexkey- the molecule field name,nullfor the main document (molecule)p- the painter
 - 
getMolCenter
Gets a molecule center.- Parameters:
 k- the document entry indexkey- the molecule field name,nullfor the main document (molecule)- Returns:
 - the center
 
 - 
setMolCenter
Sets a molecule center.- Parameters:
 k- the document entry indexkey- the molecule field name,nullfor the main document (molecule)p- the center point
 - 
getSelectedAtoms
Gets the selected atom indices.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)- Returns:
 - selected atom indices
 
 - 
setSelectedAtoms
Sets the selected atom indices.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)sel- array containing the selected atom indices
 - 
setSelectedAtoms
Sets the selected atom indices.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)str- string containing a comma separated list of atom indices
 - 
setAtomSetSeqs
Sets atom set sequence numbers.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)seqs- array of atom set sequence numbers
 - 
setAtomSetSeq
Sets atom set sequence numbers.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)str- string containing a comma separated list of atom indicessetSeq- atom set sequence number
 - 
setAtomSetSeq
Sets the atom set sequence number of an atom.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)atom- atom indexseq- atom set sequence number
 - 
setBondSetSeqs
Sets bond set sequence numbers.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)seqs- vector of bond set sequence numbers
 - 
setBondSetSeq
Sets bond set sequence numbers.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)str- string containing a comma separated list of bonds in j1-j2 format, where j1 and j2 are atom indicessetSeq- bond set sequence number
 - 
setBondSetSeq
Sets bond set sequence numbers.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)firstAtomIndex- first atom indexsecondAtomIndex- second atom indexseq- bond set sequence number
 - 
setBondSetSeqAll
Sets all bond set sequence numbers.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)seq- bond set sequence number
 - 
doSetSetSeqs
 - 
getL
Gets a text label in a record.- Parameters:
 k- the record indexj- label index- Returns:
 - the label or null
 
 - 
setL
Sets a text label in a record.- Parameters:
 k- the record indexj- label indexl- the label or null
 - 
getT
Gets a text field in a record.- Parameters:
 k- the record indexj- text field index- Returns:
 - the text or null
 
 - 
setT
Sets a text field in a record.- Parameters:
 k- the record indexj- label indexl- the text or null
 - 
isEnabledT
public boolean isEnabledT(int k, int j) Tests whether a text field is enabled.- Parameters:
 k- the record indexj- text field index- Returns:
 - true if enabled, false otherwise
 
 - 
setEnabledT
public void setEnabledT(int k, int j, boolean l) Set the enabled state of a text field in a record.- Parameters:
 k- the record indexj- label indexl- enable (true) or disable (false)
 - 
getIDBackgroundRGBA
public int getIDBackgroundRGBA(int k) Gets the background color's RGBA value in a record.- Parameters:
 k- the record index- Returns:
 - the RGB value or 0 if unset
 - Since:
 - Marvin 5.2, 02/22/2009
 
 - 
setIDBackgroundRGBA
public boolean setIDBackgroundRGBA(int k, int rgba) Sets the background color's RGBA value in a record.- Parameters:
 k- the record indexrgba- the RGBA value or 0 to reset the default color- Returns:
 trueif the color changed,falseotherwise- Since:
 - Marvin 5.2, 02/22/2009
 
 - 
getIDForegroundRGBA
public int getIDForegroundRGBA(int k) Gets the foreground color's RGBA value in a record.- Parameters:
 k- the record index- Returns:
 - the RGB value or 0 if unset
 - Since:
 - Marvin 5.2, 02/22/2009
 
 - 
setIDForegroundRGBA
public boolean setIDForegroundRGBA(int k, int rgba) Sets the foreground color's RGBA value in a record.- Parameters:
 k- the record indexrgba- the RGBA value or 0 to reset the default color- Returns:
 trueif the color changed,falseotherwise- Since:
 - Marvin 5.2.1, 04/14/2009
 
 - 
fillWithNulls
public void fillWithNulls()Set all stored document entries to null. - 
contractOrExpandSgroupsAll
public boolean contractOrExpandSgroupsAll(boolean contract) Contract or expand S-groups in all molecules.- Parameters:
 contract- contract (trueor expand (false)- Returns:
 trueif the document is changed,falseotherwise
 - 
contractOrExpandSgroups
Contract or expand S-groups in the specified cell.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)contr- contract (trueor expand (false)- Returns:
 trueif the document is changed,falseotherwise
 - 
hydrogenizeAll
Hydrogenize molecules in all cells.- Parameters:
 hydr- hydrogenize (trueor dehydrogenize (false)warn- 1-element array to store the warning message, or null- Returns:
 trueif the document is changed,falseotherwise
 - 
hydrogenize
Hydrogenize molecule in the specified cell.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)hydr- hydrogenize (trueor dehydrogenize (false)warn- 1-element array to store the warning message, or null- Returns:
 trueif the document is changed,falseotherwise
 - 
aromatizeAll
Aromatize or dearomatize molecules in all cells.- Parameters:
 v- aromatize (trueor dearomatize (false)method- aromatization method or 0warn- 1-element array to store the warning message, or null- Returns:
 trueif the document is changed,falseotherwise- Since:
 - Marvin 4.1.1, 09/08/2006
 
 - 
aromatize
Aromatize or dearomatize molecule in the specified cell.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)v- aromatize (trueor dearomatize (false)method- aromatization method or 0warn- 1-element array to store the warning message, or null- Returns:
 trueif the document is changed,falseotherwise- Since:
 - Marvin 4.1.1, 09/08/2006
 
 - 
cleanAll
Clean all cells.- Parameters:
 dim- dimension, 2 or 3opts- cleaning options ornullpm- progress monitor to use ornullwarn- 1-element array to store the warning message, or null- Returns:
 trueif the document is changed,falseotherwise- Since:
 - Marvin 5.0, 09/09/2007
 
 - 
clean
Clean the specified cell.- Parameters:
 k- the record indexkey- the molecule field name,nullfor the main document (molecule)dim- dimension, 2 or 3opts- cleaning options ornullpm- progress monitor to use ornullwarn- 1-element array to store the warning message, or null- Returns:
 trueif the document is changed,falseotherwise- Since:
 - Marvin 5.0, 09/09/2007
 
 - 
getGlobalGUIProperties
Gets the Global GUI properties.- Returns:
 - the properties
 - Since:
 - Marvin 5.0, 10/16/2006
 
 
 -