@PublicAPI public class MDocStorage extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
MDocStorage.CancellationException
Exception indicating that records are not available because the user cancelled file reading.
|
static interface |
MDocStorage.Listener
Document production listener.
|
class |
MDocStorage.RecordUnavailableException
Requested record is not available in the source.
|
Constructor and Description |
---|
MDocStorage()
Constructs a document storage.
|
MDocStorage(int n)
Constructs a document storage.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(MDocStorage.Listener l)
Adds a listener if it is not yet added.
|
boolean |
aromatize(int k,
java.lang.String key,
boolean v,
int method,
java.lang.String[] warn)
Aromatize or dearomatize molecule in the specified cell.
|
boolean |
aromatizeAll(boolean v,
int method,
java.lang.String[] warn)
Aromatize or dearomatize molecules in all cells.
|
boolean |
clean(int k,
java.lang.String key,
int dim,
java.lang.String opts,
MProgressMonitor pm,
java.lang.String[] warn)
Clean the specified cell.
|
boolean |
cleanAll(int dim,
java.lang.String opts,
MProgressMonitor pm,
java.lang.String[] warn)
Clean all cells.
|
boolean |
contractOrExpandSgroups(int k,
java.lang.String key,
boolean contr)
Contract or expand S-groups in the specified cell.
|
boolean |
contractOrExpandSgroupsAll(boolean contract)
Contract or expand S-groups in all molecules.
|
int |
countRecords(MProgressMonitor pmon,
int dt,
java.lang.Runnable sizeupdater,
int max)
Counts the total number of records and sets the size of the document storage.
|
int |
countRecordsInFraction(double q,
int ncols,
MProgressMonitor pmon)
Deprecated.
|
void |
doSetSetSeqs(Molecule[] mols,
int k,
java.lang.String key) |
void |
fillWithNulls()
Set all stored document entries to null.
|
int |
getCacheCapacity()
Gets the maximum number of cached documents.
|
MDocument |
getCachedDoc(int k,
java.lang.String key)
Gets the specified document if it is present in the memory.
|
int[] |
getCachedDocIndices()
Gets the indices of cached records.
|
java.lang.Object |
getCacheLock()
Gets the synchronization lock for caching operations.
|
int |
getCapacity()
Gets the total capacity.
|
MDocument |
getDoc(int k,
java.lang.String key)
Gets the specified document.
|
MDocument |
getDoc(int k,
java.lang.String key,
MProgressMonitor pmon)
Gets the specified document.
|
java.lang.String |
getDocLabel(int k,
MDocument doc)
Returns the display label for the given document and document index.
|
MDocSource |
getDocSource()
Gets the document source.
|
int |
getDocSourcePosition()
Gets the current position in the input.
|
MFieldAccessor |
getFieldAccessor()
Gets the field accessor.
|
MPropertyContainer |
getGlobalGUIProperties()
Gets the Global GUI properties.
|
int |
getIDBackgroundRGBA(int k)
Gets the background color's RGBA value in a record.
|
int |
getIDForegroundRGBA(int k)
Gets the foreground color's RGBA value in a record.
|
java.lang.String |
getL(int k,
int j)
Gets a text label in a record.
|
MDocStorage.Listener[] |
getListeners() |
MDocument |
getMainDoc(int k)
Gets the document at the specified position.
|
MDocument |
getMainDoc(int k,
MProgressMonitor pmon)
Gets the document at the specified position.
|
int |
getMaxDimCached()
Gets the maximum molecule dimension.
|
DPoint3 |
getMolCenter(int k,
java.lang.String key)
Gets a molecule center.
|
chemaxon.marvin.paint.internal.MolPainter |
getMolPainter(int k,
java.lang.String key)
Gets a molecule painter.
|
int |
getOffset()
Gets the offset in the document source.
|
int[] |
getSelectedAtoms(int k,
java.lang.String key)
Gets the selected atom indices.
|
int |
getSize()
Gets the total number of entries.
|
java.lang.String |
getT(int k,
int j)
Gets a text field in a record.
|
boolean |
hydrogenize(int k,
java.lang.String key,
boolean hydr,
java.lang.String[] warn)
Hydrogenize molecule in the specified cell.
|
boolean |
hydrogenizeAll(boolean hydr,
java.lang.String[] warn)
Hydrogenize molecules in all cells.
|
boolean |
isEnabledT(int k,
int j)
Tests whether a text field is enabled.
|
boolean |
isFixed(int k)
Tests whether a record is fixed.
|
boolean |
isFractionQuicklyAvailable(double x)
Tests whether the specified fraction of the total (estimated) number of records is quickly
available.
|
boolean |
isRewindable()
Tests whether the document storage is rewindable.
|
boolean |
isSizeFinal()
Tests whether the storage size is final.
|
void |
removeListener(MDocStorage.Listener l)
Removes a listener.
|
void |
setAtomSetSeq(int k,
java.lang.String key,
int atom,
int seq)
Sets the atom set sequence number of an atom.
|
void |
setAtomSetSeq(int k,
java.lang.String key,
java.lang.String str,
int setSeq)
Sets atom set sequence numbers.
|
void |
setAtomSetSeqs(int k,
java.lang.String key,
int[] seqs)
Sets atom set sequence numbers.
|
void |
setBondSetSeq(int k,
java.lang.String key,
int firstAtomIndex,
int secondAtomIndex,
int seq)
Sets bond set sequence numbers.
|
void |
setBondSetSeq(int k,
java.lang.String key,
java.lang.String str,
int setSeq)
Sets bond set sequence numbers.
|
void |
setBondSetSeqAll(int k,
java.lang.String key,
int seq)
Sets all bond set sequence numbers.
|
void |
setBondSetSeqs(int k,
java.lang.String key,
java.util.List<int[]> seqs)
Sets bond set sequence numbers.
|
void |
setCacheCapacity(int max)
Sets the maximum number of cached documents.
|
void |
setDocSource(MDocSource dp,
int offset,
int max)
Sets the document source.
|
void |
setEnabledT(int k,
int j,
boolean l)
Set the enabled state of a text field in a record.
|
void |
setFieldAccessor(MFieldAccessor fa)
Sets the field accessor.
|
void |
setFixed(int k)
Sets a document as fixed.
|
boolean |
setIDBackgroundRGBA(int k,
int rgba)
Sets the background color's RGBA value in a record.
|
boolean |
setIDForegroundRGBA(int k,
int rgba)
Sets the foreground color's RGBA value in a record.
|
void |
setL(int k,
int j,
java.lang.String l)
Sets a text label in a record.
|
void |
setListeners(MDocStorage.Listener[] arr) |
void |
setMolCenter(int k,
java.lang.String key,
DPoint3 p)
Sets a molecule center.
|
void |
setMolPainter(int k,
java.lang.String key,
chemaxon.marvin.paint.internal.MolPainter p)
Sets a molecule painter.
|
void |
setSelectedAtoms(int k,
java.lang.String key,
int[] sel)
Sets the selected atom indices.
|
void |
setSelectedAtoms(int k,
java.lang.String key,
java.lang.String str)
Sets the selected atom indices.
|
void |
setSize(int n)
Sets the total number of entries.
|
void |
setT(int k,
int j,
java.lang.String l)
Sets a text field in a record.
|
void |
storeDoc(MDocument doc,
int k,
java.lang.String key)
Store new document and free the oldest accessed if the number of documents is too much to fit
in memory.
|
void |
storeMainDoc(MDocument doc,
int k)
Store new document and free the oldest accessed if the number of documents is too much to fit
in memory.
|
public MDocStorage()
public MDocStorage(int n)
n
- number of documents to storepublic MDocSource getDocSource()
public void setDocSource(MDocSource dp, int offset, int max)
dp
- the document (molecule) sourceoffset
- number of documents to skip in the sourcemax
- maximum allowed number of documents or 0 (no restriction)public MFieldAccessor getFieldAccessor()
public void setFieldAccessor(MFieldAccessor fa)
fa
- the field accessorpublic int getOffset()
public int getDocSourcePosition()
public void addListener(MDocStorage.Listener l)
l
- the listenerpublic void removeListener(MDocStorage.Listener l)
l
- the listenerpublic MDocStorage.Listener[] getListeners()
public void setListeners(MDocStorage.Listener[] arr)
public int getSize()
public void setSize(int n)
n
- new capacity (maximum number of documents)public boolean isSizeFinal()
true
is the storage will not grow, false
if it may growpublic int getCapacity()
public int getCacheCapacity()
public void setCacheCapacity(int max)
max
- maximum number of documents in memory or 0 to store everythingpublic int[] getCachedDocIndices()
public boolean isRewindable()
true
if backward seeking is possible, false
otherwisepublic MDocument getDoc(int k, java.lang.String key) throws MDocStorage.RecordUnavailableException, java.io.IOException
k
- the record indexkey
- the molecule (or document) field name, null
for the main document
(molecule)MDocStorage.RecordUnavailableException
- if the requested record is not available (probably end of file reached too
early)java.io.IOException
- if read error occurredpublic MDocument getDoc(int k, java.lang.String key, MProgressMonitor pmon) throws MDocStorage.RecordUnavailableException, MDocStorage.CancellationException, java.io.IOException
k
- the record indexkey
- the molecule (or document) field name, null
for the main document
(molecule)pmon
- progress monitor or null
MDocStorage.RecordUnavailableException
- if the requested record is not available (probably end of file reached too
early)MDocStorage.CancellationException
- if the user cancelled the operationjava.io.IOException
- if read error occurredpublic MDocument getMainDoc(int k) throws MDocStorage.RecordUnavailableException, java.io.IOException
k
- the record indexMDocStorage.RecordUnavailableException
- if the requested record is not available (probably end of file reached too
early)java.io.IOException
- if read error occurredpublic MDocument getMainDoc(int k, MProgressMonitor pmon) throws MDocStorage.RecordUnavailableException, MDocStorage.CancellationException, java.io.IOException
k
- the record indexpmon
- progress monitor or null
MDocStorage.RecordUnavailableException
- if the requested record is not available (probably end of file reached too
early)MDocStorage.CancellationException
- if the user cancelled the operationjava.io.IOException
- if read error occurredpublic java.lang.String getDocLabel(int k, MDocument doc)
k+1
as String, where k
is the document
index.k
- the document indexdoc
- the documentpublic int countRecords(MProgressMonitor pmon, int dt, java.lang.Runnable sizeupdater, int max) throws java.io.IOException
pmon
- progress monitor or null
dt
- time interval in milliseconds for calling size updatesizeupdater
- optional runnable to be called if the total number of records changed or
null
max
- the maximum record index where counting should stopjava.io.IOException
- if read error occurred@Deprecated public int countRecordsInFraction(double q, int ncols, MProgressMonitor pmon) throws java.io.IOException
q
- the fraction, floating point number between 0 and 1ncols
- the number of columns (1 if there are no more columns)pmon
- progress monitor or null
java.io.IOException
- if read error occurredpublic boolean isFractionQuicklyAvailable(double x)
x
- the fraction, floating point number between 0 and 1true
if the specified fraction is quickly available, false
otherwisepublic java.lang.Object getCacheLock()
public int getMaxDimCached()
public MDocument getCachedDoc(int k, java.lang.String key)
k
- the record indexkey
- the molecule (or document) field name, null
for the main document
(molecule)null
public void storeDoc(MDocument doc, int k, java.lang.String key)
doc
- the new documentk
- record index (minus doc source offset)key
- the molecule (or document) field name, null
for the main document
(molecule)public void storeMainDoc(MDocument doc, int k)
doc
- the new documentk
- record index (minus doc source offset)public boolean isFixed(int k)
k
- the record indextrue
if the document object will remain in memory until the end of life
of this storage object, false
if it can be freed and reloaded
dynamically to save memoryjava.lang.IndexOutOfBoundsException
- if the specified index is negative.public void setFixed(int k)
k
- the document entry indexjava.lang.IndexOutOfBoundsException
- if the specified index is negative or larger than the number of capacitypublic chemaxon.marvin.paint.internal.MolPainter getMolPainter(int k, java.lang.String key)
k
- the document entry indexkey
- the molecule field name, null
for the main document (molecule)public void setMolPainter(int k, java.lang.String key, chemaxon.marvin.paint.internal.MolPainter p)
k
- the document entry indexkey
- the molecule field name, null
for the main document (molecule)p
- the painterpublic DPoint3 getMolCenter(int k, java.lang.String key)
k
- the document entry indexkey
- the molecule field name, null
for the main document (molecule)public void setMolCenter(int k, java.lang.String key, DPoint3 p)
k
- the document entry indexkey
- the molecule field name, null
for the main document (molecule)p
- the center pointpublic int[] getSelectedAtoms(int k, java.lang.String key)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)public void setSelectedAtoms(int k, java.lang.String key, int[] sel)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)sel
- array containing the selected atom indicespublic void setSelectedAtoms(int k, java.lang.String key, java.lang.String str)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)str
- string containing a comma separated list of atom indicespublic void setAtomSetSeqs(int k, java.lang.String key, int[] seqs)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)seqs
- array of atom set sequence numberspublic void setAtomSetSeq(int k, java.lang.String key, java.lang.String str, int setSeq)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)str
- string containing a comma separated list of atom indicessetSeq
- atom set sequence numberpublic void setAtomSetSeq(int k, java.lang.String key, int atom, int seq)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)atom
- atom indexseq
- atom set sequence numberpublic void setBondSetSeqs(int k, java.lang.String key, java.util.List<int[]> seqs)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)seqs
- vector of bond set sequence numberspublic void setBondSetSeq(int k, java.lang.String key, java.lang.String str, int setSeq)
k
- the record indexkey
- the molecule field name, null
for 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 numberpublic void setBondSetSeq(int k, java.lang.String key, int firstAtomIndex, int secondAtomIndex, int seq)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)firstAtomIndex
- first atom indexsecondAtomIndex
- second atom indexseq
- bond set sequence numberpublic void setBondSetSeqAll(int k, java.lang.String key, int seq)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)seq
- bond set sequence numberpublic void doSetSetSeqs(Molecule[] mols, int k, java.lang.String key)
public java.lang.String getL(int k, int j)
k
- the record indexj
- label indexpublic void setL(int k, int j, java.lang.String l)
k
- the record indexj
- label indexl
- the label or nullpublic java.lang.String getT(int k, int j)
k
- the record indexj
- text field indexpublic void setT(int k, int j, java.lang.String l)
k
- the record indexj
- label indexl
- the text or nullpublic boolean isEnabledT(int k, int j)
k
- the record indexj
- text field indexpublic void setEnabledT(int k, int j, boolean l)
k
- the record indexj
- label indexl
- enable (true
) or disable (false
)public int getIDBackgroundRGBA(int k)
k
- the record indexpublic boolean setIDBackgroundRGBA(int k, int rgba)
k
- the record indexrgba
- the RGBA value or 0 to reset the default colortrue
if the color changed, false
otherwisepublic int getIDForegroundRGBA(int k)
k
- the record indexpublic boolean setIDForegroundRGBA(int k, int rgba)
k
- the record indexrgba
- the RGBA value or 0 to reset the default colortrue
if the color changed, false
otherwisepublic void fillWithNulls()
public boolean contractOrExpandSgroupsAll(boolean contract)
contract
- contract (true
or expand (false
)true
if the document is changed, false
otherwisepublic boolean contractOrExpandSgroups(int k, java.lang.String key, boolean contr)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)contr
- contract (true
or expand (false
)true
if the document is changed, false
otherwisepublic boolean hydrogenizeAll(boolean hydr, java.lang.String[] warn)
hydr
- hydrogenize (true
or dehydrogenize (false
)warn
- 1-element array to store the warning message, or nulltrue
if the document is changed, false
otherwisepublic boolean hydrogenize(int k, java.lang.String key, boolean hydr, java.lang.String[] warn)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)hydr
- hydrogenize (true
or dehydrogenize (false
)warn
- 1-element array to store the warning message, or nulltrue
if the document is changed, false
otherwisepublic boolean aromatizeAll(boolean v, int method, java.lang.String[] warn)
v
- aromatize (true
or dearomatize (false
)method
- aromatization method or 0warn
- 1-element array to store the warning message, or nulltrue
if the document is changed, false
otherwisepublic boolean aromatize(int k, java.lang.String key, boolean v, int method, java.lang.String[] warn)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)v
- aromatize (true
or dearomatize (false
)method
- aromatization method or 0warn
- 1-element array to store the warning message, or nulltrue
if the document is changed, false
otherwisepublic boolean cleanAll(int dim, java.lang.String opts, MProgressMonitor pm, java.lang.String[] warn)
dim
- dimension, 2 or 3opts
- cleaning options or null
pm
- progress monitor to use or null
warn
- 1-element array to store the warning message, or nulltrue
if the document is changed, false
otherwisepublic boolean clean(int k, java.lang.String key, int dim, java.lang.String opts, MProgressMonitor pm, java.lang.String[] warn)
k
- the record indexkey
- the molecule field name, null
for the main document (molecule)dim
- dimension, 2 or 3opts
- cleaning options or null
pm
- progress monitor to use or null
warn
- 1-element array to store the warning message, or nulltrue
if the document is changed, false
otherwisepublic MPropertyContainer getGlobalGUIProperties()